magmastream 2.9.1-dev.5 → 2.9.1-dev.6

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.
package/dist/index.d.ts CHANGED
@@ -1776,6 +1776,8 @@ interface PlayerOptions {
1776
1776
  selfMute?: boolean;
1777
1777
  /** If the player should deaf itself. */
1778
1778
  selfDeafen?: boolean;
1779
+ /** Whether to apply the volume as a filter. */
1780
+ applyVolumeAsFilter?: boolean;
1779
1781
  }
1780
1782
  /**
1781
1783
  * PlayOptions interface
@@ -80,6 +80,13 @@ class Player {
80
80
  this.clusterId = this.manager.options.clusterId || 0;
81
81
  // Check the player options for errors.
82
82
  (0, playerCheck_1.default)(options);
83
+ this.options = {
84
+ ...options,
85
+ applyVolumeAsFilter: options.applyVolumeAsFilter ?? false,
86
+ selfMute: options.selfMute ?? false,
87
+ selfDeafen: options.selfDeafen ?? false,
88
+ volume: options.volume ?? 100,
89
+ };
83
90
  // Set the guild ID and voice state.
84
91
  this.guildId = options.guildId;
85
92
  this.voiceState = Object.assign({
@@ -112,7 +119,7 @@ class Player {
112
119
  // Add the player to the manager's player collection.
113
120
  this.manager.players.set(options.guildId, this);
114
121
  // Set the initial volume.
115
- this.setVolume(options.volume ?? 100);
122
+ this.setVolume(options.volume);
116
123
  // Initialize the filters.
117
124
  this.filters = new Filters_1.Filters(this, this.manager);
118
125
  // Emit the playerCreate event.
@@ -416,9 +423,10 @@ class Player {
416
423
  throw new RangeError("Volume must be between 0 and 1000.");
417
424
  const oldVolume = this.volume;
418
425
  const oldPlayer = { ...this };
426
+ const data = this.options.applyVolumeAsFilter ? { filters: { volume } } : { volume };
419
427
  await this.node.rest.updatePlayer({
420
428
  guildId: this.options.guildId,
421
- data: { volume },
429
+ data,
422
430
  });
423
431
  this.volume = volume;
424
432
  this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this, {
@@ -853,6 +861,7 @@ class Player {
853
861
  filters: this.filters,
854
862
  nowPlayingMessage: this.nowPlayingMessage,
855
863
  isAutoplay: this.isAutoplay,
864
+ applyVolumeAsFilter: this.options.applyVolumeAsFilter,
856
865
  };
857
866
  // If force is true, destroy the existing player for the new guild
858
867
  if (force && newPlayer) {
@@ -862,6 +871,7 @@ class Player {
862
871
  newOptions.selfDeafen = newOptions.selfDeafen ?? oldPlayerProperties.selfDeafen;
863
872
  newOptions.selfMute = newOptions.selfMute ?? oldPlayerProperties.selfMute;
864
873
  newOptions.volume = newOptions.volume ?? oldPlayerProperties.volume;
874
+ newOptions.applyVolumeAsFilter = newOptions.applyVolumeAsFilter ?? oldPlayerProperties.applyVolumeAsFilter;
865
875
  // Deep clone the current player
866
876
  const clonedPlayer = this.manager.create(newOptions);
867
877
  // Connect the cloned player to the new voice channel
@@ -11,8 +11,8 @@ function playerCheck(options) {
11
11
  if (!options) {
12
12
  throw new TypeError("PlayerOptions must not be empty.");
13
13
  }
14
- // Get the guild ID, node, selfDeafen, selfMute, textChannelId, voiceChannelId, and volume from the options.
15
- const { guildId, nodeIdentifier, selfDeafen, selfMute, textChannelId, voiceChannelId, volume } = options;
14
+ // Get the guild ID, node, selfDeafen, selfMute, textChannelId, voiceChannelId, volume, and applyVolumeAsFilter from the options.
15
+ const { guildId, nodeIdentifier, selfDeafen, selfMute, textChannelId, voiceChannelId, volume, applyVolumeAsFilter } = options;
16
16
  // Validate the guild ID option
17
17
  // The guild ID option must be a non-empty string.
18
18
  if (!/^\d+$/.test(guildId)) {
@@ -48,4 +48,9 @@ function playerCheck(options) {
48
48
  if (typeof volume !== "undefined" && typeof volume !== "number") {
49
49
  throw new TypeError('Player option "volume" must be a number.');
50
50
  }
51
+ // Validate the applyVolumeAsFilter option
52
+ // The applyVolumeAsFilter option must be a boolean.
53
+ if (typeof applyVolumeAsFilter !== "undefined" && typeof applyVolumeAsFilter !== "boolean") {
54
+ throw new TypeError('Player option "applyVolumeAsFilter" must be a boolean.');
55
+ }
51
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.1-dev.5",
3
+ "version": "2.9.1-dev.6",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",