Search code examples
javascriptnode.jsdiscord.jsdistube

Discord.js | Bot doesn't join VC and doesn't give error


so basically when I execute my play cmd with the song I want while I am in VC, my bot does not respond to it and doesn't give any errors but if I just type play without the song I want, I get my Please provide song response.

This is the main file

const distube = require('distube');
client.distube = new distube(client, { searchSongs: true, emitNewSongOnly: true })

client.distube
    .on('playSong', (message, queue, song) => message.channel.send(
        `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}\n${status(queue)}`,
    ))
    .on('addSong', (message, queue, song) => message.channel.send(
        `Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}`,
    ))
    .on('error', (message, e) => {
        message.channel.send(`An error occured: ${e}`)
    })

and this is the play cmd:

const distube = require("distube");

module.exports = {
    name: 'play',
    aliases: ['p'],
    description: 'play a song!',
    async execute(client, message, args) {
        
        const VC = message.member.voice.channel;
        if(!VC) return message.reply('Join VC or no music!');

        const music = args.join(" ");
        if(!music) return message.reply("Please provide me a song name");

        await client.distube.play(message, music);

    }
}

the packages I use are:

npm i distube
npm i @discordjs/opus
npm i ffmpeg-static

for references, these are the things that I looked at:

https://distube.js.org/guide/example-bot.html
https://www.youtube.com/watch?v=tbPqM6JcGA4&t=883s

This is also not the first time I'm getting this error. I tried using different packages before but still didn't work. All of them don't respond when I provide the song I want. Basically, my only problem is that the bot doesn't join the VC. Does anyone know how to fix this?


Solution

  • In order to operate distube, you also require ytdl-core in your arsenal of packages, which you can install with the same npm install command as always.