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
How do I use the Reply feature? To reply to a message directly, simply click on the Reply button when you hover over a message. You can also access the reply feature by clicking the three dots on the side of the message or by right-clicking the specific message.
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
@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.
More info: 1, 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With