mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 14:27:27 +00:00
Add minimal error catching for command invocations
This commit is contained in:
parent
7dce8f2d3c
commit
88e173efa2
1 changed files with 7 additions and 5 deletions
12
src/run.py
12
src/run.py
|
@ -160,14 +160,16 @@ async def on_error(error, *args, **kwargs):
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_error(ctx, error):
|
async def on_command_error(ctx, error):
|
||||||
with suppress(err.NotFound):
|
with suppress(err.NotFound):
|
||||||
if isinstance(error, errext.CommandOnCooldown):
|
if isinstance(error, err.NotFound):
|
||||||
await ctx.message.add_reaction('\N{HOURGLASS}')
|
|
||||||
await asyncio.sleep(error.retry_after)
|
|
||||||
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
|
||||||
elif isinstance(error, err.NotFound):
|
|
||||||
print('NOT FOUND')
|
print('NOT FOUND')
|
||||||
elif isinstance(error, err.Forbidden):
|
elif isinstance(error, err.Forbidden):
|
||||||
pass
|
pass
|
||||||
|
elif isinstance(error, errext.CommandInvokeError):
|
||||||
|
print('INVOCATION ERROR')
|
||||||
|
elif isinstance(error, errext.CommandOnCooldown):
|
||||||
|
await u.add_reaction(ctx.message, '\N{HOURGLASS}')
|
||||||
|
await asyncio.sleep(error.retry_after)
|
||||||
|
await u.add_reaction(ctx.message, '\N{WHITE HEAVY CHECK MARK}')
|
||||||
elif isinstance(error, errext.MissingRequiredArgument):
|
elif isinstance(error, errext.MissingRequiredArgument):
|
||||||
await ctx.send('**Missing required argument**')
|
await ctx.send('**Missing required argument**')
|
||||||
await u.add_reaction(ctx.message, '\N{CROSS MARK}')
|
await u.add_reaction(ctx.message, '\N{CROSS MARK}')
|
||||||
|
|
Loading…
Reference in a new issue