async 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)
async def on_command_error(self, context: Context, exception): """ Custom command error handling. :param context: the context of the exception raised. :param exception: the exception raised. """ if isinstance(exception, CommandNotFound): return try: res = command_error_handler(exception) except Exception as e: tb = format_exc() msg, triggered = format_command_error(e, context) self.bot.logger.warn(f'\n{msg}\n\n{tb}') await context.send(f':warning: I ran into an error while ' f'executing this command.\n{msg}') await self.bot.send_tb( f'**WARNING** Triggered message:\n{triggered}', tb) else: await context.send(res)