Code:
client.commands = new Discord.Collection();
const cooldowns = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name.toLowerCase(), command);//Errors at command.name.toLowerCase()
}
Research:
Command is a file and command.name is it’s name in string
Help With:
I just want to convert The string (command.name.toLowerCase()) but it sends an error i have also tried in VScode but it sends error there also error is same
Error:
TypeError: Cannot read property ‘toLowerCase’ of undefined