bot.py 文件源码

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

项目:AutomaBot 作者: 73VW 项目源码 文件源码
def on_command_error(self, exception, context):
        """
        Override bot.on_command_error function.

        Error handling function.
        """
        if isinstance(exception, discord.ext.commands.errors.CommandNotFound):
            msg = """Sorry, this command is unknown to me... :japanese_ogre:\
                    \nDo you need help? \
                    \nIf so, just type ***!help*** :sunglasses:"""
        elif isinstance(exception,
                        discord.ext.commands.errors.DisabledCommand):
            msg = ":sleeping:"
        elif isinstance(exception,
                        discord.ext.commands.errors.CheckFailure):
            msg = """:octagonal_sign: you are not allowed to do this.\
                    \nOnly an :alien: can wake me up..."""
        elif isinstance(exception,
                        discord.ext.commands.errors.MissingRequiredArgument):
            msg = """:thought_balloon: You forgot parameters.\
                    \nType !help [command] to get help :interrobang:"""
        elif isinstance(exception,
                        APIconnectionError):
            msg = """It seems we can't contact the API...:frowning2: \
            \nTake a rest and retry later.:play_pause: """
        elif isinstance(exception,
                        discord.ext.commands.errors.CommandInvokeError):
            msg = "oups... " + str(exception)
            print(msg)
        else:
            msg = "oups inconnu... " + str(type(exception)) + str(exception)
            print(msg)
        await self.send_message(context.message.channel, msg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号