I'm trying to make a queue and make my bot play it until bot has no songs in queue but istead of removing 1 song from queue (song that was played) - queue clears fully! Code:
player.on(AudioPlayerStatus.Idle, () => {
queue.splice(0, 1);
if(!queue[0]) return;
resource = createAudioResource(join('./music/', `${queue[0].toLowerCase()}.mp3`));
player.play(resource);
});
I tried console logging every step (except if(!queue[0]) return) and got this:
song1,song2,song3
song2,song3
song2,song3
song2,song3
song3
song3
song3
<empty>
What am I doing wrong?
Update 1: It removes all the songs one by one, start playing last song I added and right after it - removes last song from array