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
commit4187a8d1963a47c40cdf0ea8b998a1ca705a7d86 (patch)
tree587702cc9ee740708a5a7fea43e72a7294f27d39 /gateway
parentTemp fix for Guild.voice_states not working (diff)
downloadserver-4187a8d1963a47c40cdf0ea8b998a1ca705a7d86.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);