0

The Aim: The aim is to log all users of a server in the console

Issue: When I run the command, it only prints out two users in the console.

Code:

    if (cmd === "members") {
        console.log("Server: " + msg.guild.name)
        msg.guild.members.map(members => {
            console.log(green(members.user.username))
        })
    }

Console:

Server: lovell ���
brandon
felony .

Other Attempts: I tried using the forEach() function but the same result was shown.

Version of Discord.js: v11

Any help would be appreciated ;)

  • Does this answer your question? [None of my discord.js guildmember events are emitting, my user caches are basically empty, and my functions are timing out?](https://stackoverflow.com/questions/64559390/none-of-my-discord-js-guildmember-events-are-emitting-my-user-caches-are-basica) – Lioness100 Oct 30 '20 at 12:33
  • no unfortunately. :/ –  Oct 30 '20 at 12:35
  • Are you sure? It seems your problem is that your member caches are starting empty, which is one of the most common symptoms of not enabling privileged intents. – Lioness100 Oct 30 '20 at 12:40
  • Do you think this will work in js v11? It stated that privileged intents were introduced to v12 –  Oct 30 '20 at 14:14
  • You can still enable both of the privileged intents through the discord developer portal, which is all you'll need. If you want to modify your intents further, you'll need to update. – Lioness100 Oct 30 '20 at 14:18

2 Answers2

0
  • Try to use this

    message.guild.members.cache.forEach(m => console.log(m.user.username))

forEach should work

E3saR
  • 90
  • 9
0

It's probably because your bot needs Privileged Intents. You can set that for your bot in the Discord Developer Portal.

deb
  • 6,671
  • 2
  • 11
  • 27