【问题标题】:Adding role to user does not work, giving "Missing Permissions" error - discord.py向用户添加角色不起作用,出现“缺少权限”错误 - discord.py
【发布时间】:2022-02-10 00:44:00
【问题描述】:

我已经开始制作一个 Discord 机器人,它遵循诸如 kick、ban 等基本命令。我试图制作一个验证功能,在用户激活命令时将“会员”角色添加到用户。但是,当机器人尝试运行await author.add_roles(role) 行时,它会返回此错误:

An exception has occurred while executing command `verify`:
...
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

我已经检查了机器人是否具有执行此命令的正确权限,并且确实如此。它具有管理员权限,足以为用户赋予角色。

这是我正在使用的代码:

@slash.slash(
    name="verify",
    description="...",
    guild_ids=guilds
)

async def _verify(ctx: SlashCommand):
    role = discord.utils.get(ctx.guild.roles, name="Member")
    if role not in ctx.author.roles: # I am using ctx.author instead of ctx.message.author, because this is a slash command.
        await author.add_roles(role)

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    我完全忘记了你不能管理高于你的角色,而我的成员角色高于机器人角色。这就是它给出错误的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多