diff --git a/src/client/components/MusicPlayer.ts b/src/client/components/MusicPlayer.ts index e4fec78..e838187 100644 --- a/src/client/components/MusicPlayer.ts +++ b/src/client/components/MusicPlayer.ts @@ -274,13 +274,21 @@ class MusicPlayer implements Initialisable if (!connectionData) return; + const config = this.#options.guilds.find(conf => conf.id === guild.id); const { connection } = connectionData; + const { me } = guild.members; + if (!me || !config) + return; try { await Promise.race([ entersState(connection, VoiceConnectionStatus.Signalling, 5_000), entersState(connection, VoiceConnectionStatus.Connecting, 5_000) ]); + // If we find ourselves here, the bot was successfully able to reconnect to a VC + // Now we check if it's the one it's meant to be in + if (me.voice.channelId !== config.voiceChannel) + this.#joinVoiceChannel(guild, config.voiceChannel, config.textOutput); } catch { @@ -288,10 +296,7 @@ class MusicPlayer implements Initialisable // this.#logger.error('Promise error:', err as Error); connection.destroy(); this.#connections.delete(guild.id); - const details = this.#options.guilds.find((conf) => conf.id === guild.id); - if (!details) - return; - this.#joinVoiceChannel(guild, details.voiceChannel, details.textOutput); + this.#joinVoiceChannel(guild, config.voiceChannel, config.textOutput); } // if (newState.status !== VoiceConnectionStatus.Disconnected) // return;