From b826061e966f9dc577a3faea36f11a6a34254a7c Mon Sep 17 00:00:00 2001 From: dank074 Date: Tue, 13 May 2025 15:18:19 -0500 Subject: [PATCH] also clear guild_id from voicestate on disconnect --- src/gateway/events/Close.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gateway/events/Close.ts b/src/gateway/events/Close.ts index c3df8bbb..dbbc41d8 100644 --- a/src/gateway/events/Close.ts +++ b/src/gateway/events/Close.ts @@ -54,6 +54,8 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) { // @ts-expect-error channel_id is nullable voiceState.channel_id = null; + // @ts-expect-error guild_id is nullable + voiceState.guild_id = null; voiceState.self_stream = false; voiceState.self_video = false; await voiceState.save(); @@ -61,7 +63,10 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) { // let the users in previous guild/channel know that user disconnected await emitEvent({ event: "VOICE_STATE_UPDATE", - data: voiceState.toPublicVoiceState(), + data: { + ...voiceState.toPublicVoiceState(), + guild_id: prevGuildId, // have to send the previous guild_id because that's what client expects for disconnect messages + }, guild_id: prevGuildId, channel_id: prevChannelId, } as VoiceStateUpdateEvent);