izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Trying to play a mp3 file, but it says I miss ffmpeg even though I have it #196

Closed agilbert1412 closed 7 years ago

agilbert1412 commented 7 years ago

Here is the code, copied straight from the documentation:

bot.joinVoiceChannel(voiceChannel, function(error, events) {
    //Check to see if any errors happen while joining.
    if (error) return console.error(error);
    currentVoiceChannel = voiceChannel;

    //Then get the audio context
    bot.getAudioContext(voiceChannel, function(error, stream) {
        //Once again, check to see if any errors exist
        if (error) return console.error(error);

        //Create a stream to your file and pipe it to the stream
        //Without {end: false}, it would close up the stream, so make sure to include that.
        fs.createReadStream("AnswerBot/Music/Ylvis/" + chosenSong.name + ".mp3").pipe(stream, {end: false});
        isPlayingMusic= true;

        //The stream fires `done` when it's got nothing else to send to Discord.
        stream.on('done', leaveVoice);
    });
});

I then get this error:

Error: You need either 'ffmpeg' or 'avconv' and they need to be added to PATH
    at handleErrCB (E:\DiscordBots\answerbot\node_modules\discord.io\lib\index.j
s:1300:25)
    at DiscordClient.DCP.getAudioContext (E:\DiscordBots\answerbot\node_modules\
discord.io\lib\index.js:1266:23)
    at E:\DiscordBots\answerbot\bot.js:471:10
    at call (E:\DiscordBots\answerbot\node_modules\discord.io\lib\index.js:1451:
11)
    at Timeout._onTimeout (E:\DiscordBots\answerbot\node_modules\discord.io\lib\
index.js:1984:35)
    at ontimeout (timers.js:469:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:264:5)

I have installed ffmpeg, and set its path in environment variables. Also tried the same thing with avconv, but it makes no difference.

I'm on windows if it matters.

image

image

izy521 commented 7 years ago

The lib doesn't try to search for it or anything. It basically just attempts to execute ffmpeg or avconv in your shell. Have you tried restarting the command prompt that was open?