From 25a76bf661de7fa2da9130b9cefb48fbb760050b Mon Sep 17 00:00:00 2001 From: Christopher Lentocha Date: Tue, 27 Feb 2024 20:53:57 -0500 Subject: [PATCH] 1760002018-v2.0.4 --- src/api/routes/users/@me/settings.ts | 4 ++-- src/gateway/opcodes/LazyRequest.ts | 2 +- src/util/dtos/ReadyGuildDTO.ts | 26 ++++++++++++++++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/api/routes/users/@me/settings.ts b/src/api/routes/users/@me/settings.ts index cfcedec17..b15d42c2f 100644 --- a/src/api/routes/users/@me/settings.ts +++ b/src/api/routes/users/@me/settings.ts @@ -42,9 +42,9 @@ router.patch( relations: ["settings"], }); - user.settings.assign(body); + user.settings?.assign(body); - await user.settings.save(); + await user.settings?.save(); res.json({ ...user.settings, index: undefined }); }, diff --git a/src/gateway/opcodes/LazyRequest.ts b/src/gateway/opcodes/LazyRequest.ts index b7fff4d1a..6ee0ad59c 100644 --- a/src/gateway/opcodes/LazyRequest.ts +++ b/src/gateway/opcodes/LazyRequest.ts @@ -254,7 +254,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) { if (!channels) return; } - if (!channels) throw new Error("Must provide channel ranges"); + if (!channels) return; const channel_id = Object.keys(channels || {}).first(); if (!channel_id) return; diff --git a/src/util/dtos/ReadyGuildDTO.ts b/src/util/dtos/ReadyGuildDTO.ts index 97e6931fa..2855b3d67 100644 --- a/src/util/dtos/ReadyGuildDTO.ts +++ b/src/util/dtos/ReadyGuildDTO.ts @@ -16,7 +16,15 @@ along with this program. If not, see . */ -import { Channel, Emoji, Guild, Member, Role, Sticker } from "../entities"; +import { + Channel, + Emoji, + Guild, + Member, + Role, + Sticker, + VoiceState, +} from "../entities"; export interface IReadyGuildDTO { application_command_counts?: { 1: number; 2: number; 3: number }; // ???????????? @@ -30,6 +38,7 @@ export interface IReadyGuildDTO { member_count: number | undefined; members: Member[]; premium_subscription_count: number | undefined; + presences: unknown[]; properties: { name: string; description?: string | null; @@ -63,6 +72,7 @@ export interface IReadyGuildDTO { stage_instances: unknown[]; stickers: Sticker[]; threads: unknown[]; + voice_states: VoiceState[]; version: string; } @@ -78,6 +88,7 @@ export class ReadyGuildDTO implements IReadyGuildDTO { member_count: number | undefined; members: Member[]; premium_subscription_count: number | undefined; + presences: unknown[]; properties: { name: string; description?: string | null; @@ -111,6 +122,7 @@ export class ReadyGuildDTO implements IReadyGuildDTO { stage_instances: unknown[]; stickers: Sticker[]; threads: unknown[]; + voice_states: VoiceState[]; version: string; constructor(guild: Guild) { @@ -119,16 +131,17 @@ export class ReadyGuildDTO implements IReadyGuildDTO { 2: 2, 3: 2, }; // ????? - this.channels = guild.channels; + this.channels = guild.channels ?? []; this.data_mode = "full"; - this.emojis = guild.emojis; + this.emojis = guild.emojis ?? []; this.guild_scheduled_events = []; this.id = guild.id; this.large = guild.large; this.lazy = true; // ?????????? this.member_count = guild.member_count; - this.members = guild.members; + this.members = guild.members ?? []; this.premium_subscription_count = guild.premium_subscription_count; + this.presences = []; this.properties = { name: guild.name, description: guild.description, @@ -158,10 +171,11 @@ export class ReadyGuildDTO implements IReadyGuildDTO { nsfw_level: guild.nsfw_level, hub_type: null, }; - this.roles = guild.roles; + this.roles = guild.roles ?? []; this.stage_instances = []; - this.stickers = guild.stickers; + this.stickers = guild.stickers ?? []; this.threads = []; + this.voice_states = guild.voice_states ?? []; this.version = "1"; // ?????? }