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

240
Visualizações
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 Respostas
Responde à pergunta

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