Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

130
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda