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

219
Views
How to detect how many pings are in a message DISCORD JS?

How can I detect how many pings are in a message? I'm not sure where to start. I'm trying to create a anti-raid bot and I want to detect if someone pings 5 people in one message

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

MessageMentions#user returns a discord.js collection, you can get the length of the collection by simply using message.mentions.users.size, this works with any mentions like

  • .roles
  • .members
  • .channels

and you can just detect using

if(message.mentions.members.size > n) {
  message.delete();
}
about 4 years ago · Santiago Trujillo Report

0

Simple code that counts unique user mentions in the message.

let count = 0;
for(const user of msg.mentions.users) {
    count++;
}
if(count>4) {
    msg.delete();
}
about 4 years ago · Santiago Trujillo Report

0

You can see how many people were pinged using message.mentions.users Like the following:

Array.from(message.mentions.users).length

It may be 1 over what you need, because Javascript strings start at 0. If so, just add a -1.

Array.from(message.mentions.users).length-1

And please, search this stuff up. I was able to find this on the Discord.js documentation in a matter of seconds.

about 4 years ago · Santiago Trujillo 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!