Skip to content Skip to sidebar Skip to footer

'nonetype' Object Has No Attribute 'remove_roles' Discord.py

Keep getting an error for the reaction_remove, just copy-pasted my whole code(minus the client id) cause it might help, I have no idea what's wrong as the first half works perfectl

Solution 1:

If you try printing the payload.member the output will be None - it's because you didn't enable intents.members. To enable them:

intents = discord.Intents.default()
intents.members = True 

client = discord.Client(intents=intents)

Also make sure to enable intents in the developer portal

How to enable privileged intents

Solution 2:

The below answer is one part of the solution to make this code work so implement the provided answer. I found out in another issue that in the documentation payload.member is only available if the event_type is REACTION_ADD so i fixed it by adding:

intents = discord.Intents.default()
intents.members = Trueclient = discord.Client(intents=intents)     

After you have added this, change the

member = payload.member 

to

member = guild.get_member(payload.user_id)

That is what worked for me let me know if this helps.

Solution 3:

payload.member will always be None when the event is on_raw_reaction_remove. As such, you will have to use guild.get_member() and the payload's user_id to obtain the member from cache, which also requires having the members intent enabled.

Solution 4:

I dont know if this is still an active problem, but I had the same problem and solved it right now after some time and wanted to share with you how I have done this.

I hope i could help other peoble with this.

intents = discord.Intents().all()
bot = commands.Bot(command_prefix='!', intents=intents)

↑ Add this at the top of your code right under imports



@bot.event
async def on_raw_reaction_add(payload):
    guild = bot.get_guild(payload.guild_id)
    member = payload.memberemoji= payload.emoji.namechannel= discord.utils.get(guild.channels, name='regeln')
    channel_id = channel.idmessage_id=874741218523873370ifmessage_id== payload.message_id:
        if payload.channel_id == channel_id:
            ifemoji== '1️⃣':
                role = discord.utils.get(guild.roles, name='News1')
            ifemoji== '2️⃣':
                role = discord.utils.get(guild.roles, name='News2')
            ifemoji== '3️⃣':
                role = discord.utils.get(guild.roles, name='News3')
            ifemoji== '4️⃣':
                role = discord.utils.get(guild.roles, name='News4')
        await member.add_roles(role)



@bot.event
async def on_raw_reaction_remove(payload):
    guild = bot.get_guild(payload.guild_id)
    member = guild.get_member(payload.user_id)
    emoji = payload.emoji.namechannel= discord.utils.get(guild.channels, name='regeln')
    channel_id = channel.idmessage_id=874741218523873370ifmessage_id== payload.message_id:
        if payload.channel_id == channel_id:
            ifemoji== '1️⃣':
                role = discord.utils.get(guild.roles, name='News1')
            ifemoji== '2️⃣':
                role = discord.utils.get(guild.roles, name='News2')
            ifemoji== '3️⃣':
                role = discord.utils.get(guild.roles, name='News3')
            ifemoji== '4️⃣':
                role = discord.utils.get(guild.roles, name='News4')
        await member.remove_roles(role)

Post a Comment for "'nonetype' Object Has No Attribute 'remove_roles' Discord.py"