summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <maddyunderstars@gmail.com>2025-04-12 22:12:53 +1000
committerGitHub <noreply@github.com>2025-04-12 22:12:53 +1000
commit3ccf33950f1aa8615361fc8d0a7c92edbf301460 (patch)
tree5f168d9eafd9c9a5753395a66bde1baf31fa9212 /src
parentMerge pull request #1273 from dank074/patch/fix-members-list (diff)
parentrevert back to original schema, but add missing `members` (diff)
downloadserver-ts-3ccf33950f1aa8615361fc8d0a7c92edbf301460.tar.xz
Merge pull request #1269 from dank074/patch/fix-missing-guildcreate-properties
Diffstat (limited to 'src')
-rw-r--r--src/gateway/opcodes/Identify.ts27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts

index c6f987fc7..4f1c7e2d0 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -32,6 +32,7 @@ import { DefaultUserGuildSettings, EVENTEnum, Guild, + GuildCreateEvent, GuildOrUnavailable, IdentifySchema, Intents, @@ -455,17 +456,33 @@ 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: x, + d: { + ...x.toJSON(), + members: botMemberObject + ? [ + { + ...botMemberObject.toPublicMember(), + user: user.toPublicUser(), + }, + ] + : [], + }, })?.catch((e) => console.error(`[Gateway] error when sending bot guilds`, e), - ), - ), + ); + }), ); // TODO: ready supplemental