async function reproduceSong(interaction, connection, player, channel) {
if (sp > 0) {
try {
await search(queue[0]);
} catch (error) {
//song not found
channel.send("Song " + queue[0] + " not found, skipping.")
removeTopSong();
reproduceSong(interaction, connection, player, channel)
}
const resource = createAudioResource('Path');
player.play(resource);
channel.send("Now playing " + videoLink);
player.addListener("stateChange", (oldOne, newOne) => {
if (newOne.status == "idle") {
console.log("Song finished, moving to next.");
removeTopSong();
reproduceSong(interaction, connection, player, channel);
}
});
} else { //queue ended
interaction.editReply("Queue has ended.");
connection.destroy();
return -1;
}
}
async function reproduceSong(interaction, connection, player, channel) {
if (sp > 0) {
try {
await search(queue[0]);
} catch (error) {
//song not found
channel.send("Song " + queue[0] + " not found, skipping.")
removeTopSong();
reproduceSong(interaction, connection, player, channel)
}
const resource = createAudioResource('Path');
player.play(resource);
channel.send("Now playing " + videoLink);
player.addListener("stateChange", (oldOne, newOne) => {
if (newOne.status == "idle") {
console.log("Song finished, moving to next.");
removeTopSong();
reproduceSong(interaction, connection, player, channel);
}
});
} else { //queue ended
interaction.editReply("Queue has ended.");
connection.destroy();
return -1;
}
}