Discord.JS Command Handler Sub Folders

Viewed 42

Hello how can i add here sub folder? so that each new folder with its files will be detected

Config file: commandsDir: "./commands",

client.commands = [];
fs.readdir(config.commandsDir, (err, files) => {
  if (err) throw err;
  files.forEach(async (f) => {
    try {
      let props = require(`${config.commandsDir}/${f}`);
      client.commands.push({
        name: props.name,
        description: props.description,
        options: props.options,
      });
      console.log(`Loaded command: ${props.name}`);
    } catch (err) {
      console.log(err);
    }
  });
});
0 Answers
Related