Description
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:
import { Client, Partials } from 'discord.js';
const bot = new Client({
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') {
await handlePresenceUpdateRaw();
}
});
@ApmMonitor('handlePresenceUpdate', 0.01) // only 1% of calls is recorded via APM
function handlePresenceUpdate() {
}
@ApmMonitor('handlePresenceUpdateRawViaDiscordJS', 0.01) // only 1% of calls is recorded via APM
function handlePresenceUpdateRaw() {
}
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?
Code sample
Versions
- Node.js v20.17.0
- discord.js 14.15.3
- os Alpine Linux v3.20
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