Dota2HelperBot.py 文件源码

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

项目:Dota2HelperBot 作者: enoch-ng 项目源码 文件源码
def on_command_error(error, ctx):
    channel = ctx.message.channel
    if isinstance(error, commands.MissingRequiredArgument):
        await bot.send_cmd_help(ctx)
    elif isinstance(error, commands.BadArgument):
        await bot.send_message(channel, "Truly, your wish is my command, but I cannot make head nor tail of the argument you provide.")
    elif isinstance(error, commands.CommandNotFound):
        # This is almost as ugly as Manta on Medusa
        await bot.send_message(channel, "I fear I know not of this \"%s\". Is it perchance a new Hero?" % ctx.message.content[len(bot.settings["prefix"]):].partition(' ')[0])
    elif isinstance(error, commands.CommandOnCooldown):
        await bot.send_message(channel, random.choice(CDMESSAGES) + " (%ss remaining)" % int(error.retry_after))
    elif isinstance(error, commands.NoPrivateMessage):
        await bot.send_message(channel, "Truly, your wish is my command, but that order is not to be issued in secret. It must be invoked in a server.")
    else:
        try:
            await bot.send_message(channel, "I fear some unprecedented disaster has occurred which I cannot myself resolve. Methinks you would do well to consult %s on this matter." % (await bot.get_owner()).mention)
        except discord.NotFound:
            await bot.send_message(channel, "I fear some unprecedented disaster has occurred which I cannot myself resolve.")
        if isinstance(error, commands.CommandInvokeError):
            print(repr(error.original))
        else:
            print(repr(error))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号