问题
Now i'm not that good at Javascript, i consider myself still a learner as i still make quite a lot of mistakes from time to time (not without being able to fix them shortly after) but i am at a complete loss with this Discord bot that i'm coding, now i know that a decent amount is my code but this one area of my code i believe to possibly be the culprit of my discord bot cutting off the music stream around 20 seconds before the end.
function play(guild, song) {
const serverQueue = queue.get(guild.id);
if (!song) {
serverQueue.voiceChannel.leave();
return queue.delete(guild.id);
}
const dispatcher = serverQueue.connection.play(ytdl(song.url))
.on("end", () => {
const shiffed = serverQueue.songs.shift();
if (serverQueue.loop === true) {
serverQueue.songs.push(shiffed);
};
play(guild, serverQueue.songs[0]);
})
.on("error", error => console.error(error));
dispatcher.setVolume(serverQueue.volume / 100);
I am completely at a loss as i am not that good at Javascript i would really appreciate the help!
Edit: Should mention i seen this post: Discord bot audio end before the song end they have the exact same issue as me and they said they were able to fix it but i am not able to do so and i would really appreciate if someone could give me a bit of help on this
来源:https://stackoverflow.com/questions/62135569/my-discord-music-bot-stops-songs-20-seconds-before-it-is-meant-to