You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using client.shard.broadcastEval() to get user and server totals for all shards. (from the code below), but the client.shard.broadcastEval() value is unstable at times and is not returning accurate results.
From my research, this bug is more likely to occur the longer it has been since the BOT was launched.
This bug prevents accurate measurement of statistics
My BOT has 3 shards up and running. This was occurring even with two shards.
Code sample
(awaitclient.shard.broadcastEval(c=>c.guilds.cache.size)).reduce((a,c)=>a+c,0);// returning value is [null,1200,1001]// For some reason, a null value comes in.(awaitclient.shard.broadcastEval(c=>c.guilds.cache.reduce((a,g)=>a+g.memberCount,0))).reduce((a,c)=>a+c,0);// Same here.
Versions
discord.js 14.14.1
Node.js 18.16.0
Ubuntu Server 22.04.4
This sounds like you might have an unavailable Guild on your first shard. So there is a Guild in your <Client>.guilds.cache with available: false property causing its memberCount property to be undefined. Your reduce call then causes the whole sum to become NaN which gets JSONified into null and sent back over the IPC channel to where you call the broadcastEval.
So not a bug in discord.js itself but in your handling of unavailable Guilds. filter the guilds.cache before the reduce calls and you should be good.
This sounds like you might have an unavailable Guild on your first shard. So there is a Guild in your <Client>.guilds.cache with available: false property causing its memberCount property to be undefined. Your reduce call then causes the whole sum to become NaN which gets JSONified into null and sent back over the IPC channel to where you call the broadcastEval. So not a bug in discord.js itself but in your handling of unavailable Guilds. filter the guilds.cache before the reduce calls and you should be good.
I understand the fix about counting users. Also, all guild counts are a little higher than the actual number of guilds when there are unavailable guilds.
(awaitclient.shard.broadcastEval(c=>c.guilds.cache.size)).reduce((a,c)=>a+c,0);// The number of all guilds is 3100, but when some guilds are not available, the value is 3109, etc.
Which package is this bug report for?
discord.js
Issue description
I am using client.shard.broadcastEval() to get user and server totals for all shards. (from the code below), but the client.shard.broadcastEval() value is unstable at times and is not returning accurate results.
From my research, this bug is more likely to occur the longer it has been since the BOT was launched.
This bug prevents accurate measurement of statistics
My BOT has 3 shards up and running. This was occurring even with two shards.
Code sample
Versions
discord.js 14.14.1
Node.js 18.16.0
Ubuntu Server 22.04.4
Issue priority
High (immediate attention needed)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildPresences, GuildMessages, MessageContent
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: