How would I go about doing this?
I am attempting to figure out how to search subdirectories of ./commands, check all folders under it, for a file, and return the path to the file.
//here is where I wish the code to be.
const categories = fs.readdirSync('./commands');
let commandFiles = [];
let commands = [];
for (let folder of categories) {
let files = null;
files = fs.readdirSync(`./commands/${folder}`).filter(
file => file.endsWith('.js')
);
const newArray = commandFiles.concat(files)
commandFiles = newArray
};
if (commandFiles) {
for (let file of commandFiles) {
commands.push(file)
}
}
if (commands) {
for (let name of commands) {
// here
config.commands.set(name, file)
log.info(`[Commands] Loaded.. ${name} ✌️`)
}
} else {
log.info('[Commands] No commands have been found.')
}