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

182
Vistas
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 Respuestas
Responde la pregunta

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