Skip to content

Commit

Permalink
#44 - code refactor, add help snippet for invite comman
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgfedericotomasi committed Oct 16, 2022
1 parent ea2c5e8 commit 0aa4359
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/Bot.Discord/Commands/HelpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Task<Result<IDiscordInteractionResponse>> ShowHelpAsync()
new DiscordEmbedBuilder()
.WithTitle("Help | Misc commands | Page 3")
.WithField($"{Constants.SlashPrefix}{AboutCommands.AboutCommandName}", AboutCommands.AboutCommandDesc)
.WithField($"{Constants.SlashPrefix}{InviteCommands.InviteCommandName}", InviteCommands.InviteCommandDesc)
.WithColor(Constants.Colors.Neutral)
.Build();

Expand Down
27 changes: 15 additions & 12 deletions src/Bot.Discord/Commands/InviteCommands.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Bot.Discord.Components;
using Color_Chan.Discord.Commands.Attributes;
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.API.DataModels;
using Color_Chan.Discord.Core.Common.Models;
using Color_Chan.Discord.Core.Common.Models.Interaction;
using Color_Chan.Discord.Core.Results;

Expand All @@ -18,7 +18,6 @@ public class InviteCommands : SlashCommandModule
public const string InviteCommandName = "invite";
public const string InviteCommandDesc = "Invite the bot somewhere else!";


/// <summary>
/// An invitation command where the bot will reply back with a link to be added to other servers.
/// </summary>
Expand All @@ -28,21 +27,25 @@ public class InviteCommands : SlashCommandModule
[SlashCommand(InviteCommandName, InviteCommandDesc)]
public Task<Result<IDiscordInteractionResponse>> InviteAsync()
{
var inviteMeEmbed = new DiscordEmbedBuilder()
.WithTitle("Invite me")
.WithDescription("I need more friends, add me to other Discord servers!")
.WithColor(Constants.Colors.Successful)
.WithTimeStamp()
.Build();

// Build the embedded response.
var inviteResponse = new InteractionResponseBuilder()
.WithEmbed(InviteMeEmbed)
.WithComponent(InviteButtons.InviteMe)
.WithEmbed(inviteMeEmbed)
.WithComponent(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()
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();
}
13 changes: 0 additions & 13 deletions src/Bot.Discord/Components/InviteButtons.cs

This file was deleted.

0 comments on commit 0aa4359

Please sign in to comment.