Add calculatedVolume property

This commit is contained in:
Androz2091 2020-06-24 17:48:25 +02:00
parent ec83e01cde
commit 5a4714772b
2 changed files with 7 additions and 3 deletions

View file

@ -406,8 +406,8 @@ class Player {
const queue = this.queues.find((g) => g.guildID === guildID)
if (!queue) return reject(new Error('Not playing'))
// Updates volume
queue.voiceConnection.dispatcher.setVolumeLogarithmic(percent / 200)
queue.volume = percent
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
// Resolves guild queue
resolve()
})
@ -800,7 +800,7 @@ class Player {
queue.voiceConnection.play(newStream, {
type: 'opus'
})
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.volume / 200)
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
// When the track starts
queue.voiceConnection.dispatcher.on('start', () => {
resolve()
@ -845,7 +845,7 @@ class Player {
queue.voiceConnection.play(newStream, {
type: 'ogg/opus'
})
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.volume / 200)
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
// When the track starts
queue.voiceConnection.dispatcher.on('start', () => {
resolve()

View file

@ -62,6 +62,10 @@ class Queue extends EventEmitter {
*/
this.filters = {}
}
get calculatedVolume () {
return this.filters.bassboost ? this.volume + 40 : this.volume
}
}
module.exports = Queue