Wednesday, 17 May 2017

Discord.js getting all members and tag them seperately

Hello I'm trying to tag everyone individually in discord but I keep getting the following error:

TypeError: Cannot read property 'members' of undefined

I've been struggling to figure out what is causing this.

Here is my code.

var Discord = require("discord.js")
var client = new Discord.Client()

client.on = function (client, msg) {
let everyone = msg.guild.members.map(m => `${m.user} ${(m.user.bot ? '**`[BOT]`**' : '')}`).sort();
let message = []
while (everyone.length > 50) {
        messages.push(everyone.splice(0, 50));
    }
    messages.push(everyone);

    client.on = function (msg) {
      if (msg.content === "$everyone") {
        msg.edit("Loading..");
        Promise.all(
          messages.map(group => msg.channel.sendEmbed(
            bot.utils.embed('', group.join('\n'), [], { footer: false })
          ))
        ).then(subMsgs => {
          msg.delete();
          subMsgs.forEach(m => m.delete(30000));
        }).catch(msg.error);
      };
    }
  }

client.login("token")



via fragile

No comments:

Post a Comment