mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Receiver#createStream should take options
This commit is contained in:
@@ -10,12 +10,12 @@ class VoiceReceiver extends EventEmitter {
|
||||
this.connection.sockets.udp.socket.on('message', buffer => this.packets.push(buffer));
|
||||
}
|
||||
|
||||
createStream(user, pcm=false) {
|
||||
createStream(user, { mode = 'opus' } = {}) {
|
||||
user = this.connection.client.users.resolve(user);
|
||||
if (!user) throw new Error('VOICE_USER_MISSING');
|
||||
console.log('making stream for', user.tag);
|
||||
const stream = this.packets.makeStream(user.id);
|
||||
if (pcm) {
|
||||
if (mode === 'pcm') {
|
||||
const decoder = new prism.opus.Decoder({ channels: 2, rate: 48000, frameSize: 1920 });
|
||||
stream.pipe(decoder);
|
||||
return decoder;
|
||||
|
||||
@@ -3,15 +3,9 @@ const { Readable } = require('stream');
|
||||
class VoiceReadable extends Readable {
|
||||
constructor() {
|
||||
super();
|
||||
this._packets = [];
|
||||
this.open = true;
|
||||
}
|
||||
|
||||
_read() {} // eslint-disable-line no-empty-function
|
||||
|
||||
_push(d) {
|
||||
if (this.open) this.push(d);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = VoiceReadable;
|
||||
|
||||
Reference in New Issue
Block a user