1

I'm making a server info command and i want it to say how many humans and bots are in the server, here's the part of the embed that should do that:

{ name: 'Human members: ', value: message.guild.members.cache.filter(member => !member.user.bot).size, inline: true}, 
{ name: 'Bots members: ', value: message.guild.members.cache.filter(member => member.user.bot).size, inline: true},  
            

But this is what i get: enter image description here

I'm trying the command in a server with like 50 humans and 10 bots, i hope you can help

Tom The Italian BBQ
  • 173
  • 1
  • 1
  • 10
  • 1
    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 Jul 19 '21 at 10:50

1 Answers1

0

Try to fetch the members before you check the cache. members.fetch() will fetch members from Discord, even if they're offline. It returns a collection of GuildMember objects so you don't even need the cache property any more:

let members = await message.guild.members.fetch()

// ...
.addFields(
  { name: 'Human members: ', value: members.filter(member => !member.user.bot).size, inline: true}, 
  { name: 'Bots members: ', value: members.filter(member => member.user.bot).size, inline: true},  
)
Zsolt Meszaros
  • 15,542
  • 12
  • 36
  • 40