#Voice connection not starting

1 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()
            })