[Bug] Add back command to set up verification buttons
Closed this issue · 2 comments
stepech commented
Idk how, but somehow it got lost when switching from Commands to SlashCommands
stepech commented
Inspiration can be taken from:
honza-botner/src/HonzaBotner.Discord.Services/Commands/MessageCommands.cs
Lines 232 to 293 in b62ca96
public class ButtonCommands : BaseCommandModule | |
{ | |
private readonly IButtonManager _buttonManager; | |
public ButtonCommands(IButtonManager manager) | |
{ | |
_buttonManager = manager; | |
} | |
[Description("Deletes all button interactions on the message")] | |
[Command("remove")] | |
public async Task RemoveButtons(CommandContext ctx, [Description("URL of the message")] string url) | |
{ | |
DiscordGuild guild = ctx.Guild; | |
DiscordMessage? message = await DiscordHelper.FindMessageFromLink(guild, url); | |
if (message == null) | |
{ | |
throw new ArgumentOutOfRangeException($"Couldn't find message with link: {url}"); | |
} | |
try | |
{ | |
await _buttonManager.RemoveButtonsFromMessage(message); | |
} | |
catch (UnauthorizedException) | |
{ | |
await ctx.RespondAsync("Error: You can only edit messages by this bot."); | |
return; | |
} | |
DiscordEmoji reactEmoji = DiscordEmoji.FromName(ctx.Client, ":+1:"); | |
await ctx.Message.CreateReactionAsync(reactEmoji); | |
} | |
[Description("Marks message as verification message")] | |
[Command("setup")] | |
public async Task SetupButtons( | |
CommandContext ctx, | |
[Description("URL of the message")] string url | |
) | |
{ | |
DiscordGuild guild = ctx.Guild; | |
DiscordMessage? message = await DiscordHelper.FindMessageFromLink(guild, url); | |
if (message == null) | |
{ | |
throw new ArgumentOutOfRangeException($"Couldn't find message with link: {url}"); | |
} | |
try | |
{ | |
await _buttonManager.SetupVerificationButtons(message); | |
} | |
catch (UnauthorizedException) | |
{ | |
await ctx.RespondAsync("Error: You can only edit messages by this bot."); | |
return; | |
} | |
DiscordEmoji reactEmoji = DiscordEmoji.FromName(ctx.Client, ":+1:"); | |
await ctx.Message.CreateReactionAsync(reactEmoji); | |
} | |
} |
stepech commented
In case we proceed with a plan discussed in discord to change the way verification works, this might actually be a fix that would be useful just for one app version and then removed with potential rewrite. I am thus removing it from todo for the next version.