#Voice connection not starting

4 messages · Page 1 of 1 (latest)

buoyant acorn
#

Im trying to get my bot to just play an audio file in a voice channel, the bot joins the channel but doesnt play any audio and the try-catch in it throws an error

const voiceConnection = joinVoiceChannel({
                channelId: interaction.member.voice.channel.id,
                guildId: interaction.guild.id,
                adapterCreator: interaction.guild.voiceAdapterCreator
            })

            const player = createAudioPlayer()
            const resource = createAudioResource(path)
            const connection = getVoiceConnection(interaction.guild.id)

            try {
                await entersState(voiceConnection, VoiceConnectionStatus.Ready, 5000);
                console.log("Connected: " + interaction.guild.name);
            } catch (error) {
                console.log("Voice Connection not ready within 5s.", error);
                return
            }

            connection.subscribe(player)
            player.play(resource)

            player.on(AudioPlayerStatus.Idle, () => {
                voiceConnection.destroy()
            })
sand pasture
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

buoyant acorn
#

discordjs v14.1.2
node v16.15.1

#

here's the full stack trace

Voice Connection not ready within 5s. AbortError: The operation was aborted
    at abortListener (bot\lib\events.js:970:14)
    at AbortSignal.<anonymous> (bot\lib\events.js:1006:47)
    at AbortSignal.[nodejs.internal.kHybridDispatch] (bot\lib\internal\event_target.js:643:20)
    at AbortSignal.dispatchEvent (bot\lib\internal\event_target.js:585:26)
    at abortSignal (bot\lib\internal\abort_controller.js:284:10)
    at AbortController.abort (bot\lib\internal\abort_controller.js:315:5)
    at Timeout.<anonymous> (bot\node_modules\@discordjs\voice\dist\index.js:1931:39)
    at listOnTimeout (bot\lib\internal\timers.js:559:17)
    at processTimers (node:internal/timers:502:7) {code: 'ABORT_ERR', name: 'AbortError', stack: 'AbortError: The operation was aborted
    at …at processTimers (node:internal/timers:502:7)', message: 'The operation was aborted'}