summary refs log tree commit diff
path: root/gateway
diff options
context:
space:
mode:
authorAlTech98 <altech123159@gmail.com>2021-09-03 14:12:44 +0200
committerAlTech98 <altech123159@gmail.com>2021-09-03 14:12:44 +0200
commitd61e6dbab69d5a1bfdc1d298d5df885984c5e95b (patch)
treee6b88d66caec6463969fecf2465e60193f00d5d8 /gateway
parentTemp fix for Guild.voice_states not working (diff)
downloadserver-d61e6dbab69d5a1bfdc1d298d5df885984c5e95b.tar.xz
Make the user leave the current channel before joining one in another guild
Diffstat (limited to 'gateway')
-rw-r--r--gateway/src/opcodes/VoiceStateUpdate.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/gateway/src/opcodes/VoiceStateUpdate.ts b/gateway/src/opcodes/VoiceStateUpdate.ts
index 10808c10..668508fd 100644
--- a/gateway/src/opcodes/VoiceStateUpdate.ts
+++ b/gateway/src/opcodes/VoiceStateUpdate.ts
@@ -22,6 +22,15 @@ export async function onVoiceStateUpdate(this: WebSocket, data: Payload) {
 			return;
 		}
 
+		//If a user change voice channel between guild we should send a left event first
+		if (voiceState.guild_id !== body.guild_id) {
+			await emitEvent({
+				event: "VOICE_STATE_UPDATE",
+				data: { ...voiceState, channel_id: null },
+				guild_id: voiceState.guild_id,
+			})
+		}
+
 		//The event send by Discord's client on channel leave has both guild_id and channel_id as null
 		if (body.guild_id === null) body.guild_id = voiceState.guild_id;
 		voiceState.assign(body);