def on_command_error(ctx, error):
if isinstance(error, commands.NoPrivateMessage):
await ctx.send(content='This command cannot be used in private messages.')
elif isinstance(error, commands.DisabledCommand):
await ctx.send(content='This command is disabled and cannot be used.')
elif isinstance(error, commands.MissingRequiredArgument):
await bot.formatter.format_help_for(ctx, ctx.command, "You are missing required arguments.")
elif isinstance(error, commands.CommandNotFound):
# await ctx.send('Command not found. (I\'m working on fixing cmd_not_found forf help module')
await bot.formatter.format_help_for(ctx, [c for c in bot.commands if 'help' == c.name][0],
"Command not found.")
elif isinstance(error, commands.CommandInvokeError):
print('In {0.command.qualified_name}:'.format(ctx), file=sys.stderr)
print('{0.__class__.__name__}: {0}'.format(error.original), file=sys.stderr)
traceback.print_tb(error.__traceback__, file=sys.stderr)
log.error('In {0.command.qualified_name}:'.format(ctx))
log.error('{0.__class__.__name__}: {0}'.format(error.original))
else:
traceback.print_tb(error.__traceback__, file=sys.stderr)
评论列表
文章目录