Reputation: 21
guys I'm working on a reaction role discord bot but whenever I set a reaction my bot gets the role too How can I prevent that? I don't want my bot to get every role
this is my code rn.
@client.event
async def on_raw_reaction_add(payload):
for role_id, msg_id, emoji in client.reaction_roles:
if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode("utf-8")):
await payload.member.add_roles(client.get_guild(payload.guild_id).get_role(role_id))
edit: so I added an if statement to my code but apparently it's wrong. so can you tell how it's working??
@client.event
async def on_raw_reaction_add(payload):
for role_id, msg_id, emoji in client.reaction_roles:
if msg_id == payload.message_id and emoji == str(payload.emoji.name.encode("utf-8")):
if payload.member== client.user:
return
else:
await payload.member.add_roles(client.get_guild(payload.guild_id).get_role(role_id))
Upvotes: 2
Views: 52
Reputation: 2658
Simple, ignore the case where the reaction adder is your bot!
@client.event
async def on_raw_reaction_add(payload):
if payload.user_id = client.user.id:
return
#other stuff here
Upvotes: 1