Facebook
From Unique Crow, 4 Years ago, written in Plain Text.
This paste is a reply to Untitled from Perl Matamata - go back
Embed
Viewing differences between Untitled and Re: Untitled
buy.js loaded!
/home/container/index.js:20
const config = require('./config.json')
const Discord = require("discord.js");
const fs = require("fs");
const bot = new Discord.Client({disableEveryone: true});
bot.commands = new Discord.Collection();

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("Couldn't find commands.");
    return;
  }

  jsfile.forEach((f, i) =>{
    let props = require(`./commands/${f}`);
    console.log(`${f} loaded!`);
    bot.
commands.set(props.help.name, props);
TypeError: Cannot read property 'name' of undefined
at jsfile.forEach (/home/container/index.js:20:33)
at Array.forEach ()
at fs.readdir (/home/container/index.js:17:10)
at FSReqWrap.oncomplete (fs.js:141:20)
  });

});






bot.on("ready", async () => {
  console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
    setInterval(function() {
      request.get(serverQuery)
          .then(res => {
            let Statuses = [`c!help | Bot by Stainlqss | ステンレス#2322`, `Hosted By NitroSRV.us`]
            let status = Statuses[Math.floor(Math.random()*Statuses.length)];
              bot.user.setActivity(status, {
                  type: 'PLAYING'
              })
          });
  }, 1000);
    



  
 
});

bot.on("message", async message => {
  if(message.author.bot) return;
  if(message.channel.type === "dm") return;

  let prefix = config.prefix;
  let messageArray = message.content.split(" ");
  let cmd = messageArray[0];
  let args = messageArray.slice(1);

  let commandfile = bot.commands.get(cmd.slice(prefix.length));
  if(commandfile) commandfile.run(bot,message,args);


});

                                                                                            
bot.on('guildMemberAdd', async member => {
    if (member.user.bot) return;


});


bot.login(config.token);