Retrieving a message from on_raw_reaction_add

Tags: ,

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:

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)


on_raw_reaction_add returns a RawReactionActionEvent which has a message_id attribute. You can pass it to to retreive the message :

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 : documentation

Source: stackoverflow