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

181
Views
How to add more then one names to a command?

If I add more then one property to "name" then it doesn't detect any.

This works:

module.exports = {
  name: "info",
  description: "Gives full details of a user.",
  async execute(...) {
    ...
  }
}

But if i try to add something like "whois" to "name":

module.exports = {
  name: ["info", "whois"],
  description: "Gives full details of a user.",
  async execute(...) {
    ...
  }
}

Then the command just stops working.

Here the code for my index.js:

const infoCommandModule = require(`./BotCommands/Info.js`);
if (msg.content.toLowerCase() === `${infoCommandModule.name}`) {
  infoCommandModule.execute(...)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's because when it's an array you can't compare it to a string. You can use Array#includes() though that checks if a given string is included in the array:

const infoCommandModule = require('./BotCommands/Info.js')

if (infoCommandModule.name.includes(msg.content.toLowerCase)) {
  infoCommandModule.execute(...)
}

Please note that you will need to use arrays for every name in your commands. If you want to accept arrays and strings too, you will need to check if name is an array. You can use Array.isArray(name) for that.

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!