how to repeat music once it's finished

Hi, once the music playback finishes the bot crashes and I get this error
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
But I'd like it to start all over again
2 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
t3mq
t3mqOP15mo ago
that is to say My bot crashes after a while, and when the resource reaches its end, I'd like it to loop again once it's finished I had previously
audioPlayer.on(AudioPlayerStatus.Idle, () => {
audioPlayer.play(resource);
});
audioPlayer.on(AudioPlayerStatus.Idle, () => {
audioPlayer.play(resource);
});
because the music stopped But there's no way to get her to do it again? ? isn't this method more efficient?
audioPlayer.on(AudioPlayerStatus.Finish, () => {
audioPlayer.play(resource);
});
audioPlayer.on(AudioPlayerStatus.Finish, () => {
audioPlayer.play(resource);
});
But what I don't understand is why it works. since I replaced Idle with this, I no longer get errors Oe it won't happen again I'd like to try, but I can't really see how to use your method. But could you tell me a little more about the method you're using? Except that I'm finding it hard to understand - I've tried to understand - except that I really can't see how I'm supposed to do my play afterwards. I understand that you have to use AudioRessource again. with createAudioResource except that I've already created a resource I understand that, but I don't know how to go about it. But I understand what I'm doing, except that I don't understand the wording of what you're telling me. I'm talking to a translator, so it's even more complicated to understand.
Want results from more Discord servers?
Add your server