diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 12:53:25 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-03 12:53:25 +0200 |
commit | ddf4f54e8157f5f2469852025e111517cd35bb02 (patch) | |
tree | a3ccdf2cc213c6f9d23d2bbba88f84dd4a11e981 | |
parent | fix #310 (diff) | |
download | server-ddf4f54e8157f5f2469852025e111517cd35bb02.tar.xz |
:bug: fix client connection crash on guild create
-rw-r--r-- | util/src/entities/Member.ts | 21 | ||||
-rw-r--r-- | util/src/interfaces/Event.ts | 11 |
2 files changed, 28 insertions, 4 deletions
diff --git a/util/src/entities/Member.ts b/util/src/entities/Member.ts index ae60f4e2..db4e827b 100644 --- a/util/src/entities/Member.ts +++ b/util/src/entities/Member.ts @@ -208,7 +208,7 @@ export class Member extends BaseClassWithoutId { where: { id: guild_id, }, - relations: ["channels", "emojis", "members", "roles", "stickers"], + relations: ["channels", "emojis", "members", "roles", "stickers", "voice_states"], }); if (await Member.count({ id: user.id, guild: { id: guild_id } })) @@ -225,8 +225,6 @@ export class Member extends BaseClassWithoutId { mute: false, pending: false, }; - // @ts-ignore - guild.joined_at = member.joined_at.toISOString(); await Promise.all([ Member.insert({ @@ -255,7 +253,22 @@ export class Member extends BaseClassWithoutId { } as GuildMemberAddEvent), emitEvent({ event: "GUILD_CREATE", - data: { ...guild, members: [...guild.members, { ...member, user }] }, + data: { + ...guild, + members: [...guild.members, { ...member, user }], + member_count: (guild.member_count || 0) + 1, + guild_hashes: { + channels: { omitted: false, hash: "nkMQJ5nl5Cg" }, + metadata: { omitted: false, hash: "+5ybMfcb8iw" }, + roles: { omitted: false, hash: "Idhc6P9ktfM" }, + version: 1, + }, + guild_scheduled_events: [], + joined_at: member.joined_at, + presences: [], + stage_instances: [], + threads: [], + }, user_id, } as GuildCreateEvent), ]); diff --git a/util/src/interfaces/Event.ts b/util/src/interfaces/Event.ts index 7ea1bd49..acaa822e 100644 --- a/util/src/interfaces/Event.ts +++ b/util/src/interfaces/Event.ts @@ -125,6 +125,17 @@ export interface GuildCreateEvent extends Event { event: "GUILD_CREATE"; data: Guild & { joined_at: Date; + // TODO: add them to guild + guild_scheduled_events: never[]; + guild_hashes: { + channels: { omitted: boolean; hash: string }; + metadata: { omitted: boolean; hash: string }; + roles: { omitted: boolean; hash: string }; + version: number; + }; + presences: never[]; + stage_instances: never[]; + threads: never[]; }; } |