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

131
Vistas
adding more folder for new code resulting error on command handler

So I have likes 6 folder on my bot commands, meanwhile I need to manually add "the folder name" into the command.js (so bot can run the command on those folders) but when I add more than 4 folder name in the code, it said "Cannot read properties of undefined (reading 'name'), meanwhile if it's only 4 or less it works fine, is there a way so the bot can run those folders without adding the name into handlers ?

here's my folder that I had currently : https://i.stack.imgur.com/KrO0J.png

here's the error after I add more than 4 folders on the handler : https://i.stack.imgur.com/XYClm.png

and here's the code I use for the command handler:

const { readdirSync } = require("fs")

module.exports = (bot) => {
    const load = dirs => {
        const commands = readdirSync(`./commands/${dirs}/`).filter(d => d.endsWith('.js'));
        for (let file of commands) {
            let pull = require(`../commands/${dirs}/${file}`);
            bot.commands.set(pull.config.name, pull);
            if (pull.config.aliases) pull.config.aliases.forEach(a => bot.aliases.set(a, pull.config.name));
          };
        };
        ["mod", "utility", "misc", "department"].forEach(x => load(x));
};

about 4 years ago · Juan Pablo Isaza
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