1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-21 18:21:36 +02:00

Make the user leave the current channel before joining one in another guild

This commit is contained in:
AlTech98 2021-09-03 14:12:44 +02:00
parent c9024692f7
commit 4187a8d196

View File

@ -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);