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

202
Visualizações
how to check if a message has a ping in it discord.js

I know you can use:

client.on('messageCreate', msg => {
    if(msg.content.includes("<@") && msg.content.includes(">")){
        //some code
    }
})

but this method isn't really the best. Is there a better way to check for pings in a discord message?

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

0

If you want to check if there are any mentions in a message, you can just get the mentions in the message and check the size of them by using:

if (message.mentions.users.size !== 0) {}

You can then replace the .users with .channels to check if there were any mentioned channels and .roles to check if any role was mentioned

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use message.mentions.members.first() to get the first pinged user. So, using your example:

if(message.mentions.members.first()){
    //some code
}
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