How do I loop an audio?

const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
})

let audio = pathName + 'yeay.mp3'

let player = createAudioPlayer()
let resource = createAudioResource(audio)

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

player.on(AudioPlayerStatus.Idle, () => {

player.play(resource)

})
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: voiceChannel.guild.id,
adapterCreator: voiceChannel.guild.voiceAdapterCreator,
})

let audio = pathName + 'yeay.mp3'

let player = createAudioPlayer()
let resource = createAudioResource(audio)

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

player.on(AudioPlayerStatus.Idle, () => {

player.play(resource)

})
I tried this but without luck. It plays fine the first time, but doesn't loop the audio which is what I want. How can I do that? The error I am getting is: Error: Cannot play a resource that has already ended.
2 Replies
d.js docs
d.js docs3y ago
• 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.
Iced Queen
Iced QueenOP3y ago
Ahh thank you 😊
Want results from more Discord servers?
Add your server