discord.js: Discord does not support receiving audio

Please describe the problem you are having in as much detail as possible: When creating a readable stream for audio, no audio is received from the on data event. This used to work a month or so ago, but no longer works. No data is passed, the on end event is never passed.

Include a reproducible code sample here, if possible:

const audioStream = voiceReceiver.createStream(member, { end: 'manual', mode: 'pcm' });
               audioStream.on('data', (chunk) => {
                console.log(`Received ${chunk.length} bytes of data.`);
              });

Further details:

  • discord.js version: 12.0.0-dev (master)
  • Node.js version: v8.11.4
  • Operating system: Windows 10 (also tested on Ubuntu 16.04 with node v11.0.0)
  • Priority this issue should have – please be realistic and elaborate if possible: High priority for bots needing audio receiving
  • I found this issue while running code on a user account
  • I have also tested the issue on latest master, commit hash: f3cad81f5314a3997ac188277e2471ba84cbd771

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Sending the silence frame only once also works for me:

const { Readable } = require('stream');

const SILENCE_FRAME = Buffer.from([0xF8, 0xFF, 0xFE]);

class Silence extends Readable {
  _read() {
    this.push(SILENCE_FRAME);
    this.destroy();
  }
}

voiceConnection.play(new Silence(), { type: 'opus' });

As per https://github.com/discordapp/discord-api-docs/issues/808 (see below), it seems that Discord does not support receiving audio and there currently seems to be no immediate intention of supporting it.

image

I’d hate to entirely remove this feature from Discord.js because it can work with some tinkering around. However, without any documentation or communication from the developers I’m no longer going to actively maintain this feature as it’s too unstable.

Sorry for how this has turned out! 😢 I’ll leave this issue open to continue posting any updates about the situation and hopefully we’ll be able to resolve this once documentation is provided.

Discord used to have a bug where bots couldn’t receive audio if they didn’t play any audio, it got fixed but I just tested now and it looks like it came back. There have been reports of this from users of other libraries, so my suggestion would be to consider playing a silent audio file when your bot joins a channel so that it can still receive audio until Discord fixes it.

I’ve been trying Minn’s fix but it doesn’t seem to be working 😕

This issue is also reproduced in JDA https://github.com/DV8FromTheWorld/JDA/issues/789