How do I get the message that a person is responding to?

52 views Asked by At

I am coding a discord bot. When someone replies to a message with a specific command, the bot will create a poll to decide what to do with the replied-to message.

When the bot handles the command, how can it find the message (if any) that the command is replying to?

1

There are 1 answers

0
Evorp On

Assuming you already have the message with the command:

original_message = (await client
    .get_channel(message.reference.channel_id)
    .fetch_message(message.reference.message_id))

This will throw a discord.errors.NotFound error if the channel or message cannot be found.

https://discordpy.readthedocs.io/en/latest/api.html#discord.MessageReference