add ophandler for GuildSubscriptionsBulk message
This commit is contained in:
parent
126a881f31
commit
0ed7a8af77
28200
assets/schemas.json
28200
assets/schemas.json
File diff suppressed because it is too large
Load Diff
24
src/gateway/opcodes/GuildSubscriptionsBulk.ts
Normal file
24
src/gateway/opcodes/GuildSubscriptionsBulk.ts
Normal file
@ -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],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ import { onPresenceUpdate } from "./PresenceUpdate";
|
|||||||
import { onRequestGuildMembers } from "./RequestGuildMembers";
|
import { onRequestGuildMembers } from "./RequestGuildMembers";
|
||||||
import { onResume } from "./Resume";
|
import { onResume } from "./Resume";
|
||||||
import { onVoiceStateUpdate } from "./VoiceStateUpdate";
|
import { onVoiceStateUpdate } from "./VoiceStateUpdate";
|
||||||
|
import { onGuildSubscriptionsBulk } from "./GuildSubscriptionsBulk";
|
||||||
|
|
||||||
export type OPCodeHandler = (this: WebSocket, data: Payload) => unknown;
|
export type OPCodeHandler = (this: WebSocket, data: Payload) => unknown;
|
||||||
|
|
||||||
@ -40,4 +41,5 @@ export default {
|
|||||||
// 10: Hello
|
// 10: Hello
|
||||||
// 13: Dm_update
|
// 13: Dm_update
|
||||||
14: onLazyRequest,
|
14: onLazyRequest,
|
||||||
|
37: onGuildSubscriptionsBulk,
|
||||||
} as { [key: number]: OPCodeHandler };
|
} as { [key: number]: OPCodeHandler };
|
||||||
|
11
src/util/schemas/GuildSubscriptionsBulkSchema.ts
Normal file
11
src/util/schemas/GuildSubscriptionsBulkSchema.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { LazyRequestSchema } from "./LazyRequestSchema";
|
||||||
|
|
||||||
|
export interface GuildSubscriptionsBulkSchema {
|
||||||
|
subscriptions: { [key: string]: GuildSubscriptionSchema };
|
||||||
|
}
|
||||||
|
|
||||||
|
export type GuildSubscriptionSchema = Omit<LazyRequestSchema, "guild_id">;
|
||||||
|
|
||||||
|
export const GuildSubscriptionsBulkSchema = {
|
||||||
|
$subscriptions: Object,
|
||||||
|
};
|
@ -30,6 +30,7 @@ export interface LazyRequestSchema {
|
|||||||
threads?: boolean;
|
threads?: boolean;
|
||||||
typing?: true;
|
typing?: true;
|
||||||
members?: string[];
|
members?: string[];
|
||||||
|
member_updates?: boolean;
|
||||||
thread_member_lists?: unknown[];
|
thread_member_lists?: unknown[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,5 +41,6 @@ export const LazyRequestSchema = {
|
|||||||
$typing: Boolean,
|
$typing: Boolean,
|
||||||
$threads: Boolean,
|
$threads: Boolean,
|
||||||
$members: [] as string[],
|
$members: [] as string[],
|
||||||
|
$member_updates: Boolean,
|
||||||
$thread_member_lists: [] as unknown[],
|
$thread_member_lists: [] as unknown[],
|
||||||
};
|
};
|
||||||
|
@ -41,6 +41,7 @@ export * from "./EmojiModifySchema";
|
|||||||
export * from "./ForgotPasswordSchema";
|
export * from "./ForgotPasswordSchema";
|
||||||
export * from "./GatewayPayloadSchema";
|
export * from "./GatewayPayloadSchema";
|
||||||
export * from "./GuildCreateSchema";
|
export * from "./GuildCreateSchema";
|
||||||
|
export * from "./GuildSubscriptionsBulkSchema";
|
||||||
export * from "./GuildTemplateCreateSchema";
|
export * from "./GuildTemplateCreateSchema";
|
||||||
export * from "./GuildUpdateSchema";
|
export * from "./GuildUpdateSchema";
|
||||||
export * from "./GuildUpdateWelcomeScreenSchema";
|
export * from "./GuildUpdateWelcomeScreenSchema";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user