Discord Music bot - the song i play stopped 10-20 seconds before the end so i added highWaterMark and now the song barely plays at all

放肆的年华 提交于 2020-08-06 02:18:49

问题


So basically i had this issue and i got given a "solution" but it didn't work, so i found a fix and that was adding highWaterMark to my code so the stream stays open longer or whatever idk, so this is what my code looks like currently

    const dispatcher = serverQueue.connection.play(ytdl(song.url, {
        filter:"audioonly",
        highWaterMark: 1<<25 })
        .on("finish", () => {
            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);

but now my issue is that the song will play for like 10 seconds then just stop, i have no idea why this just made my issue worse because for everyone i seen that used this solution it worked perfectly. Please someone help me out with my issue i get tons of post views but no one seems to want to answer :/


回答1:


There recently was an update of ytdl, you should try to run a quick npm update on your project.

Also, I've tried this module and the issue seem to be gone for me. You might also want to make sure that you have both ffmpeg and ffmpeg-static on your project, I think this may have helped to fix the issue in my case.




回答2:


You should try to install the modules found under the Installation section here




回答3:


You might want to try to change the type of the stream to opus :

serverQueue.connection.play(ytdl(song.url, { filter:"audioonly", type: 'opus' });


来源:https://stackoverflow.com/questions/62237105/discord-music-bot-the-song-i-play-stopped-10-20-seconds-before-the-end-so-i-ad

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