0

I'm learning Discord.js and following this tutorial: https://discord.js.org/#/docs/main/stable/topics/voice . From the start, when I try to run- npm install ffmpeg-binaries I get a huge error message but it tells me to just use install ffmpeg so I did.

Here is my Index.js page(I've replaced my token with * here):

const Discord = require('discord.js');
const Colesbot = new Discord.Client();

const token = '**********************************';

Colesbot.on('ready', () =>{
    console.log('Slamsbot is online.');
})

Colesbot.on('message', msg=>{
   if(msg.content == "What up bot?"){
       msg.reply("Whats good pimp?")
   }
});

Colesbot.on('message', message=>{
    if (message.content === '/join') {
        // Only try to join the sender's voice channel if they are in one themselves
        if (message.member.voiceChannel) {
            message.member.voiceChannel.join().then(connection => {
                message.reply('I have successfully connected to the channel!');
            }).catch(console.log);
    } else {
        message.reply('You need to join a voice channel first!');
      }
    }
 });

//Event listener for new guild members
Colesbot.on('guildMemberAdd', member =>{
    // Send the message to a designated channel on a server:
    const channel = member.guild.channels.find(ch => ch.name === 'general');
    // Do nothing if the channel wasn't found on this server
    if (!channel) return;
    // Send the message, mentioning the member
    channel.send(`Welcome to the server, ${member}. Please use the bot-commands channel to assign yourself a role.`);
})

Colesbot.login(token);



exports.run = (client, message, args) => {

    let user = message.mentions.users.first || message.author;


}

If I type "/join" while not connected to a voice channel I get the proper message. However, if I try while I am I get this error message:

Error: FFMPEG not found
task_queues.js:94
message:"FFMPEG not found"
stack:"Error: FFMPEG not found\n    at Function.selectFfmpegCommand (c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:46:13)\n    at new FfmpegTranscoder (c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\prism-media\src\transcoders\ffmpeg\Ffmpeg.js:7:37)\n    at new MediaTranscoder (c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\prism-media\src\transcoders\MediaTranscoder.js:10:19)\n    at new Prism (c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\prism-media\src\Prism.js:5:23)\n    at new VoiceConnection (c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\discord.js\src\client\voice\VoiceConnection.js:46:18)\n    at c:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\node_modules\discord.js\src\client\voice\ClientVoiceManager.js:63:22\n    at new Promise (<anonymous>)\n    at ClientVoiceManager.joinChannel (c:\Users\bobal\Documents\GitHub\Spotif...

So I went to that folder and the file Ffmpeg.js is there and here is its contents:

const ChildProcess = require('child_process');
const FfmpegProcess = require('./FfmpegProcess');

class FfmpegTranscoder {
  constructor(mediaTranscoder) {
    this.mediaTranscoder = mediaTranscoder;
    this.command = FfmpegTranscoder.selectFfmpegCommand();
    this.processes = [];
  }

  static verifyOptions(options) {
    if (!options) throw new Error('Options not provided!');
    if (!options.media) throw new Error('Media must be provided');
    if (!options.ffmpegArguments || !(options.ffmpegArguments instanceof Array)) {
      throw new Error('FFMPEG Arguments must be an array');
    }
    if (options.ffmpegArguments.includes('-i')) return options;
    if (typeof options.media === 'string') {
      options.ffmpegArguments = ['-i', `${options.media}`].concat(options.ffmpegArguments).concat(['pipe:1']);
    } else {
      options.ffmpegArguments = ['-i', '-'].concat(options.ffmpegArguments).concat(['pipe:1']);
    }
    return options;
  }

  /**
   * Transcodes an input using FFMPEG
   * @param {FfmpegTranscoderOptions} options the options to use
   * @returns {FfmpegProcess} the created FFMPEG process
   * @throws {FFMPEGOptionsError}
   */
  transcode(options) {
    if (!this.command) this.command = FfmpegTranscoder.selectFfmpegCommand();
    const proc = new FfmpegProcess(this, FfmpegTranscoder.verifyOptions(options));
    this.processes.push(proc);
    return proc;
  }

  static selectFfmpegCommand() {
    try {
      return require('ffmpeg-binaries');
    } catch (err) {
      for (const command of ['ffmpeg', 'avconv', './ffmpeg', './avconv']) {
        if (!ChildProcess.spawnSync(command, ['-h']).error) return command;
      }
      throw new Error('FFMPEG not found');
    }
  }
}

module.exports = FfmpegTranscoder;

I also added ffmpeg to system path and it didn't help:

C:\ffmpeg
C:\Users\bobal\Documents\GitHub\Spotify-Playlist-Discord-bot\ffmpeg

I'm not quite sure what to do from here. If you need any other info I'd be glad to give it.

Cole Perry
  • 333
  • 1
  • 5
  • 27
  • Did you add it to system path? – Cursed Feb 21 '20 at 12:52
  • Uh I don't think so. I'm sorry if this is a dumb question but how do I do that? – Cole Perry Feb 21 '20 at 16:11
  • https://windowsloop.com/install-ffmpeg-windows-10/ quick guide – Cursed Feb 21 '20 at 16:13
  • You can use the command line and `SETX`: https://stackoverflow.com/questions/19287379/how-do-i-add-to-the-windows-path-variable-using-setx-having-weird-problems – DaCurse Feb 21 '20 at 16:14
  • I followed @Cursed guide and added it to system path but it still didn't work. What now? I edited the question to show what I did. – Cole Perry Feb 21 '20 at 16:23
  • ffmpeg isn't a javascript program. It's a binary for video/audio playing/modification. Your edit in which you said you added ffmpeg to path: That's not the path to ffmpeg. The installation path looks different. Look up on how to install ffmpeg on Windows. It should be added to your PATH automatically. Note that you can do a lot of damage if you edit your PATH wrong. A lot of programs may stop working. – Tin Nguyen Feb 23 '20 at 21:36

0 Answers0