TypeError:connection.playStream不是一个功能不一致的bot

时间:2020-06-04 20:30:59

标签: discord.js

switch(args[0]){
case 'ping':
message.reply('pong!');
    break;
case 'play':
    if (message.member.voice.channel) {
    if(args[1]){
        const connection = message.member.voice.channel.join();
        const dispatcher = connection.playStream(ytdl(args[1]));

    }else{
    message.reply('Tio, el link joder');
    }

    } else {
    message.reply('Pero tio, únete al canal de voz');
    }
break;  
case 'info':
    message.reply('No soy el FBI,hippie');
    break;
case 'clear':
    if(!args[1]) return message.reply('Hippie,que te falta un argumento')
    message.channel.bulkDelete(args[1]);
    break;
        }
         });

我试图在其他问题中寻求解决方案,但是这些都不是我所需要或不起作用的,这是错误TypeError:connection.playStream不是函数

2 个答案:

答案 0 :(得分:0)

在新的v12更新中,playStream已失效。

新的正确代码是

server.dispatcher = connection.play(ytdl(server.queue[0], {filter: "audioonly"}));

不是playStream而是播放。

答案 1 :(得分:0)

正在对您正在运行的相同代码进行故障排除,这是完整播放,停止和跳过命令。虽然我无法弄清队列,但这可以解决您的错误,因为队列未运行。

case 'play':

                if(usedCommandRecently4.has(message.author.id)){
                    message.reply("Your using this command to fast!");
                } else{
                    function play(connection, message){
                        var server = servers[message.guild.id];

                        server.dispatcher = connection.play(ytdl(server.queue[0], {filter: "audioonly"}));

                        server.queue.shift();

                        message.channel.send("``Music Bot v1.2`` \n Adding song to queue!");

                        server.dispatcher.on("end", function(){
                            if(server.queue[0]){
                                play(connection, message);
                            }else {
                                connection.disconnect();
                            }
                        })
                    }

                    if(!args[1]){
                        message.channel.send("``Music Bot v1.2`` \n you need to provide a link!!");
                        return;
                    }

                    if(!message.member.voice.channel){
                        message.channel.send("``Music Bot v1.2`` \n You must be in a voice channel to play music!");
                        return;
                    }

                    if(!servers[message.guild.id]) servers[message.guild.id] = {
                        queue: []
                    }

                    var server = servers[message.guild.id];

                    server.queue.push(args[1]);

                    if(!message.guild.voiceConnection)message.member.voice.channel.join().then(function(connection){
                        server.dispatcher = connection.play(ytdl(server.queue[0], {filter: "audioonly"}));
                        play(connection, message);

                    })

                    usedCommandRecently4.add(message.author.id);
                    setTimeout(() => {
                        usedCommandRecently4.delete(message.author.id)
                    }, 10000);
                }

            break;

            case 'skip':

                if(usedCommandRecently3.has(message.author.id)){
                    message.reply("Your using this command to fast!");
                } else{
                    var server = servers[message.guild.id];
                    if(server.dispatcher) server.dispatcher.end();
                    message.channel.send("``Music Bot v1.2`` \n Skipping the current song!")

                    usedCommandRecently3.add(message.author.id);
                    setTimeout(() => {
                        usedCommandRecently3.delete(message.author.id)
                    }, 3000);
                }

            break;

            case 'stop':
                var server = servers[message.guild.id];
                if(message.guild.voice.connection){
                    for(var i = server.queue.length -1; i >=0; i--){
                        server.queue.splice(i, 1);
                    }

                    server.dispatcher.end();
                    message.channel.send("``Music Bot v1.2`` \n Ending the queue and Leaving the voice channel! \n This bot is in early development! \n if you have any problems with it dm Justice#6770!")
                    console.log('stopped the queue')
                }
            }

            if(message.guild.connection) message.guild.voiceConnection.disconnect();