My Discord music bot stops songs 20 seconds before it is meant to

你离开我真会死。 提交于 2020-07-22 06:04:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!