TypeError: Cannot read property 'filter' of undefined

Discussion in 'Javascript' started by LoyRixLegendary, Jun 10, 2019 at 5:51 PM.

  1. LoyRixLegendary

    LoyRixLegendary

    Joined:
    Monday
    Messages:
    1
    Likes Received:
    0
    I have a probleme in coding a discord bot ...

    TypeError: Can not read property 'filter' of undefined

    bot.command = new Discord.Collection ();
    fs.readdir ('./ comands /', (err, files) => { if (err) console.log (err);
    let jsFile = files.filter (f => f.split ("."). pop () === "js");
    if (jsFile.lenght <= 0) { console.log ("I can not find the command");
    return;
    }
    jsFile.forEach ((f, i) => { let props = require (`./commands / $ {f}`);
    bot.command.set (props.help.name, props);
    }); });
     
    LoyRixLegendary, Jun 10, 2019 at 5:51 PM
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.