Skip to content

.users.cache.size not working with Discord.js bot

I have a problem with just a bit of my code:


It was working perfectly before but one day it begins to give me random numbers instead of the number of users the bot.

So I would like to fix this but I didn’t find how.


Try this, it is working:

if (message.content === prefix + 'servers'){

let serverlist = ''
let count = 0; //<---
client.guilds.cache.forEach((guild) => {
    count += guild.memberCount // <---

})"Member Count = " + count);