I want bot to add role and remove another one for those who reacts on message.
JavaScript
x
12
12
1
@client.event
2
async def on_raw_reaction_add(payload):
3
rUnauthorized=payload.member.guild.get_role(672473730114387968)
4
rMember=payload.member.guild.get_role(672473925053055036)
5
if payload.message_id==679223445258633216:
6
if payload.emoji.name=='white_check_mark':
7
print('Sucess!')
8
await payload.member.add_roles(rMember)
9
await payload.member.remove_roles(rUnauthorized)
10
else:
11
return
12
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:
JavaScript
1
2
1
if payload.emoji.name == 'white_check_mark':
2
with this:
JavaScript
1
2
1
if str(payload.emoji) == '✅':
2
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.