📝 Better functioning error handling

This commit is contained in:
NikolajDanger
2021-04-03 22:35:11 +02:00
parent 0fb7887745
commit 1a2ead8448
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import discord, traceback
import discord, traceback, discord_slash
from discord.ext import commands
class EventHandler():
@ -28,9 +28,11 @@ class ErrorHandler():
async def on_slash_command_error(self, ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("That's not a command (error code 001)")
elif isinstance(error,commands.errors.MissingRequiredArgument):
elif isinstance(error, commands.errors.MissingRequiredArgument):
self.bot.log(f"{error}",str(ctx.channel_id))
await ctx.send("Missing command parameters (error code 002). Try using `!help [command]` to find out how to use the command.")
elif isinstance(error, discord_slash.error.AlreadyResponded):
self.bot.log("Defer failed")
else:
exception = traceback.format_exception(type(error), error, error.__traceback__)
stopAt = "\nThe above exception was the direct cause of the following exception:\n\n"
@ -53,4 +55,4 @@ class ErrorHandler():
exception = exception[:index]
exceptionString = "".join(exception)
self.bot.log([f"exception in /{method}", f"{exceptionString}"], level = 40)
self.bot.log([f"exception in {method}", f"{exceptionString}"], level = 40)