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

Audio Issue #249

Closed Kaezar closed 6 years ago

Kaezar commented 6 years ago

I'm issues with getting audio to work with my discord bot. Here's the section of code:

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

                  //Then get the audio context
                  bot.getAudioContext(VC, 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.
                    play = fs.createReadStream('mpthreetest.mp3')
                    play.pipe(stream, {end: false});

                    //The stream fires `done` when it's got nothing else to send to Discord.
                    stream.on('done', function() {
                       bot.leaveVoiceChannel("VC");
                    });
                    if (error) return console.error(error);
                  });
                });

In node I get this error:

events.js:188
      throw err;
      ^

Error: Unhandled "error" event. (Unrecognized option 'vbr'.
Error splitting the argument list: )
    at AudioCB.emit (events.js:186:19)
    at AudioCB.onerror (_stream_readable.js:663:12)
    at emitOne (events.js:116:13)
    at AudioCB.emit (events.js:211:7)
    at Socket.<anonymous> (/Users/(username)/Iris/node_modules/discord.io/lib/index.js:2451:48)
    at Object.onceWrapper (events.js:315:30)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
izy521 commented 6 years ago

I assume it was fixed? But it seems like you're using an older version of ffmpeg, or one without the vbr option for opus encoding.