events.py 文件源码

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

项目:Nurevam 作者: Maverun 项目源码 文件源码
def on_command_error(self,ctx,error):
        if self.bot.user.id == 181503794532581376 or self.error_log:
            print(error)
        if isinstance(error, commands.MissingRequiredArgument):
            await self.send_cmd_help(ctx)
        elif isinstance(error,commands.BadArgument):
            await self.send_cmd_help(ctx)
        elif isinstance(error, commands.CommandInvokeError):
            if isinstance(error.original,discord_error.Forbidden):
                await ctx.send("I am sorry, I need a certain permission to run it...")
                traceback.print_exception(type(error), error, error.__traceback__)
                return utils.prRed(type(error.original))
            errors = traceback.format_exception(type(error), error, error.__traceback__)
            Current_Time = datetime.datetime.utcnow().strftime("%b/%d/%Y %H:%M:%S UTC")
            utils.prRed(Current_Time)
            utils.prRed("Error!")
            traceback.print_exception(type(error), error, error.__traceback__)
            cog_error =  '```fix\nCogs:{0.command.cog_name}\tCommand:{0.command}\tAuthor:{0.message.author}-{0.message.author.id}\n' \
                         'Server:{0.message.guild.id}\n{0.message.clean_content}\nError:\n{1}```'.format(ctx,error)
            msg ="```py\n{}```\n{}\n```py\n{}\n```".format(Current_Time + "\n"+ "ERROR!",cog_error,"".join(errors).replace("`",""))
            if len(msg) >= 1900:
                msg = await utils.send_hastebin(msg)
            await self.bot.owner.send(msg)
            await ctx.send("You either used the command incorrectly or an unexpected error occurred. A report has been sent to the creator so you can hope for a fix soon.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号