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

244
Views
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 answers
Answer question

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 Report

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