From dd8897294f0c070948b34214defcb436c70005a3 Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Wed, 10 Jun 2026 21:50:33 +0200 Subject: Add voice connection state logging to diagnose join failures Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/handlers/playCommand.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/handlers/playCommand.js b/src/handlers/playCommand.js index c61e009..81c498f 100644 --- a/src/handlers/playCommand.js +++ b/src/handlers/playCommand.js @@ -136,12 +136,19 @@ async function createVoiceConnection(voiceChannel, interaction) { selfDeaf: true, }); + const stateLogger = (oldState, newState) => { + console.log(`[VOICE STATE] Guild: ${guildId}, ${oldState.status} -> ${newState.status}${newState.reason ? ` (reason: ${newState.reason})` : ''}${newState.closeCode ? ` (closeCode: ${newState.closeCode})` : ''}`); + }; + connection.on('stateChange', stateLogger); + try { await entersState(connection, VoiceConnectionStatus.Ready, 30000); + connection.off('stateChange', stateLogger); return connection; } catch (error) { lastError = error; - console.error(`Failed to join voice channel (attempt ${attempt}/${maxAttempts}):`, error); + console.error(`Failed to join voice channel (attempt ${attempt}/${maxAttempts}), last state: ${connection.state?.status}:`, error); + connection.off('stateChange', stateLogger); try { connection.destroy(); } catch (e) { -- cgit v1.2.3