Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!