Skip to content
Advertisement

Bot doesn’t want to add roles on reaction [closed]

I want bot to add role and remove another one for those who reacts on message.

@client.event
async def on_raw_reaction_add(payload):
    rUnauthorized=payload.member.guild.get_role(672473730114387968)
    rMember=payload.member.guild.get_role(672473925053055036)
    if payload.message_id==679223445258633216:
        if payload.emoji.name=='white_check_mark':
            print('Sucess!')
            await payload.member.add_roles(rMember)
            await payload.member.remove_roles(rUnauthorized)
        else:
            return

But when I am reacting to that message nothing happens(there is no anything in console as well).

Advertisement

Answer

I think you’re making a mistake while checking the emoji. Try replacing this:

if payload.emoji.name == 'white_check_mark':

with this:

if str(payload.emoji) == '✅':

Alternative to the emoji, you can use the Unicode u2705.

Note: You can also use payload.emoji.name instead of payload.emoji. It’ll still work.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement