The bot's voice does not work. (Musical bot) Why?

  • 0
    There are no problems with some commands. The fact is that when I enter the name of the song, the bot finds it, everything is clear, and when it comes to me in the voice box, it can be seen by the green edging that some sounds are supposed to be uttered, but nothing like that is heard. Here's the code for everyone:

    const { Player } = require("discord-player");
    // Create a new Player (you don't need any API Key)
    const player = new Player(client);
    // To easily access the player
    client.player = player;
    // add the trackStart event so when a song will be played this message will be sent
    client.player.on('trackStart', (message, track) => message.channel.send(`Now playing ${track.title}...`))
    
    client.on("ready", () => {
        console.log("I'm ready !");
    });
    
    client.on("message", async (message) => {
    
        const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
        const command = args.shift().toLowerCase();
    
        // !play Despacito
        // will play "Despacito" in the member voice channel
    
        if(command === "play"){
            client.player.play(message, args[0], message.member.user);
            // as we registered the event above, no need to send a success message here
        }
    
    });
    client.player
    
    // Send a message when a track starts
    .on('trackStart', (message, track) => message.channel.send(`Now playing ${track.title}...`))
    
    // Send a message when something is added to the queue
    .on('trackAdd', (message, track) => message.channel.send(`${track.title} has been added to the queue!`))
    .on('playlistAdd', (message, playlist) => message.channel.send(`${playlist.title} has been added to the queue (${playlist.items.length} songs)!`))
    
    // Send messages to format search results
    .on('searchResults', (message, query, tracks) => {
    
        const embed = new Discord.MessageEmbed()
        .setAuthor(`Here are your search results for ${query}!`)
        .setDescription(tracks.map((t, i) => `${i}. ${t.title}`))
        .setFooter('Send the number of the song you want to play!')
        message.channel.send(embed);
    
    })
    .on('searchInvalidResponse', (message, query, tracks, content, collector) => message.channel.send(`You must send a valid number between 1 and ${tracks.length}!`))
    .on('searchCancel', (message, query, tracks) => message.channel.send('You did not provide a valid response... Please send the command again!'))
    .on('noResults', (message, query) => message.channel.send(`No results found on YouTube for ${query}!`))
    
    // Send a message when the music is stopped
    .on('queueEnd', (message, queue) => message.channel.send('Music stopped as there is no more music in the queue!'))
    .on('channelEmpty', (message, queue) => message.channel.send('Music stopped as there is no more member in the voice channel!'))
    .on('botDisconnect', (message, queue) => message.channel.send('Music stopped as I have been disconnected from the channel!'))
    
    // Error handling
    .on('error', (error, message) => {
        switch(error){
            case 'NotPlaying':
                message.channel.send('There is no music being played on this server!')
                break;
            case 'NotConnected':
                message.channel.send('You are not connected in any voice channel!')
                break;
            case 'UnableToJoin':
                message.channel.send('I am not able to join your voice channel, please check my permissions!')
                break;
            default:
                message.channel.send(`Something went wrong... Error: ${error}`)
        }
    })
    Node.js Eden McGrath, Aug 21, 2019

  • 1 Answers
  • 0
    Found a solution. There was another troubleshooter, almost spamming messages by a bot .. roughly speaking:

    The song "title of the song" is playing

    The song "title of the song" is playing

    The song "title of the song" is playing

    The song "name of the song" is playing
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!