Hello. I have a problem with a .name
in my bot’s command handler code.
Error:
TypeError: Cannot read property 'name' of undefined
My code of a command handler:
fs.readdir("./commands/", (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Nie można znaleźć komend.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`Komenda ${f} została załadowana!`);
bot.commands.set(props.help.name, props); //props.help.name
});
});