mirror of
https://github.com/danbulant/discord.js
synced 2026-06-08 01:01:30 +00:00
voice: workaround for receiving audio
(#2929 and discordapp/discord-api-docs#808)
This commit is contained in:
parent
d98d464d74
commit
f826c9c75e
1 changed files with 19 additions and 7 deletions
|
|
@ -10,6 +10,15 @@ const EventEmitter = require('events');
|
||||||
const { Error } = require('../../errors');
|
const { Error } = require('../../errors');
|
||||||
const PlayInterface = require('./util/PlayInterface');
|
const PlayInterface = require('./util/PlayInterface');
|
||||||
const Speaking = require('../../util/Speaking');
|
const Speaking = require('../../util/Speaking');
|
||||||
|
const Silence = require('./util/Silence');
|
||||||
|
|
||||||
|
// Workaround for Discord now requiring silence to be sent before being able to receive audio
|
||||||
|
class SingleSilence extends Silence {
|
||||||
|
_read() {
|
||||||
|
super._read();
|
||||||
|
this.push(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SUPPORTED_MODES = [
|
const SUPPORTED_MODES = [
|
||||||
'xsalsa20_poly1305_lite',
|
'xsalsa20_poly1305_lite',
|
||||||
|
|
@ -419,13 +428,16 @@ class VoiceConnection extends EventEmitter {
|
||||||
onSessionDescription(data) {
|
onSessionDescription(data) {
|
||||||
Object.assign(this.authentication, data);
|
Object.assign(this.authentication, data);
|
||||||
this.status = VoiceStatus.CONNECTED;
|
this.status = VoiceStatus.CONNECTED;
|
||||||
clearTimeout(this.connectTimeout);
|
const dispatcher = this.play(new SingleSilence(), { type: 'opus' });
|
||||||
/**
|
dispatcher.on('finish', () => {
|
||||||
* Emitted once the connection is ready, when a promise to join a voice channel resolves,
|
clearTimeout(this.connectTimeout);
|
||||||
* the connection will already be ready.
|
/**
|
||||||
* @event VoiceConnection#ready
|
* Emitted once the connection is ready, when a promise to join a voice channel resolves,
|
||||||
*/
|
* the connection will already be ready.
|
||||||
this.emit('ready');
|
* @event VoiceConnection#ready
|
||||||
|
*/
|
||||||
|
this.emit('ready');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue