I've started to create a bot for my discord, trying to add a role after a user's reaction, but I still have a 403 forbidden (error code 50013): Missing permission when I've already put in the right permissions (8) to the bot.
@client.event
async def on_raw_reaction_add(payload):
message_id = payload.message_id
if message_id == 706945439945195551:
guild_id = payload.guild_id
guild = discord.utils.find(lambda g : g.id == guild_id, client.guilds)
if payload.emoji.name == 'montmo':
role = discord.utils.get(guild.roles, name='membre')
Traceback (most recent call last):
File "D:\ProgramData\Python\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "c:/Users/bntth/Documents/Python/Projets/Bot discord/bot_elogic.py", line 47, in on_raw_reaction_add
await member.add_roles(role)
File "D:\ProgramData\Python\lib\site-packages\discord\member.py", line 641, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
File "D:\ProgramData\Python\lib\site-packages\discord\http.py", line 221, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
Do you have any idea what might be causing this mistake? Did I forget something in the configuration or the code? Thank you in advance for your help
The bot's highest role has to be higher than the role you're attempting to add.
Consider this list of roles:
Member
is the default. They're not able to assign Moderator
, Bot
or Admin
to other members.
In the same way, people with Moderator
won't be able to assign Bot
or Admin
, but are able to assign Member
roles.
And if a bot with role Bot
tried to assign Admin
to another user, it wouldn't have the permissions to. However, it would have the permissions to assign Moderator
and Member
roles.
To fix this, just move the Bot
role to the top of the list, and then it'll be able to assign all roles.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加