summary refs log tree commit diff
path: root/src/gateway
diff options
context:
space:
mode:
authordank074 <torresefrain10@gmail.com>2025-04-12 05:01:37 -0500
committerdank074 <torresefrain10@gmail.com>2025-04-12 05:01:37 -0500
commit0ed7a8af77f2e4a2733cef2e61250e1fae032b8d (patch)
tree2ea6aad214e44978ebe46d94f4fee56405cde5a4 /src/gateway
parentPrettier (diff)
downloadserver-ts-0ed7a8af77f2e4a2733cef2e61250e1fae032b8d.tar.xz
add ophandler for GuildSubscriptionsBulk message
Diffstat (limited to 'src/gateway')
-rw-r--r--src/gateway/opcodes/GuildSubscriptionsBulk.ts24
-rw-r--r--src/gateway/opcodes/index.ts2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/gateway/opcodes/GuildSubscriptionsBulk.ts b/src/gateway/opcodes/GuildSubscriptionsBulk.ts
new file mode 100644

index 000000000..f0a431c8a --- /dev/null +++ b/src/gateway/opcodes/GuildSubscriptionsBulk.ts
@@ -0,0 +1,24 @@ +import { WebSocket, Payload } from "@spacebar/gateway"; +import { onLazyRequest } from "./LazyRequest"; +import { GuildSubscriptionsBulkSchema } from "@spacebar/util"; +import { check } from "./instanceOf"; + +export async function onGuildSubscriptionsBulk( + this: WebSocket, + payload: Payload, +) { + check.call(this, GuildSubscriptionsBulkSchema, payload.d); + const body = payload.d as GuildSubscriptionsBulkSchema; + + let guildId: keyof GuildSubscriptionsBulkSchema["subscriptions"]; + + for (guildId in body.subscriptions) { + await onLazyRequest.call(this, { + ...payload, + d: { + guild_id: guildId, + ...body.subscriptions[guildId], + }, + }); + } +} diff --git a/src/gateway/opcodes/index.ts b/src/gateway/opcodes/index.ts
index cf2338e64..e925134d8 100644 --- a/src/gateway/opcodes/index.ts +++ b/src/gateway/opcodes/index.ts
@@ -24,6 +24,7 @@ import { onPresenceUpdate } from "./PresenceUpdate"; import { onRequestGuildMembers } from "./RequestGuildMembers"; import { onResume } from "./Resume"; import { onVoiceStateUpdate } from "./VoiceStateUpdate"; +import { onGuildSubscriptionsBulk } from "./GuildSubscriptionsBulk"; export type OPCodeHandler = (this: WebSocket, data: Payload) => unknown; @@ -40,4 +41,5 @@ export default { // 10: Hello // 13: Dm_update 14: onLazyRequest, + 37: onGuildSubscriptionsBulk, } as { [key: number]: OPCodeHandler };