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:
@client.event
async def on_raw_reaction_add(self):
if self.message_id == 805179023641542726:
channel = client.get_channel(self.channel_id)
message = ???
user = client.get_user(self.user_id)
await message.remove_reaction(self.emoji,user)
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 :
@client.event
async def on_raw_reaction_add(payload):
channel = client.get_channel(payload.channel_id)
message = await channel.fetch_message(payload.message_id)
user = client.get_user(payload.user_id)
await message.remove_reaction(payload.emoji,user)
Reference : discord.py documentation