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

243
Vistas
How do i mention two roles in discord.js v13
const role = message.guild.roles.cache.find(role => role.name === ['Muted' || 'muted'])

The code above is for a mute (and unmute) command. Normally servers have the M capital or small which affects the role in the coding. With the code above it returns an error saying Unknown code

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

0

For starters, let's look at what your code is actually doing.

const role = message.guild.roles.cache.find(role => role.name === ['Muted' || 'muted'])

This code is equivalent to

const role = message.guild.roles.cache.find(role => role.name === ['Muted'])

because "string" || "otherString" evaluates to "string". Note that this comparison will always fail, because different arrays can't be compared using the === operator.

["muted"] === ["muted"] // this is false

If you want to do checks against arrays you'll need to implement some iterative logic yourself or use one of the useful helpers like Array#some and Array#includes.

The correct way to do a case-insensetive comparison would probably be something like

const role = 
  message.guild.roles.cache.find(role => role.name.toLowerCase() === "muted")

If you really only want to support Muted or muted (and not mUtEd for example), your method can work with a small tweak.

const role 
  = message.guild.roles.cache.find(role => ["muted","Muted"].includes(role.name))
//                                         ^ anonymous array of acceptable values 
about 4 years ago · Juan Pablo Isaza Denunciar

0

Lowercase the role name and compare it to a lowercase string

const role = message.guild.roles.cache
   .find(role => role.name.toLowerCase() == 'muted');

If you ever do need to check a string array for possible role names use Array#includes()

const role = message.guild.roles.cache
   .find(role => ['foo', 'bar', 'baz'].includes(role.name));
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