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