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

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

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 Denunciar

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 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