lavalink-client 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -339,12 +339,12 @@ class LavalinkNode {
|
|
|
339
339
|
player.voice = data.playerOptions.voice;
|
|
340
340
|
if (typeof data.playerOptions.volume !== "undefined") {
|
|
341
341
|
if (this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer) {
|
|
342
|
-
player.volume = data.playerOptions.volume / this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
343
|
-
player.lavalinkVolume = data.playerOptions.volume;
|
|
342
|
+
player.volume = Math.round(data.playerOptions.volume / this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer);
|
|
343
|
+
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
344
344
|
}
|
|
345
345
|
else {
|
|
346
|
-
player.volume = data.playerOptions.volume;
|
|
347
|
-
player.lavalinkVolume = data.playerOptions.volume;
|
|
346
|
+
player.volume = Math.round(data.playerOptions.volume);
|
|
347
|
+
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
if (typeof data.playerOptions.filters !== "undefined") {
|
|
@@ -73,11 +73,13 @@ class Player {
|
|
|
73
73
|
}
|
|
74
74
|
if (!this.node)
|
|
75
75
|
throw new Error("No available Node was found, please add a LavalinkNode to the Manager via Manager.NodeManager#createNode");
|
|
76
|
-
if (this.LavalinkManager.options.playerOptions.volumeDecrementer)
|
|
77
|
-
this.volume *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
78
|
-
this.LavalinkManager.emit("playerCreate", this);
|
|
79
76
|
if (typeof options.volume === "number" && !isNaN(options.volume))
|
|
80
|
-
this.
|
|
77
|
+
this.volume = Number(options.volume);
|
|
78
|
+
this.volume = Math.round(Math.max(Math.min(this.volume, 1000), 0));
|
|
79
|
+
this.lavalinkVolume = Math.round(Math.max(Math.min(Math.round(this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
80
|
+
? this.volume * this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
81
|
+
: this.volume), 1000), 0));
|
|
82
|
+
this.LavalinkManager.emit("playerCreate", this);
|
|
81
83
|
this.queue = new Queue_1.Queue(this.guildId, {}, new Queue_1.QueueSaver(this.LavalinkManager.options.queueOptions), this.LavalinkManager.options.queueOptions);
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
@@ -155,8 +157,8 @@ class Player {
|
|
|
155
157
|
let vol = Number(this.volume);
|
|
156
158
|
if (this.LavalinkManager.options.playerOptions.volumeDecrementer)
|
|
157
159
|
vol *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
158
|
-
this.lavalinkVolume = Math.
|
|
159
|
-
options.volume =
|
|
160
|
+
this.lavalinkVolume = Math.round(vol);
|
|
161
|
+
options.volume = this.lavalinkVolume;
|
|
160
162
|
}
|
|
161
163
|
const finalOptions = {
|
|
162
164
|
encodedTrack: track.encoded,
|
|
@@ -193,17 +195,16 @@ class Player {
|
|
|
193
195
|
volume = Number(volume);
|
|
194
196
|
if (isNaN(volume))
|
|
195
197
|
throw new TypeError("Volume must be a number.");
|
|
196
|
-
this.volume = Math.max(Math.min(volume,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
volume
|
|
200
|
-
this.lavalinkVolume = Math.floor(volume * 100) / 100;
|
|
198
|
+
this.volume = Math.round(Math.max(Math.min(volume, 1000), 0));
|
|
199
|
+
this.lavalinkVolume = Math.round(Math.max(Math.min(Math.round(this.LavalinkManager.options.playerOptions.volumeDecrementer && !ignoreVolumeDecrementer
|
|
200
|
+
? this.volume * this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
201
|
+
: this.volume), 1000), 0));
|
|
201
202
|
const now = performance.now();
|
|
202
203
|
if (this.LavalinkManager.options.playerOptions.applyVolumeAsFilter) {
|
|
203
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume:
|
|
204
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume: this.lavalinkVolume / 100 } } });
|
|
204
205
|
}
|
|
205
206
|
else {
|
|
206
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume } });
|
|
207
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume: this.lavalinkVolume } });
|
|
207
208
|
}
|
|
208
209
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
209
210
|
return;
|
|
@@ -420,7 +421,7 @@ class Player {
|
|
|
420
421
|
noReplace: false,
|
|
421
422
|
playerOptions: {
|
|
422
423
|
position: data.position,
|
|
423
|
-
volume: data.volume,
|
|
424
|
+
volume: Math.round(Math.max(Math.min(data.volume, 1000), 0)),
|
|
424
425
|
paused: data.paused,
|
|
425
426
|
filters: { ...data.filters, equalizer: data.equalizer },
|
|
426
427
|
},
|
|
@@ -335,12 +335,12 @@ export class LavalinkNode {
|
|
|
335
335
|
player.voice = data.playerOptions.voice;
|
|
336
336
|
if (typeof data.playerOptions.volume !== "undefined") {
|
|
337
337
|
if (this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer) {
|
|
338
|
-
player.volume = data.playerOptions.volume / this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
339
|
-
player.lavalinkVolume = data.playerOptions.volume;
|
|
338
|
+
player.volume = Math.round(data.playerOptions.volume / this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer);
|
|
339
|
+
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
340
340
|
}
|
|
341
341
|
else {
|
|
342
|
-
player.volume = data.playerOptions.volume;
|
|
343
|
-
player.lavalinkVolume = data.playerOptions.volume;
|
|
342
|
+
player.volume = Math.round(data.playerOptions.volume);
|
|
343
|
+
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
if (typeof data.playerOptions.filters !== "undefined") {
|
|
@@ -70,11 +70,13 @@ export class Player {
|
|
|
70
70
|
}
|
|
71
71
|
if (!this.node)
|
|
72
72
|
throw new Error("No available Node was found, please add a LavalinkNode to the Manager via Manager.NodeManager#createNode");
|
|
73
|
-
if (this.LavalinkManager.options.playerOptions.volumeDecrementer)
|
|
74
|
-
this.volume *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
75
|
-
this.LavalinkManager.emit("playerCreate", this);
|
|
76
73
|
if (typeof options.volume === "number" && !isNaN(options.volume))
|
|
77
|
-
this.
|
|
74
|
+
this.volume = Number(options.volume);
|
|
75
|
+
this.volume = Math.round(Math.max(Math.min(this.volume, 1000), 0));
|
|
76
|
+
this.lavalinkVolume = Math.round(Math.max(Math.min(Math.round(this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
77
|
+
? this.volume * this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
78
|
+
: this.volume), 1000), 0));
|
|
79
|
+
this.LavalinkManager.emit("playerCreate", this);
|
|
78
80
|
this.queue = new Queue(this.guildId, {}, new QueueSaver(this.LavalinkManager.options.queueOptions), this.LavalinkManager.options.queueOptions);
|
|
79
81
|
}
|
|
80
82
|
/**
|
|
@@ -152,8 +154,8 @@ export class Player {
|
|
|
152
154
|
let vol = Number(this.volume);
|
|
153
155
|
if (this.LavalinkManager.options.playerOptions.volumeDecrementer)
|
|
154
156
|
vol *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
155
|
-
this.lavalinkVolume = Math.
|
|
156
|
-
options.volume =
|
|
157
|
+
this.lavalinkVolume = Math.round(vol);
|
|
158
|
+
options.volume = this.lavalinkVolume;
|
|
157
159
|
}
|
|
158
160
|
const finalOptions = {
|
|
159
161
|
encodedTrack: track.encoded,
|
|
@@ -190,17 +192,16 @@ export class Player {
|
|
|
190
192
|
volume = Number(volume);
|
|
191
193
|
if (isNaN(volume))
|
|
192
194
|
throw new TypeError("Volume must be a number.");
|
|
193
|
-
this.volume = Math.max(Math.min(volume,
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
volume
|
|
197
|
-
this.lavalinkVolume = Math.floor(volume * 100) / 100;
|
|
195
|
+
this.volume = Math.round(Math.max(Math.min(volume, 1000), 0));
|
|
196
|
+
this.lavalinkVolume = Math.round(Math.max(Math.min(Math.round(this.LavalinkManager.options.playerOptions.volumeDecrementer && !ignoreVolumeDecrementer
|
|
197
|
+
? this.volume * this.LavalinkManager.options.playerOptions.volumeDecrementer
|
|
198
|
+
: this.volume), 1000), 0));
|
|
198
199
|
const now = performance.now();
|
|
199
200
|
if (this.LavalinkManager.options.playerOptions.applyVolumeAsFilter) {
|
|
200
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume:
|
|
201
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume: this.lavalinkVolume / 100 } } });
|
|
201
202
|
}
|
|
202
203
|
else {
|
|
203
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume } });
|
|
204
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume: this.lavalinkVolume } });
|
|
204
205
|
}
|
|
205
206
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
206
207
|
return;
|
|
@@ -417,7 +418,7 @@ export class Player {
|
|
|
417
418
|
noReplace: false,
|
|
418
419
|
playerOptions: {
|
|
419
420
|
position: data.position,
|
|
420
|
-
volume: data.volume,
|
|
421
|
+
volume: Math.round(Math.max(Math.min(data.volume, 1000), 0)),
|
|
421
422
|
paused: data.paused,
|
|
422
423
|
filters: { ...data.filters, equalizer: data.equalizer },
|
|
423
424
|
},
|
package/package.json
CHANGED