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

239
Views
Discord.js | I'm trying to check if a role has a specific permission for a mute role

Basically I'm making a ultra customizable discord bot, and you have to specify in the config file the name of the role you want to use when you mute someone. And as a fail-safe in case the role is invalid or misspelled the bot looks himself for a role that has the permission "SEND_MESSAGE" turned off.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Look in the guild's RoleManager for a role that does not have the permission by using .find(). This will return the first role that does not have 'SEND_MESSAGES'

const role = message.guild.roles.cache
   .find(r => !r.permissions.has('SEND_MESSAGES'));

role will return undefined if a role without 'SEND_PERMISSIONS' was not found.

If you want to increase accuracy of finding a muted role given that the name is misspelled check what the name of the role starts with.

// Account for spelling mistakes, given that "mu" in "muted" is correct
const role = message.guild.roles.cache
   .find(r => !r.permissions.has('SEND_MESSAGES') && r.name.toLowerCase().startsWith('mu'));
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!