Discord.py add reaction role issue

Regen

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

Diggy.

The bot's highest role has to be higher than the role you're attempting to add.

Consider this list of roles:

  1. Admin
  2. Bot
  3. Moderator
  4. Member

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]

編集
0

コメントを追加

0

関連記事

分類Dev

Discord.py bot, assign role when a user adds reaction

分類Dev

On_Reaction_Add() with messages sent in On_Ready() Discord.PY

分類Dev

Discord.py: wait_for('reaction_add') not working as intended

分類Dev

Unable to add permissions to a newly created role in Discord.py

分類Dev

Discord.py on_raw_reaction_add()に1つの必須の位置引数がありません: 'user'

分類Dev

Discord.py, how do I delete a role?

分類Dev

discord.py make bot kick users with specified role

分類Dev

How to give role to user for reaction

分類Dev

Adding a role to a user when they click a reaction on a message

分類Dev

on_reaction_add custom emoji

分類Dev

Discord.js v12 Role add to mentioned user problem

分類Dev

Discord.py SSLCertVerificationError

分類Dev

Discord.py Massdm

分類Dev

Discord py get input

分類Dev

add_rolesに関するDiscord.pyの問題

分類Dev

Discord JS add role byreactionコマンドが再起動後に機能しない

分類Dev

on_guild_role_createイベントがdiscord.py-rewrite v1.3.4で機能しない

分類Dev

Discord.py discord.NotFound exception

分類Dev

Discord.py wait_for()

分類Dev

Discord.py Custom Status

分類Dev

Discord py message.createdat

分類Dev

discord.pyのtyperacer

分類Dev

Entity Framework Add User to Role

分類Dev

Take random user from a discord server in discord.py

分類Dev

on_raw_reaction_adddiscord.pyからのメッセージの取得

分類Dev

message.content.startswith Discord.Py

分類Dev

@bot.event in a cog discord.py

分類Dev

Discord.py-> channel.mention

分類Dev

Discord.Py OpusHerokuの問題