Reputation: 57
So im making an error handler for my discord bot. I believe I have all the instances put into if statements. However when an error happens it sends 2-3 error instance messages at a time. How can i fix this? I was thinking an error message counter but i'm not sure how to do it.
Here is my handler:
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CheckFailure):
await ctx.send("[HANDLER] You do not have the required role to use this command!")
print(error)
if isinstance(error, commands.MissingPermissions):
await ctx.send("[HANDLER] You do not have sufficient permission settings to use this command!")
print(error)
if isinstance(error, commands.UserInputError):
await ctx.send("[HANDLER] Invalid input! You have most likely typed something wrong; check spelling and try again. Use $help for more information.")
print(error)
if isinstance(error, commands.CommandNotFound):
await ctx.send("[HANDLER] That command doesn't exist! You may have typed it wrong, try again. Use $help for more information")
print(error)
if isinstance(error, commands.BotMissingPermissions):
await ctx.send("[HANDLER] I'm missing the permissions to use this command!")
print(error)
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send("[HANDLER] You missed an argument! For help do $help [command].")
print(error)
if isinstance(error, commands.BadArgument):
await ctx.send("[HANDLER] Could not find that value!")
print(error)
if isinstance(error, commands.DisabledCommand):
await ctx.send("[HANDLER] This command has been disabled!")
print(error)
if isinstance(error, commands.NoPrivateMessage):
await ctx.send("[HANDLER] This command can not be used inside private messages!")
Thanks in advance!!!
Upvotes: 0
Views: 445
Reputation: 11
You didn't specify if you're getting different error instance messages, but since your if statements are merely if statements rather than if else statements, if an error is of more than one type, both error messages will be output.
Upvotes: 1