I have subfolders for each of my commands and I'm wondering how I would check the name of the command's folder without having to add code into the command file itself. I've tried folders.filter(folder => folder.includes(command) and I'm hoping there's a similar way that could help me.
const folders = fs.readdirSync(`./categories`);
for (const folder of folders) {
const files = fs.readdirSync(`./categories/${folder}`);
for (const file of files) {
const command = require(`./categories/${folder}/${file}`);
client.commands.set(command.name, command);
};
};
client.on("message", async message => {
if (command.args && !args.length) {
const commandArgs = new Discord.MessageEmbed()
.setAuthor(command.category) // HERE - how would i check what subfolder the given command is in?
.setTitle(command.name)
.setDescription(command.description);
}
//code...
});