I’ve been working for a while on making commands for my discord.js bot, but now I am starting to categorize them. My commands are currently being put into a collector for a new discord collection (named client.{commandType}commands). I want to make “{commandType}” to be changed out for the value “i” in the following code. Anyone know how to do this?
folder.forEach(i => {
fs.readdir(`/home/runner/commands/${i}`, (err, file) => {
if (err) console.log(err);
let jsfile = file.filter(f => f.split(`.`).pop() === `js`);
jsfile.forEach((f,e) => {
let props = require(`/home/runner/commands/${i}/${f}`);
client.commandPermissions.set(props.help.name, props.help.permissionLevel);
console.log(`${props.help.name}: ${props.help.permissionLevel}`);
client.{commandType}command.set(props.help.name, props);
^^^^^^^^^^^^^
});
});
});
So how do I fix that?
Edit: Just so I am clear, I am essentially trying to do this: client. + i + commands.set(props.help.name, props);