diff --git a/src/Bot.Discord/Commands/InviteCommands.cs b/src/Bot.Discord/Commands/InviteCommands.cs new file mode 100644 index 0000000..8c0ad76 --- /dev/null +++ b/src/Bot.Discord/Commands/InviteCommands.cs @@ -0,0 +1,48 @@ +using Bot.Discord.Components; +using Color_Chan.Discord.Commands.Attributes; +using Color_Chan.Discord.Commands.Attributes.ProvidedRequirements; +using Color_Chan.Discord.Commands.MessageBuilders; +using Color_Chan.Discord.Commands.Modules; +using Color_Chan.Discord.Core.Common.Models.Embed; +using Color_Chan.Discord.Core.Common.Models.Interaction; +using Color_Chan.Discord.Core.Results; + +namespace Bot.Discord.Commands; + +/// +/// The command module for inviting the bot to other Discord's servers. +/// +[UserRateLimit(5, 10)] // Sets the rate lcimit for this command module to 5 requests per 10 seconds per user. +public class InviteCommands : SlashCommandModule +{ + public const string InviteCommandName = "invite"; + public const string InviteCommandDesc = "Invite the bot somewhere else!"; + + + /// + /// An invitation command where the bot will reply back with a link to be added to other servers. + /// + /// + /// An embedded response with the provided message. + /// + [SlashCommand(InviteCommandName, InviteCommandDesc)] + public Task> InviteAsync() + { + // Build the embedded response. + var inviteResponse = new InteractionResponseBuilder() + .WithEmbed(InviteMeEmbed) + .WithComponent(InviteButtons.InviteMe) + .Build(); + + // Return the response to Discord. + return Task.FromResult(FromSuccess(inviteResponse)); + } + + public static readonly IDiscordEmbed InviteMeEmbed = + new DiscordEmbedBuilder() + .WithTitle("Invite me") + .WithDescription("I need more friends, add me to other Discord servers!") + .WithColor(Constants.Colors.Successful) + .WithTimeStamp() + .Build(); +} \ No newline at end of file diff --git a/src/Bot.Discord/Components/InviteButtons.cs b/src/Bot.Discord/Components/InviteButtons.cs new file mode 100644 index 0000000..a941a6b --- /dev/null +++ b/src/Bot.Discord/Components/InviteButtons.cs @@ -0,0 +1,13 @@ +using Color_Chan.Discord.Commands.MessageBuilders; +using Color_Chan.Discord.Core.Common.API.DataModels; +using Color_Chan.Discord.Core.Common.Models; + +namespace Bot.Discord.Components; + +public static class InviteButtons +{ + public static readonly IDiscordComponent InviteMe = + new ActionRowComponentBuilder() + .WithButton("Invite me!", DiscordButtonStyle.Link, null, $"https://discord.com/api/oauth2/authorize?client_id={Constants.BotId}&permissions=0&scope=bot%20applications.commands") + .Build(); +}