Reputation: 375
I am developing a little reaction roles bot in discord.py - for this I am trying to use the .wait_for() function with the "reaction_add" parameter. The problem is that I need to get the emoji from the reaction, which is not working as an error is shown:
AttributeError: 'tuple' object has no attribute 'user'
Seemingly there is something wrong with the way I am trying to get the emoji, but I couldn't find the proper way to get the emoji.
interaction = await client.wait_for('reaction_add')
if interaction.emoji == "🚨":
await interaction.user.add_roles(role)
Upvotes: 3
Views: 169
Reputation: 504
emoji = "🚨"
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add")
if user != bot.user:
if reaction.emoji == emoji:
await user.add_roles(user, role)
or
emoji = "🚨"
def check(reaction, user):
return user == ctx.message.author and reaction.emoji == emoji
message = await ctx.send("Test")
await message.add_reaction(emoji)
reaction, user = await bot.wait_for("reaction_add", check=check)
await bot.add_roles(user, role)
Upvotes: 1