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

351
Vistas
Discord.js: roles.some(r => !message.member.roles.cache.has(r)) doesn't work

So I am switching from single STAFF command (e.g. if(message.member.roles.cache.has(staff_id))) to more flexable method - if member has either helper or mod or admin role, etc. I used some method with array like this:

const roles = [
  "859471924753072188",
  "836214627243262002",
  "922170188089139261",
  "836214626923315221",
  "922170903394127873",
  "859878718599987200",
  "836214626617655296"
]
const isntStaff = roles.some(r => !message.member.roles.cache.has(r))

And now whenever I use this in some code, for example in this one:

...
if (
    rudeWords.some(word =>
      message
        .toString()
        .toLowerCase()
        .includes(word)
    ) &&
    isntStaff
  ) {
    message.delete({ reason: `Blacklisted Word Detected` });
    message.channel
      .send({ content: `${message.author}, do not use that word here, thank you.` })
      .then(msg => {
    setTimeout(() => msg.delete(), 3000)
  })

it just doesn't let me to use the word even if I have helper or mod or admin command. It also logs nothing in console.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

There is also another way to do this according to this Discord.js Guide.

This is an example of how you could do this:

// Check if they have one of many roles
const roles = [
  "859471924753072188",
  "836214627243262002",
  "922170188089139261",
  "836214626923315221",
  "922170903394127873",
  "859878718599987200",
  "836214626617655296"
]

if (message.member.roles.cache.some(r => roles.includes(r.id)) ) {
  // has one of the roles
}else {
  // has none of the roles
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your code requires every single one of those roles. You are checking if there are any roles in that array that aren't in the member's role cache. Instead, put the ! on the outside

const roles = [
  "859471924753072188",
  "836214627243262002",
  "922170188089139261",
  "836214626923315221",
  "922170903394127873",
  "859878718599987200",
  "836214626617655296"
]
const isntStaff = !roles.some(r => message.member.roles.cache.has(r))
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