diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2026-06-10 21:50:33 +0200 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2026-06-10 21:50:33 +0200 |
| commit | dd8897294f0c070948b34214defcb436c70005a3 (patch) | |
| tree | 8e965ab45a789adaef2043eed69cb1563dc0498f /src/handlers | |
| parent | bbc7e707d536b76fddeff28e70095de860a41be8 (diff) | |
Add voice connection state logging to diagnose join failures
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/playCommand.js | 9 |
1 files changed, 8 insertions, 1 deletions
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) { |
