Skip to content

Commit

Permalink
Add the possibility to specify a voiceTarget when sending a file or s…
Browse files Browse the repository at this point in the history
…tream
  • Loading branch information
kripton committed Oct 26, 2020
1 parent f425085 commit 25a0ec3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/voice/DispatchStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/voice/Dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
Expand Down

0 comments on commit 25a0ec3

Please sign in to comment.