Home > Software engineering >  Members Cache only has me and a bot in it even though I have server members intents
Members Cache only has me and a bot in it even though I have server members intents

Time:10-23

So I'm making a server info command which needs a member list. I used guild.members.cache.map.lengh but it only returned 2. I tried to trouble shoot it with looking at the collection itself but I only saw myself and the bot. I searched for the issue and found one but the writer just said "its just intents problem" so I turned the member intent on and added GUILD_MEMBERS to my intents but still doesn't work. Can someone tell me how to fix it?

CodePudding user response:

Cache is unreliable. You can instead fetch the members from the API

const members = await guild.members.fetch()
console.log(members.size) //should output correct result
  • Related