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
Using discord.js we created a bot connected to server which has over 1.2M members.
In this server we try to listen to all presence updates:
import{Client,Partials}from'discord.js';constbot=newClient({intents: 257,partials: [Partials.Channel,Partials.GuildMember,Partials.GuildScheduledEvent,Partials.Message,Partials.Reaction,Partials.ThreadMember,Partials.User,],});bot.on('presenceUpdate',handlePresenceUpdate);bot.on('raw',async(event: {t: string;d: any})=>{if(event.t==='PRESENCE_UPDATE'){awaithandlePresenceUpdateRaw();}});
@ApmMonitor('handlePresenceUpdate',0.01)// only 1% of calls is recorded via APMfunctionhandlePresenceUpdate(){}
@ApmMonitor('handlePresenceUpdateRawViaDiscordJS',0.01)// only 1% of calls is recorded via APMfunctionhandlePresenceUpdateRaw(){}
It looks like discord.js does not emit all presenceUpdate events at the beginning, even when all partials are turned on because when we start/restart the service, the amount of handlePresenceUpdateRawViaDiscordJS calls is much higher than handlePresenceUpdate calls.
For comparison see handlePresenceUpdateRawViaDiscordJS calls before/after restart:
And handlePresenceUpdate calls during the same period:
Is it possible that discord.js tries to cache some additional resource first before it emits presenceUpdate event?
the raw gateway event PRESENCE_UPDATE emits when either the presence or the user itself is updated. Discord.js separates those two into emitting presenceUpdate only for actual changes in presence, userUpdate if the user changed but presence remained as is
Since on login all presences for online members are sent in the initial GUILD_CREATE payload which discord.js waits for before emitting READY (and before emitting other events) the presences would already be in cache to be compared against.
So it would be helpful if you were able to get information about the payload contained in the raw events that don’t emit the djs event to find out if this is intended behavior or an actual bug
Which package is this bug report for?
discord.js
Issue description
Hello and thank you for this project.
Using discord.js we created a bot connected to server which has over 1.2M members.
In this server we try to listen to all presence updates:
It looks like discord.js does not emit all
presenceUpdate
events at the beginning, even when all partials are turned on because when we start/restart the service, the amount ofhandlePresenceUpdateRawViaDiscordJS
calls is much higher thanhandlePresenceUpdate
calls.For comparison see

handlePresenceUpdateRawViaDiscordJS
calls before/after restart:And

handlePresenceUpdate
calls during the same period:Is it possible that discord.js tries to cache some additional resource first before it emits
presenceUpdate
event?Code sample
Versions
Issue priority
Medium (should be fixed soon)
Which partials do you have configured?
User, Channel, GuildMember, Message, Reaction, GuildScheduledEvent, ThreadMember
Which gateway intents are you subscribing to?
GuildPresences
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: