Reputation: 13
I am to give role to some users when they react but it says
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
And the bot have administrator permissions
Here is my code :
@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)
the error code :
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:/Users/****/PycharmProjects/tp's/bot discord/main.py", line 30, in on_raw_reaction_add
await membre.add_roles(python_role)
File "C:\Users\****\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\****\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
Upvotes: 1
Views: 1885
Reputation: 90
Make sure that the role of the bot is high on the role hierarchy.
This is a picture of where to put your bots role on the hierarchy
Upvotes: 3
Reputation: 195
The Role of the bot has to be higher than the one given to the user.
there is also a spelling mistake:await membre.add_roles(python_role)
membr/member
Upvotes: 2