Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda