Problems playing music with a Discord bot in Javascript

I have a problem with my offers, it sopused a song after the command! To play game connected but i keep the same mistake, could someone please help me

Code:

const {Client, Attachment} = require('discord.js');
const bot = new Client();

const ytdl = require("ytdl-core");

const token = 'awhdbaiwdiawd';

const PREFIX ='!';

var servers = {};



bot.on('ready', () =>{
    console.log('Bot online');
})

bot.on('message', msg=>{

    let args = msg.content.substring(PREFIX.length).split(" ");

    switch(args(0)){
        case 'play':

            function play(connection, msg){
                var server = servers(msg.guild.id);

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

                server.queue.shift();

                server.dispatcher.on("end", function(){
                    if(server.queue(0)){
                        play(connection, msg);
                    }else {
                        connection.disconnect();
                    }
                });
            }
            if (!args(1)){
                msg.channel.sendMessage('you have to link a song');
                return;
            }

            if (!msg.member.voiceChannel){
                msg.channel.sendMessage('you have to be in a voice channel');
                return;
            }

            if(!servers(msg.guild.id)) servers(msg.guild.id) = {
                queue: ()
            }

            var server = servers(msg.guild.id);

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

            if(!msg.guild.voiceConnection) msg.member.voiceChannel.join().then(function(connection) {
                play(connection, msg);
            })

            break;
          }
)}

error message

Typeerror (ERR_INVALID_ARG_TYPE): The "file" argument must be of type string. Obtain type of object
Typeerror (ERR_INVALID_ARG_TYPE): The "file" argument must be of type string. Obtain type of object

C: Users João Nolasco Desktop DiscordBot node_modules opusscript build opusscript_native_wasm.js: 8
var module = typeof module == "undefined" module 😕 {}; var moduleOverrides = {}; var key; for (key in module) {if (Module.hasOwnProperty (key)) {moduleOverrides (key) = ModuostRun “) = (); var ENVIRONMENT_IS_WEB = false; var ENVIRONMENT_IS_WORKER = false; var ENVIRONMENT_IS_NODE = false; var ENVIRONMENT_IS_SHELL = false; var ENVIRONMENT_IS_WEB = false; "; ENVIRONMENT_HAS_NODE = typeof process ===" object "&& typeof process.versions ===" object "&& typeof process.versions.node ===" string "; ENVIRONMENT_IS_NODE = ENVIRONMENT_HAS_NODE && ENVIRONMENT_IS_WEB && ENVIRONELL_IS_ ENVIRONELLISIS! && ENVIRONMENT_IS_NODE &&! ENVIRONMENT_IS_WORKER; var scriptDirectory = ""; Function Locate (path) {i
Abort (Typeerror (ERR_INVALID_ARG_TYPE): The "file" argument must be of type String. Received type object.). Create ASSERTIONS = 1 with -s for more information.

Thanks for your help

Integration of discord Forum Promotion

Hey everyone

I will try to create a gaming website. I'm really interested to hear if anyone succeeds with any kind of forum software that has really good discord integration. Basically I would like to show my whole server somewhere on the website / forum. I mean, in the worst case, I could frame the Discord website on a blank page. But really curious which software people like best.

My Discord Server and information about me!

Hello, my name is iiSkullmas and I have a discord server called Skycadians, if you want to find new friends and hang out, this is the place for you. Skycadians is an entertaining gaming / community chat server, an entertaining little community, and we're definitely looking forward to passing the number of members on so the community can get bigger, better, and stronger! If you are looking for a couple of friends this is for you :] Posted on Categories ArticlesTags , ,

python – Discord offered problem to Youtube, disagreement bugged pure MP3

Hello, I have a problem with my discord music bot … I know that YouTube blocks things, but on my bot I try to play an MP3
The following error command is:
x.play (discord.FFmpegPCMAudio (music), after = lambda and: proximaMusica (x, message.guild.id))

Music = way to MP3
This next song is a function to call the next and passes some parameters …
The problem here is that the bot was called to the audio channel, but this is not …
Error in line 349 ClientException Not connected to Voice.

That's the mistake that exists!

Does anyone know what I have to solve?

windows – How do I activate my bot in discord?

Thank you for your contribution to Stack Overflow in Portuguese!

  • Make sure you answer the question, Enter details about your solution and share your findings.

But avoid

  • Ask for explanations or details of other answers.
  • Make statements based solely on your opinion; Point references or previous experience.

For more information, see our tips for writing good answers.