Problem with .name in command handler

Hello. I have a problem with a .name in my bot’s command handler code.


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.");

jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`Komenda ${f} została załadowana!`);
bot.commands.set(, props); //

1 Like

Every file in commands must have the following: = {
    name: 'filenameOrWhatever'
1 Like

please help me. IT’S STILL NOT WORKING!!!

Hello @PoProstuBartek, welcome to the Glitch Forums!

Can you post the contents of the command js file that seems to be causing the issue, if you know which one it is? Or give us your project name so we can take a look?

Oh wait… I didn’t coded my commands files. Sorry! It’s propably going to work after filling ALL commands files. :sweat_smile:

1 Like