-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Amino-NET-Group/dev
move dev to master
- Loading branch information
Showing
13 changed files
with
343 additions
and
548 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Discord; | ||
using Discord.Interactions; | ||
using Discord.WebSocket; | ||
|
||
|
||
namespace AminoBot | ||
{ | ||
public class Components : InteractionModuleBase | ||
{ | ||
|
||
private readonly DiscordSocketClient _client; | ||
public Components(DiscordSocketClient client) | ||
{ | ||
this._client = client; | ||
} | ||
|
||
[ComponentInteraction("amino-help_help")] | ||
public async Task HandleHelpCommandButton() | ||
{ | ||
await DeferAsync(); | ||
EmbedBuilder embed = new EmbedBuilder(); | ||
ComponentBuilder components = new ComponentBuilder(); | ||
|
||
embed.Color = Color.Teal; | ||
embed.Title = "AminoBot Help"; | ||
embed.Description = "A list of all commands"; | ||
|
||
foreach(var command in await _client.GetGlobalApplicationCommandsAsync()) | ||
{ | ||
embed.AddField($"</{command.Name}:{command.Id}>", command.Description); | ||
} | ||
|
||
components.WithButton("Help", "amino-help_help", ButtonStyle.Primary, disabled: true); | ||
components.WithButton("About", "amino-help_about", ButtonStyle.Secondary); | ||
|
||
await ModifyOriginalResponseAsync(msg => { msg.Embed = embed.Build(); msg.Components = components.Build(); }); | ||
} | ||
|
||
[ComponentInteraction("amino-help_about")] | ||
public async Task HandleHelpAboutButton() | ||
{ | ||
await DeferAsync(); | ||
EmbedBuilder embed = new EmbedBuilder(); | ||
ComponentBuilder components = new ComponentBuilder(); | ||
embed.Title = "AminoBot Info"; | ||
embed.Description = "AminoBot is a Discord Bot designed to act as a simple interface to interact with the Aminoapps API for Developers and Users alike.\nThis project is brought to you by the Amino.NET Group"; | ||
embed.AddField("Links", "[Join our Discord Server!](https://discord.com/invite/2JeE54uG7x)\n[Github](https://github.com/Amino-NET-Group/AminoBot)\n[Amino.NET Github](https://github.com/Amino-NET-Group/Amino.NET)"); | ||
embed.Color = Color.Teal; | ||
|
||
components.WithButton("Help", "amino-help_help", ButtonStyle.Secondary); | ||
components.WithButton("About", "amino-help_about", ButtonStyle.Primary, disabled: true); | ||
|
||
await ModifyOriginalResponseAsync(msg => { msg.Embed = embed.Build(); msg.Components = components.Build(); }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Discord; | ||
|
||
namespace AminoBot | ||
{ | ||
public static class CoolDown | ||
{ | ||
static Dictionary<ulong, long> timeoutList = new Dictionary<ulong, long>(); // userId : expirationTime | ||
|
||
|
||
/// <summary> | ||
/// Checks if the given user is on Cooldown, if the time expired it will automatically remove them from the list | ||
/// </summary> | ||
/// <param name="targetUser"></param> | ||
/// <returns></returns> | ||
public static bool IsOnCooldown(this IUser targetUser) | ||
{ | ||
if (!timeoutList.ContainsKey(targetUser.Id)) return false; | ||
if (timeoutList[targetUser.Id] <= DateTimeOffset.UtcNow.ToUnixTimeSeconds()) | ||
{ | ||
timeoutList.Remove(targetUser.Id); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
|
||
public static Task AddUser(this IUser targetUser) | ||
{ | ||
if(!timeoutList.ContainsKey(targetUser.Id)) | ||
{ | ||
timeoutList.Add(targetUser.Id, (DateTimeOffset.UtcNow.ToUnixTimeSeconds() + new Utils().GetConfig().CommandTimeout)); | ||
} | ||
return Task.CompletedTask; | ||
} | ||
|
||
|
||
public static long GetRemainingTimeoutSeconds(this IUser targetUser) | ||
{ | ||
if (!timeoutList.ContainsKey(targetUser.Id)) return 0; | ||
return (timeoutList[targetUser.Id] - DateTimeOffset.UtcNow.ToUnixTimeSeconds()); | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.