error_handler.py 文件源码

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

项目:kitsuchan-2 作者: n303p4 项目源码 文件源码
def setup(bot):
    """Set up the cog."""

    @bot.check
    def is_human(ctx):
        """Prevent the bot from responding to other bots."""
        if ctx.author.bot:
            raise IsNotHuman("User is not human")
        return True

    @bot.listen("on_command_error")
    async def handle_error(ctx, exc):
        """Simple error handler."""
        if isinstance(exc, commands.MissingRequiredArgument):
            param = exc.param.replace("_", " ")
            await ctx.send(f"Please specify a {param} for this command to work.")
        elif not isinstance(exc, (commands.CommandNotFound, IsNotHuman)):
            await ctx.send(exc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号