How can i loop an audio resource?

I've tried this
client.audioPlayer.on(AudioPlayerStatus.Idle, () => {
if (!client.audioPlayer) return;
client.audioPlayer.play(client.waitaudio);
});
client.audioPlayer.on(AudioPlayerStatus.Idle, () => {
if (!client.audioPlayer) return;
client.audioPlayer.play(client.waitaudio);
});
But i got an error saying Error: Cannot play a resource that has already ended.
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
edomango
edomangoOP2y ago
npm list discord.js [email protected] /home/edoardo/Desktop/Ammiragli ├─┬ [email protected] │ └── [email protected] deduped └── [email protected] node -v v19.4.0 full Error:
/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:862
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
at AudioPlayer.play (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:862:13)
at AudioPlayer.<anonymous> (/home/edoardo/Desktop/Ammiragli/dist/Events/memberJoinedVC.js:27:36)
at AudioPlayer.emit (node:events:513:28)
at set state [as state] (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:854:12)
at AudioPlayer.checkPlayable (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:959:18)
at /home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:121:60
at Array.filter (<anonymous>)
at audioCycleStep (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:121:34)
at Timeout.<anonymous> (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:132:45)
at listOnTimeout (node:internal/timers:564:17)
/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:862
throw new Error("Cannot play a resource that has already ended.");
^

Error: Cannot play a resource that has already ended.
at AudioPlayer.play (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:862:13)
at AudioPlayer.<anonymous> (/home/edoardo/Desktop/Ammiragli/dist/Events/memberJoinedVC.js:27:36)
at AudioPlayer.emit (node:events:513:28)
at set state [as state] (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:854:12)
at AudioPlayer.checkPlayable (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:959:18)
at /home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:121:60
at Array.filter (<anonymous>)
at audioCycleStep (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:121:34)
at Timeout.<anonymous> (/home/edoardo/Desktop/Ammiragli/node_modules/@discordjs/voice/dist/index.js:132:45)
at listOnTimeout (node:internal/timers:564:17)
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ So I'm making a support voice channel really? createAudioResource(createReadStream('IMG_1792.ogg')) do i have to use createReadStream or not
edomango
edomangoOP2y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
edomango
edomangoOP2y ago
it says to put inputType but typescript says that the object doesn't have this property
Want results from more Discord servers?
Add your server