mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-01-31 01:25:22 +01:00
automatically remove messages in old text command format
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Net;
|
||||
using DSharpPlus.Commands.EventArgs;
|
||||
using DSharpPlus.Commands.Exceptions;
|
||||
using DSharpPlus.Commands.Processors.TextCommands;
|
||||
using DSharpPlus.Exceptions;
|
||||
|
||||
namespace CompatBot.Commands.Processors;
|
||||
@@ -10,9 +11,15 @@ internal static class CommandErroredHandler
|
||||
// CommandsExtension.DefaultCommandErrorHandlerAsync()
|
||||
public static async Task OnError(CommandsExtension sender, CommandErroredEventArgs eventArgs)
|
||||
{
|
||||
StringBuilder stringBuilder = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
DiscordMessageBuilder messageBuilder = new();
|
||||
|
||||
if (eventArgs is { Exception: CommandNotFoundException, Context: TextCommandContext tctx })
|
||||
{
|
||||
await tctx.Message.DeleteAsync().ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Error message
|
||||
stringBuilder.Append(eventArgs.Exception switch
|
||||
{
|
||||
|
||||
@@ -145,6 +145,8 @@ internal static class Program
|
||||
Config.CommandPrefix,
|
||||
Config.AutoRemoveCommandPrefix
|
||||
).ResolvePrefixAsync,
|
||||
IgnoreBots = true,
|
||||
EnableCommandNotFoundException = true,
|
||||
});
|
||||
var appCommandProcessor = new SlashCommandProcessor(new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user