I’ve been trying to make it so the bot removes the reaction using discord.Message.remove_reaction()
, but I can’t find a way to actually retrieve and store the message in a variable. Does anybody know how to do this?
Here is the code I have so far:
JavaScript
x
8
1
@client.event
2
async def on_raw_reaction_add(self):
3
if self.message_id == 805179023641542726:
4
channel = client.get_channel(self.channel_id)
5
message = ???
6
user = client.get_user(self.user_id)
7
await message.remove_reaction(self.emoji,user)
8
Advertisement
Answer
on_raw_reaction_add
returns a RawReactionActionEvent
which has a message_id
attribute. You can pass it to discord.abc.Messageable.fetch_message
to retreive the message :
JavaScript
1
7
1
@client.event
2
async def on_raw_reaction_add(payload):
3
channel = client.get_channel(payload.channel_id)
4
message = await channel.fetch_message(payload.message_id)
5
user = client.get_user(payload.user_id)
6
await message.remove_reaction(payload.emoji,user)
7
Reference : discord.py
documentation