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

259
Visualizações
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?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The best - and most conventional - way to do this is to check the MessageMentions#(users|members) collection.

const { 
   mentions:{ 
      users,
      repliedUser
   }
} = message;

if (users.has("723821826291138611") && !repliedUser) {
   // Your code
}

This will return true if the mentioned is found in any order not only first, it's possible for the API to emit the mentions in different orders if multiple mentions were given. I wouldn't recommend searching the message.content string either.

about 4 years ago · Juan Pablo Isaza Relatório

0

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") {
if(message.mentions.repliedUser) return;
message.channel.send("YOUR_TEXT")
}
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