YTDL AudioPlayer.play gives error

Hello! Trying to replicate a pseudo music bot from links with YTDL
The bot enters in channel, but then returns the error: Error: Cannot play a resource that has already ended.
Code:
var connection = voice.joinVoiceChannel({
            channelId: voiceChannel.id,
            guildId: message.guild.id,
            adapterCreator: message.guild.voiceAdapterCreator,
        });

        const ap = voice.createAudioPlayer();
        const song = await ytdl.getBasicInfo(args[1])

        const stream = ytdl(song.url, {filter: 'audioonly'});
        const resource = await voice.createAudioResource(stream, { inlineVolume: true })
        // console.log(stream, resource, song.url)
        const subs = await connection.subscribe(ap)
        ap.play(resource)

I've the GuildVoiceStates intent
Then if i try without the ytdl.getbasic info, but directly with
const song = args[1] // that is const args = message.content.split(" ");;
i got a big long error:
https://pastebin.com/VCLNcJ51
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?