From fd33d58af83d9df9c37d345453cbb324f3b7a761 Mon Sep 17 00:00:00 2001 From: dank074 Date: Fri, 11 Apr 2025 18:39:45 -0500 Subject: [PATCH] revert back to original schema, but add missing `members` --- src/gateway/opcodes/Identify.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index 2798f3eb..4f1c7e2d 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -458,18 +458,31 @@ export async function onIdentify(this: WebSocket, data: Payload) { // If we're a bot user, send GUILD_CREATE for each unavailable guild // TODO: check if bot has permission to view some of these based on intents (i.e. GUILD_MEMBERS, GUILD_PRESENCES, GUILD_VOICE_STATES) await Promise.all( - pending_guilds.map((x) => - Send(this, { + pending_guilds.map((x) => { + //Even with the GUILD_MEMBERS intent, the bot always receives just itself as the guild members + const botMemberObject = members.find( + (member) => member.guild_id === x.id, + ); + + return Send(this, { op: OPCODES.Dispatch, t: EVENTEnum.GuildCreate, s: this.sequence++, d: { - ...new ReadyGuildDTO(x).toJSON(), - } as GuildCreateEvent["data"], + ...x.toJSON(), + members: botMemberObject + ? [ + { + ...botMemberObject.toPublicMember(), + user: user.toPublicUser(), + }, + ] + : [], + }, })?.catch((e) => console.error(`[Gateway] error when sending bot guilds`, e), - ), - ), + ); + }), ); // TODO: ready supplemental