Hi I'm trying to load files within different folders for example
-- Main directory
-- bot folder
- index.js
- package.json
- package-lock.json
-- commands
-- fun
- kick.js
- ban.js
-- some other category
However in my code I'm only seem to be able to load the .js files in the Commands folder rather than the sub folders.
Here is the code I'm working with:
const commandFiles = fs.readdirSync("../main/Commands")
.filter(file => file.endsWith(".js"));
const commands = commandFiles.map(file => require(`../Commands/${file}`));
commands.forEach(cmd => {
console.log(`Command ${cmd.name} loaded`);
this.commands.set(cmd.name, cmd);
});
Help appreciated.