Romans
Romans
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Romans on 9/21/2024 in #djs-voice
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)
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
2 replies