Problem with counting members with catch
Can someone help me, cuz I have a problem with counting members. Generally, I am trying to count both bot count and non bots count but while the Guild.memberCount is equal 5, both the counts are equal 5(should be 4 bots and 1 person)
Code:
14 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by OPwhere are you logging these values
show the code you are running
In an embed
ok show me a picture of the embed
alright i was expecting something like that
you said both numbers were 5 but they aren't
are the other members offline?
if not then you are probably missing the guild members intent, that could be one issue, if you dont have it then only members that interact with your bot are going to be cached
There is two bots online, me online and two bots offline
okay
I believe I have the GuildMembers intent
it not caching the offline members is okay, discord doesn't send them. if you want a more accurate number you need to fetch all members from the guild before running this command
await guild.members.fetch()
should be enough to cache themstill, two bot members are offline
and it still shows one
are you counting your own bot as the one thats online
yup...
try doing this before doing the filtering
k
okay, it worked, thank you!