excalibot.py 文件源码

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

项目:Excalibot 作者: endreman0 项目源码 文件源码
def on_command_error(self, ctx, err):
        if isinstance(err, errors.PermissionDenied):
            await ctx.send('BAKA! You do not have my permission!')
        elif isinstance(err, errors.MissingPermissions):
            await ctx.send('BAKA! I require these permissions: %s' % ', '.join(err.args))
        elif isinstance(err, commands.NoPrivateMessage):
            await ctx.send('BAKA! This command does not work in private messages!')
        elif isinstance(err, commands.BadArgument):
            str_err = str(err)
            if not str_err.endswith(('.', '!')):
                str_err += '.'
            await ctx.send('BAKA! %s' % str_err)
        elif isinstance(err, commands.MissingRequiredArgument):
            await ctx.send('BAKA! Missing required argument: `%s`' % err.args[0].partition(' ')[0])
        elif isinstance(err, commands.TooManyArguments):
            await ctx.send('BAKA! Too many arguments!')
        elif isinstance(err, commands.CommandNotFound):
            pass
        else:
            await ctx.send('```\n%s\n```' % ''.join(traceback.format_exception_only(type(err), err)).strip())
            if isinstance(ctx.channel, discord.TextChannel):
                log.error('Error in command <{0}> ({1.name!r}({1.id}) {2}({2.id}) {3}({3.id}) {4!r})'.format(ctx.command, ctx.guild, ctx.channel, ctx.author, ctx.message.content))
            else:
                log.error('Error in command <{0}> (DM {1}({1.id}) {2!r})'.format(ctx.command, ctx.channel.recipient, ctx.message.content))
            log.error(''.join(traceback.format_exception(type(err), err, err.__traceback__)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号