1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01: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 ddee2c0272
commit d61e6dbab6

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