1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

Fix bot exiting on NotFound errors within on_command_error

This commit is contained in:
Dylan Dizon 2018-11-26 18:53:23 -05:00
parent 6ebd93ea14
commit 82fb640fc1

View file

@ -159,35 +159,36 @@ 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):
if isinstance(error, errext.CommandOnCooldown): with suppress(err.NotFound):
await ctx.message.add_reaction('\N{HOURGLASS}') if isinstance(error, errext.CommandOnCooldown):
await asyncio.sleep(error.retry_after) await ctx.message.add_reaction('\N{HOURGLASS}')
await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}') await asyncio.sleep(error.retry_after)
elif isinstance(error, err.NotFound): await ctx.message.add_reaction('\N{WHITE HEAVY CHECK MARK}')
print('NOT FOUND') elif isinstance(error, err.NotFound):
elif isinstance(error, err.Forbidden): print('NOT FOUND')
pass elif isinstance(error, err.Forbidden):
elif isinstance(error, errext.MissingRequiredArgument): pass
await ctx.send('**Missing required argument**') elif isinstance(error, errext.MissingRequiredArgument):
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.send('**Missing required argument**')
elif isinstance(error, errext.BadArgument): await ctx.message.add_reaction('\N{CROSS MARK}')
await ctx.send(f'**Invalid argument.** {error}') elif isinstance(error, errext.BadArgument):
await ctx.message.add_reaction('\N{CROSS MARK}') await ctx.send(f'**Invalid argument.** {error}')
elif isinstance(error, errext.CheckFailure): await ctx.message.add_reaction('\N{CROSS MARK}')
await ctx.send('**Insufficient permissions**') elif isinstance(error, errext.CheckFailure):
await ctx.message.add_reaction('\N{NO ENTRY}') await ctx.send('**Insufficient permissions**')
elif isinstance(error, errext.CommandNotFound): await ctx.message.add_reaction('\N{NO ENTRY}')
print('INVALID COMMAND : {}'.format(error), file=sys.stderr) elif isinstance(error, errext.CommandNotFound):
await ctx.message.add_reaction('\N{BLACK QUESTION MARK ORNAMENT}') print('INVALID COMMAND : {}'.format(error), file=sys.stderr)
else: await ctx.message.add_reaction('\N{BLACK QUESTION MARK ORNAMENT}')
print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format( else:
error), file=sys.stderr) print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format(
tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr) error), file=sys.stderr)
await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr)
await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.name, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error))
await exc.send_error(ctx, error) await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.name, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error))
await ctx.message.add_reaction('\N{WARNING SIGN}') await exc.send_error(ctx, error)
# u.notify('C O M M A N D E R R O R') await ctx.message.add_reaction('\N{WARNING SIGN}')
# u.notify('C O M M A N D E R R O R')
# @bot.event # @bot.event
# async def on_command(ctx): # async def on_command(ctx):