Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
buroburoburo opened this issue Jan 19, 2020 · 0 comments
Open

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

buroburoburo opened this issue Jan 19, 2020 · 0 comments

Comments

@buroburoburo
Copy link

buroburoburo commented Jan 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant