Troubleshooting Discord bot: Resolving 'FFMPEG not found' error

Hey everyone, I’m having trouble with my Discord bot. I’m trying to make it join a voice channel, but I keep getting this annoying error message: FFMPEG not found. It pops up in the log every time I run the command.

I’ve got this code for the bot:

bot.on('messageCreate', msg => {
  if (!msg.guild) return;

  if (msg.content === '!enterVoice') {
    if (msg.member.voice.channel) {
      msg.member.voice.channel.join()
        .then(conn => {
          msg.reply('Yay! I joined the voice channel!');
        })
        .catch(err => console.error(err));
    } else {
      msg.reply('Oops! You need to be in a voice channel first.');
    }
  }
});

And here’s my package.json:

{
  "name": "mybot",
  "version": "1.0.0",
  "main": "bot.js",
  "scripts": {
    "start": "node bot.js",
    "dev": "nodemon bot.js"
  },
  "dependencies": {
    "discord.js": "^13.0.0",
    "dotenv": "^10.0.0",
    "ffmpeg-static": "^4.4.0",
    "@discordjs/opus": "^0.5.3"
  },
  "devDependencies": {
    "nodemon": "^2.0.12"
  }
}

Any ideas on how to fix this FFMPEG issue? I’m stuck and could really use some help!

Have you considered using the @discordjs/voice package instead? It’s designed specifically for voice functionality in Discord.js v13 and later. You’ll need to update your code a bit, but it’s more reliable for voice operations.

First, install it with npm:

npm install @discordjs/voice

Then, modify your code to use the new methods. Here’s a quick example:

const { joinVoiceChannel } = require('@discordjs/voice');

// In your command handler:
const connection = joinVoiceChannel({
    channelId: msg.member.voice.channel.id,
    guildId: msg.guild.id,
    adapterCreator: msg.guild.voiceAdapterCreator,
});

This approach should bypass the FFMPEG issue entirely. Just make sure you’ve got the latest discord.js version installed too. Let me know if you need more details on implementation.

I ran into this exact issue a while back when building my own Discord bot. The ‘FFMPEG not found’ error can be frustrating, but there’s a simple fix.

First, make sure you’ve actually installed the dependencies listed in your package.json. Run ‘npm install’ in your project directory to ensure everything’s properly installed.

If that doesn’t solve it, you might need to specify the FFMPEG path explicitly. Try adding this line near the top of your bot.js file:

const ffmpeg = require(‘ffmpeg-static’);

Then, when setting up your voice connection, pass the FFMPEG path like this:

msg.member.voice.channel.join({ ffmpeg: ffmpeg })

This should resolve the FFMPEG error. If you’re still having trouble, double-check that your bot has the necessary permissions in your Discord server to join voice channels.

Hope this helps! Let me know if you need any further clarification.

hey there, i had similar issues before. make sure ffmpeg is installed on ur system, not just in the project. u can download it from ffmpeg.org and add it to ur PATH. also, try using the full path to ffmpeg in ur code:

const ffmpeg = require(‘ffmpeg-static’);
client.voice.setFFmpegPath(ffmpeg);

hope this helps!