Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Discord bot reacts when specific user is tagged

I'm new to programming and i'm trying to make a Discord bot for me and my friends, for now I have set up two commands, the first works fine, but the second one is the problem.

client.on('message', msg => {
  if (msg.content === `@usertag#0001`) {
    msg.channel.send(`<@${msg.author.id}> <@${msg.author.id}> <@${msg.author.id}> <@${msg.author.id}> don't tag me`);
  }
});

So what it should do is when a specific user is tagged it sends a message, the message sent from the bot is working (it tags the user who sent the message 3 times and then it says something else), but the part where the bot recognizes the tag doesn't work.

I tried by putting the Discord id, using the full @, and other stuff, but it doesn't seem to work.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For this you could use the message.mentions method, and here is how you could use it for example:

// For Discord V13 'message' is deprecated and
// will be removed in the future, use 'messageCreate' instead.
client.on("message", msg => {
    // Disable messages from bot to avoid endless loops / replies
    if(msg.author.bot === true) return;

    // Check if anyone is mentioned.
    // Skip @everyone mentions to be checked.
    if(msg.mentions.users.size > 0 && msg.mentions.everyone === false) {
        if(msg.mentions.users.find(user => user.id === "ENTER USER ID HERE")) {
            msg.channel.send(`<@${msg.author.id}> <@${msg.author.id}> <@${msg.author.id}> <@${msg.author.id}> don't tag me!`);
        }
    }
});

Hope this will help you! ! I have tested this with Discord V13, i'm not 100% sure if this will work on Discord V12 as well.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!