【发布时间】: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