SupportChild/Commands/RemoveMessageCommand.cs

41 lines
1.3 KiB
C#
Raw Permalink Normal View History

2022-08-21 07:34:11 +00:00
using DSharpPlus.Entities;
2022-02-21 08:40:09 +00:00
using System.Threading.Tasks;
2022-08-21 07:34:11 +00:00
using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes;
2022-02-21 08:40:09 +00:00
2022-08-21 07:34:11 +00:00
namespace SupportChild.Commands;
2022-02-21 08:40:09 +00:00
2022-08-21 07:34:11 +00:00
public class RemoveMessageCommand : ApplicationCommandModule
{
[SlashRequireGuild]
[SlashCommand("removemessage", "Removes a message from the 'say' command.")]
public async Task OnExecute(InteractionContext command, [Option("Identifier", "The identifier word used in the /say command.")] string identifier)
{
if (!Database.TryGetMessage(identifier.ToLower(), out Database.Message _))
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "There is no message with that identifier."
}, true);
return;
}
2022-02-21 08:40:09 +00:00
if (Database.RemoveMessage(identifier))
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Message removed."
}, true);
}
else
{
await command.CreateResponseAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error: Failed removing the message from the database."
}, true);
}
}
2022-05-19 11:38:59 +00:00
}