From 25a0ec35b78c91aa75467f91ed4b3bbdb8be90e6 Mon Sep 17 00:00:00 2001 From: Jannis Achstetter Date: Mon, 26 Oct 2020 21:40:04 +0100 Subject: [PATCH] Add the possibility to specify a voiceTarget when sending a file or stream --- src/voice/DispatchStream.js | 4 +++- src/voice/Dispatcher.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/voice/DispatchStream.js b/src/voice/DispatchStream.js index 49da300..1d16a22 100644 --- a/src/voice/DispatchStream.js +++ b/src/voice/DispatchStream.js @@ -3,7 +3,7 @@ const EventEmitter = require('events').EventEmitter const Constants = require('../Constants') class DispatchStream extends WritableStream { - constructor(connection) { + constructor(connection, voiceTarget) { super() this.connection = connection this.processObserver = new EventEmitter() @@ -13,6 +13,8 @@ class DispatchStream extends WritableStream { this.frameQueue = [] this.lastFrame = this._createFrameBuffer() + this.whisperId = voiceTarget + this._volume = 1 this.lastFrameWritten = 0 this.lastWrite = null diff --git a/src/voice/Dispatcher.js b/src/voice/Dispatcher.js index 3ee21a1..7ac66cc 100644 --- a/src/voice/Dispatcher.js +++ b/src/voice/Dispatcher.js @@ -9,16 +9,16 @@ class Dispatcher extends EventEmitter { this.connection = this.client.connection } - playFile(filename) { - this.play(filename) + playFile(filename, voiceTarget) { + this.play(filename, voiceTarget) } - playStream(stream) { - this.play(stream) + playStream(stream, voiceTarget) { + this.play(stream, voiceTarget) } - play(unknown) { - this.dispatchStream = new DispatchStream(this.connection) + play(unknown, voiceTarget) { + this.dispatchStream = new DispatchStream(this.connection, voiceTarget) this.dispatchStream.once('finish', () => { this.emit('end') })