Why does discord.js v14 stop playing audio?

Viewed 9

I want my bot to play music via @discordjs/voice, and it plays, but after a few minutes it stops and the event "player.on("idle", () => {console.log(' Idle' )} )". I am using this code to play music from a streaming music URL and the version of discord.js is v14. I hope you can help me with this. Thanks.


        const resource = createAudioResource('url', {
            inlineVolume: true
        });
        resource.volume.setVolume(0.9);

        const Connection = joinVoiceChannel({
            channelId: channel.id,
            guildId: channel.guild.id,
            adapterCreator: channel.guild.voiceAdapterCreator
        });
        try {
            const player = createAudioPlayer();
            Connection.subscribe(player);
            // play the resource
            player.play(resource);
            
            player.on("idle", () => {
                console.log('Idle')
            })
            player.on('error', error => {
                console.error(error);
            });
            
        } catch (e) {
            console.log(e)
}```
0 Answers
Related