当我要求机器人跳过歌曲时,音乐机器人代码继续播放相同的随机歌曲

时间:2017-07-07 05:48:06

标签: javascript node.js discord

function playMusic(id, message, backQueueUsed) {
voiceChannel = message.member.voiceChannel || voiceChannel;

if (voiceChannel != null) {
    voiceChannel.join()
        .then(function(connection) {
            stream = ytdl("https://www.youtube.com/watch?v=" + id, {
                filter: 'audioonly'
            });
            skipReq = 0;
            skippers = [];

            dispatcher = connection.playStream(stream);
            dispatcher.on('end', function() {
                skipReq = 0;
                skippers = [];
                if (backQueueUsed) {
                    currentBackQueue++;
                } else {
                    queue.shift();
                    queueNames.shift();
                }
                if (queue.length === 0) {
                    queue = [];
                    queueNames = [];
                    if (backQueue.length === currentBackQueue) {
                        currentBackQueue = 0;
                    }
                    youtube.search_video(backQueue[currentBackQueue] + " succ", function(id) {
                        playMusic(id, message, true);
                    });
                } else {
                    playMusic(queue[0], message, false);
                }
            });
        });
} else {
    message.reply("Please be in a voiceChannel or have the bot already in a voiceChannel");
}

}

这是我认为是问题的代码片段。请帮帮我。

0 个答案:

没有答案