Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

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

Description

@buroburoburo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions