GoogleChromeLabs / prerender-loader

📰 Painless universal pre-rendering for Webpack.
https://npm.im/prerender-loader
Apache License 2.0
1.9k stars 50 forks source link

Trying to write a script for a discord bot to play music #42

Open buroburoburo opened 4 years ago

buroburoburo commented 4 years ago

Hi, I'm still learning how to code so please bear with me. As the title reads, I'm having issues with a custom bot. It joins the voice channel when i provide a prefix and link but doesn't play the music, instead it sits idle and pops this error message in my terminal; TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object

This is most of the coding for it; ``function play(connection, message){ var server = servers[message.guild.id];

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

            server.queue.shift();

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

        }

        if(!args[1]){
            message.channel.send("You need to provide a link!");
            return;
        }

        if(!message.member.voiceChannel){
            message.channel.send("You must be in a channel to play the bot!");
            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.voiceChannel.join().then(function(connection){
        play(connection, message);
    })
break;   

I am also using ytdl-core as a module for it