Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I want to set when someone mention me bot will respond

I’m trying to make my discord.js bot send messages when someone pings me. How can I do that??

I was trying with that code:

if(message.content === "<@723821826291138611>") {
message.channel.send("Hello, sup? ")
}

but that doesn’t work. how can I do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You have to use if(message.content.includes("<@723821826291138611>")) instead of if(message.content === "<@723821826291138611>") to make it work!

But also you can use this code to do it:

let mentioned = message.mentions.members.first();
if(mentioned && mentioned.id == "723821826291138611") {
message.channel.send("YOUR_TEXT")
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading