0
votes

I'm trying to get a bot to print the text of a discord message that a user has reacted to. This is what I have so far:

@bot.event
async def on_raw_reaction_add(payload):
    print(payload)
    channel = bot.get_channel(payload.channel_id)
    await channel.fetch_message(payload.message_id)
    print("message text here")

Weirdly the object await channel.fetch_message(id) sgives doesn't seem to include the text of the message.

1
You didn't define the id in the fetch_message(id).Nurqm
I've now fixed that!Abijah

1 Answers

0
votes

You must assign fetched message to a variable. For example message = await channel.fetch_message(payload.message_id). Then you can get it's content with message.content.

@bot.event
async def on_raw_reaction_add(payload):
    print(payload)
    channel = bot.get_channel(payload.channel_id)
    message = await channel.fetch_message(payload.message_id)
    print(message.content)