【问题标题】:discord.py: How to do Bot is missing permissions?discord.py:Bot 缺少权限怎么办?
【发布时间】:2021-12-03 17:24:49
【问题描述】:

更新:

我找到了原因, 这是新的工作代码:

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandInvokeError):
        return

希望它有效!

【问题讨论】:

    标签: python discord discord.py bots


    【解决方案1】:

    使用discord.Forbidden

    试试:

    if isinstance(error, discord.Forbidden):
         await ctx.send("Bot doesn't have permissions to do this **or** the bot can't do this. Please try again.")
    

    【讨论】:

    • 嗨!感谢您的回答。但它不起作用。
    • 哦,不是吗?你可以去 discord.py 官方服务器,他们会帮助你
    【解决方案2】:

    你的代码没有失败

    BotMissingPermissions

    试试这个代码 if isinstance(error, commands.CommandNotFound):

    if isinstance(error, commands.MissingPermissions):

    【讨论】:

    • 嗨!谢谢您的回答。 if isinstance(error, commands.CommandNotFound): 不起作用。如果用户使用 bot 中不存在的错误命令,则会出错。 if isinstance(error, commands.MissingPermissions): 代码不起作用。
    猜你喜欢
    • 2013-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 2011-06-01
    • 2021-01-01
    • 2020-09-19
    • 1970-01-01
    相关资源
    最近更新 更多