def _on_command_error(self, exception, ctx):
# non-existing commands won't trigger check thus are not deleted
if isinstance(exception, dec.CommandNotFound) and not isinstance(ctx.message.channel, discord.PrivateChannel):
await self._bot.client.delete_message(ctx.message)
# get a cause if the exception was thrown inside the command routine
if isinstance(exception, dec.CommandInvokeError):
exception = exception.__cause__
# now inform the author of the command on the failure using PMs
await self._bot.client.send_message(ctx.message.author, str(exception))
# log the error for debugging purposes
log.debug('Command \'{}\' invoked by {} raised an exception\n{}'
.format(ctx.command, ctx.message.author, ctx.message.content), exc_info=exception)
评论列表
文章目录