From 2423ba72e1aaa7334147134dfeb3a311b03cfa90 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sat, 26 Jun 2021 00:53:34 +0545 Subject: [PATCH] Voice state handling --- src/Player.ts | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 1a718eb..de7b484 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -69,29 +69,27 @@ class Player extends EventEmitter { const queue = this.getQueue(oldState.guild.id); if (!queue) return; - // @todo - // update channel - // if (oldState.channelID && newState.channelID && oldState.channelID !== newState.channelID) { - // queue.connection.channel = newState.channel; - // } + if (oldState.channelID && newState.channelID && oldState.channelID !== newState.channelID) { + queue.connection.channel = newState.channel; + } - // if (!oldState.channelID && newState.channelID && newState.member.id === newState.guild.me.id) { - // if (newState.serverMute || !newState.serverMute) { - // queue.setPaused(newState.serverMute); - // } else if (newState.suppress || !newState.suppress) { - // if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop); - // queue.setPaused(newState.suppress); - // } - // } + if (!oldState.channelID && newState.channelID && newState.member.id === newState.guild.me.id) { + if (newState.serverMute || !newState.serverMute) { + queue.setPaused(newState.serverMute); + } else if (newState.suppress || !newState.suppress) { + if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop); + queue.setPaused(newState.suppress); + } + } - // if (oldState.channelID === newState.channelID && oldState.member.id === newState.guild.me.id) { - // if (oldState.serverMute !== newState.serverMute) { - // queue.setPaused(newState.serverMute); - // } else if (oldState.suppress !== newState.suppress) { - // if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop); - // queue.setPaused(newState.suppress); - // } - // } + if (oldState.channelID === newState.channelID && oldState.member.id === newState.guild.me.id) { + if (oldState.serverMute !== newState.serverMute) { + queue.setPaused(newState.serverMute); + } else if (oldState.suppress !== newState.suppress) { + if (newState.suppress) newState.guild.me.voice.setRequestToSpeak(true).catch(Util.noop); + queue.setPaused(newState.suppress); + } + } if (oldState.member.id === this.client.user.id && !newState.channelID) { queue.destroy();