bot.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:AceBot 作者: Run1e 项目源码 文件源码
def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        return

    # if isinstance(error, commands.CommandInvokeError):
    #   return print(error)

    errors = {
        commands.DisabledCommand: 'Command has been disabled.',
        commands.MissingPermissions: 'Invoker is missing permissions to run this command.',
        commands.BotMissingPermissions: 'Bot is missing permissions to run this command.',
        commands.CheckFailure: 'You are not allowed to run this command.'
    }

    for type, text in errors.items():
        if isinstance(error, type):
            return await ctx.send(errors[type])

    # argument error
    if isinstance(error, commands.UserInputError):
        bot.formatter.context = ctx
        bot.formatter.command = ctx.command
        return await ctx.send(f'Invalid argument(s) provided.\n```{bot.formatter.get_command_signature()}```')

    await ctx.send(f'An error occured in `{ctx.command.name}` invoked by {ctx.message.author}:\n```{error}```')
    #traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr)

# blacklist check
# check is user is blacklister, or if it's a bot
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号