Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord.js Display Server User Count separately from Server Bot Member Count

I am trying to create a serverinfo command for my Discord.js Bot. I am trying to get the Discord Server User Count separate from the Server's Bot Count. I have been told to use the .filter but I don't understand how to filter the bot count from the user count.

like image 425
Zachary Murphy Avatar asked Jan 02 '23 13:01

Zachary Murphy


1 Answers

Well from guild.members.cache you'll get a Collection with all the members (users and bots). With .filter you can "exclude" items of a collection if they don't match something. For example:

guild.members.cache.filter(member => !member.user.bot).size;

Should return the number of members that aren't bots on guild.

like image 109
André Avatar answered May 17 '23 09:05

André