Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda