Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当我要求音乐机器人跳过歌曲时,音乐机器人代码会继续播放同一首随机歌曲_Javascript_Node.js_Discord - Fatal编程技术网

Javascript 当我要求音乐机器人跳过歌曲时,音乐机器人代码会继续播放同一首随机歌曲

Javascript 当我要求音乐机器人跳过歌曲时,音乐机器人代码会继续播放同一首随机歌曲,javascript,node.js,discord,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:

}

我认为这就是问题所在。请帮帮我

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");
}