当某些用户做出反应时,我要赋予他们角色,但它说
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
该机器人具有管理员权限
这是我的代码:
@bot.event
async def on_raw_reaction_add(payload):
emoji = payload.emoji.name
canal = payload.channel_id
message = payload.message_id
python_role = get(bot.get_guild(payload.guild_id).roles, name="python")
member = bot.get_guild(payload.guild_id).get_member(payload.user_id)
if canal == 703637575566491731 and message == 703643218658459778 and emoji == "python":
await membre.add_roles(python_role)
错误代码:
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\natael\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:/Users/natael/PycharmProjects/tp's/bot discord/main.py", line 30, in on_raw_reaction_add
await membre.add_roles(python_role)
File "C:\Users\natael\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\member.py", line 641, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
File "C:\Users\natael\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\http.py", line 221, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
答案 0 :(得分:1)
机器人的角色必须高于授予用户的角色。
还有一个拼写错误: print("Hello \bWorld!")
成员/成员
答案 1 :(得分:1)
确保机器人的角色在角色层次结构中处于较高位置。
这是将您的机器人角色放置在层次结构中的位置的图片