Recently, I've been working on creating a unique member counter for my server. The goal is to accurately count the total number of members in the server, excluding bots, and counting only bots as well. However, when I attempt to display these counts in the general channel, the results are not accurate.
Here is the code snippet I am using:
const memberCount = message.guild.members.cache.filter(member => !member.user.bot).size;
const totalCount = message.guild.memberCount;
const botCount = message.guild.members.cache.filter(member => member.user.bot).size;
When testing this code on a server with 20 Members, here are the output numbers I receive:
1st Output: 1
2nd Output: 19 (Excludes itself somehow, but can be fixed by adding +1)
3rd Output: 1
It's clear that there is an issue with the accuracy of the counts, but I'm struggling to identify where the problem lies.