How would I get the message object of a message I replied to? E.g. Someone said "Hello, How are you!". And I replied to that message calling the .good
command, it would print the message (Hello, How are you!)'s message object. I've looked all over discord.py docs but haven't seen a thing mentioning something like this.
1
votes
1 Answers
2
votes
You can use the discord.Message.reference
attribute. In your question you'd do something like this:
@client.command()
async def good(ctx):
# If this message has a reference (meaning it's a reply)
if ctx.message.reference:
original = await ctx.fetch_message(id=ctx.message.reference.message_id)
text = original.content
print(f"Author said {text}")
This is the link to the docs: https://discordpy.readthedocs.io/en/stable/api.html#discord.Message.reference