Skip to content

Commit

Permalink
removed command not found, optimised error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
XInTheDark committed Aug 11, 2022
1 parent c9b70c6 commit 25caf75
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def on_ready():
# init variables
downloadSpeed = speedTestDownload()


# error handling
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, BotMissingPermissions):
Expand All @@ -126,18 +126,20 @@ async def on_command_error(ctx, error):
await ctx.send(f'`Missing Roles!`')
if isinstance(error, CommandInvokeError):
msg = await ctx.send(f'`{error}`\nPlease contact the bot owner for assistance if necessary.')
# await asyncio.sleep(3)
# await msg.delete()
if isinstance(error, CommandOnCooldown):
msg = await ctx.reply(f'`{error}`')
await asyncio.sleep(3)
await msg.delete()
if isinstance(error, MissingRequiredArgument) or isinstance(error, TooManyArguments):
await ctx.send(f'`Missing Required Arguments!`\nFor the command\'s help page, type `.help <command>`!')
if isinstance(error, CommandNotFound):
msg = await ctx.send(f'`Command not found!`')
await asyncio.sleep(3)
if isinstance(error, CommandOnCooldown):
msg = await ctx.reply(f'`{error}`', mention_author=False)
await asyncio.sleep(2)
await msg.delete()
if isinstance(error, MissingRequiredArgument)
await ctx.send(f'`Missing Required Arguments!`\nFor the command\'s help page, type `.help <command>`!')
if isinstance(error, TooManyArguments):
await ctx.send(f'`Too Many Arguments Provided!`\nFor the command\'s help page, type `.help <command>`!')
# if isinstance(error, CommandNotFound):
# msg = await ctx.send(f'`Command not found!`')
# await asyncio.sleep(3)
# await msg.delete()


# @bot.event
Expand Down

0 comments on commit 25caf75

Please sign in to comment.