Reply to a message discord.py
21,930
Solution 1
To any new user here, as of the 1.6.0 discord.py-rewrite update, you are now able to reply!
Every message or context now has a reply attribute. To reply, simply use
await ctx.reply('Hello!')
You can also not mention the author in the reply with mention_author=False
await ctx.reply('Hello!', mention_author=False)
You can also find a basic example Here
Solution 2
@bot.event
async def on_message(message):
if message.content == "hi":
await message.channel.send("hello", reference=message)
The main thing here is reference=message
. It is available since Discord.py 1.6.
![Legacy Coding](https://lh4.googleusercontent.com/-BGT2VgCDA8M/AAAAAAAAAAI/AAAAAAAAAAA/AMZuucm0VQMczEStDlSLJCKQds0egnuMjA/photo.jpg?sz=256)
Author by
Legacy Coding
Hi, Im a fairly new programmer, and I also stream to twitch https://twitch.tv/danhowe0
Updated on August 21, 2022Comments
-
Legacy Coding almost 2 years
I want to make my bot react to a users message when they type a certain sentence.
My code to reply:
await ctx.message.reply("I just replied to you")
I get the error:
ctx.message has no attribute "reply"
What code can I do to make the bot reply to the message?
When I say reply, I mean the same as a user can press reply on a message
-
Legacy Coding over 3 yearsNo i know that to send a message you can use that, but i want it to specifically reply to the message, like when you right click on a message and press reply
-
Legacy Coding over 3 yearsHi, when i say "reply" i mean reply as in a user would right click and press reply
-
Zeref over 3 yearsWhat version of discord.py do you use? The documentation says that it was added in version 1.6.
-
Zeref over 3 yearsI don't know if this has to do with me using PyCharm but according to it, the latest version of discord.py is 1.5.1, so maybe it's something that hasn't been implemented yet.
-
shellbyy over 3 yearsah I got you. I do apologize, but I'm not sure how one would go about doing that :( I will be following this though so that if someone has figured out a way, then I can learn something new too :)
-
Nicholas Chen about 3 yearsI got an error saying that
AttributeError: 'Context' object has no attribute 'reply'
, can someone help? -
Frederick Reynolds about 3 years@NicholasChen You need to update to discord.py 1.6
-
Nicholas Chen about 3 yearsThanks, I'll do that