def on_command_error(self, exception, context):
"""
Custom command error handling
:param exception: the expection raised
:param context: the context of the command
"""
if isinstance(exception, Forbidden):
# Ignore this case
return
if isinstance(exception, CommandNotFound):
# Ignore this case
return
channel = context.message.channel
try:
res = command_error_handler(exception)
except Exception as e:
tb = format_exc()
msg, triggered = format_command_error(e, context)
self.logger.log(logging.WARN, f'\n{msg}\n\n{tb}')
warn = (f':warning: I ran into an error while executing this '
f'command. It has been reported to my developers.\n{msg}')
await self.__try_send_msg(channel, context.message.author, warn)
await self.send_traceback(
tb, f'**WARNING** Triggered message:\n{triggered}')
else:
await self.__try_send_msg(channel, context.message.author, res)
评论列表
文章目录