Reputation: 114
I have an authorization system on my server. When member reacts to message, he's getting access to stuff like chats etc. I want bot to remove reaction left by member, so number of reactions on the message will always=1
@client.event
async def on_raw_reaction_add(payload):
message=payload.reaction.message
if payload.channel_id==804320454152028170:
if str(payload.emoji) == '✅':
await message.remove_reaction("✅", payload.member)
else:
return
When I am leaving reaction under the message, I am getting this error:
message=payload.reaction.message
AttributeError: 'RawReactionActionEvent' object has no attribute 'reaction'
Ignoring exception in on_message
Upvotes: 0
Views: 52
Reputation: 2289
Read your error message! Looking at the docs you can easily find out that payload
simply does not have such attribute.
To get a message from payload
you will need to do something like this
guild = client.get_guild(payload.guild_id)
channel = guild.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
Upvotes: 2