magmastream 2.0.5 → 2.0.7

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
@@ -3,6 +3,14 @@ import WebSocket from 'ws';
3
3
  import { Collection } from '@discordjs/collection';
4
4
  import { EventEmitter } from 'events';
5
5
 
6
+ /** Represents an equalizer band. */
7
+ interface Band {
8
+ /** The index of the equalizer band. */
9
+ band: number;
10
+ /** The gain value of the equalizer band. */
11
+ gain: number;
12
+ }
13
+
6
14
  declare class Filters {
7
15
  distortion: distortionOptions;
8
16
  equalizer: Band[];
@@ -12,9 +20,11 @@ declare class Filters {
12
20
  timescale: timescaleOptions;
13
21
  vibrato: vibratoOptions;
14
22
  volume: number;
23
+ private filterStatus;
15
24
  constructor(player: Player);
16
25
  private updateFilters;
17
26
  private applyFilter;
27
+ private setFilterStatus;
18
28
  /**
19
29
  * Sets the equalizer bands and updates the filters.
20
30
  * @param bands - The equalizer bands.
@@ -48,8 +58,10 @@ declare class Filters {
48
58
  setRotation(rotation?: rotationOptions): this;
49
59
  /** Applies the distortion options specified by the filter. */
50
60
  setDistortion(distortion?: distortionOptions): this;
51
- /** Removes the audio effects. */
52
- clearFilters(): this;
61
+ /** Removes the audio effects and resets the filter status. */
62
+ clearFilters(): Promise<this>;
63
+ /** Returns the status of the specified filter . */
64
+ getFilterStatus(filter: keyof availableFilters): boolean;
53
65
  }
54
66
  /** Options for adjusting the timescale of audio. */
55
67
  interface timescaleOptions {
@@ -93,12 +105,17 @@ interface distortionOptions {
93
105
  offset?: number;
94
106
  scale?: number;
95
107
  }
96
- /** Represents an equalizer band. */
97
- interface Band {
98
- /** The index of the equalizer band. */
99
- band: number;
100
- /** The gain value of the equalizer band. */
101
- gain: number;
108
+ interface availableFilters {
109
+ bassboost: boolean;
110
+ distort: boolean;
111
+ eightD: boolean;
112
+ karaoke: boolean;
113
+ nightcore: boolean;
114
+ slowmo: boolean;
115
+ soft: boolean;
116
+ trebleBass: boolean;
117
+ tv: boolean;
118
+ vaporwave: boolean;
102
119
  }
103
120
 
104
121
  /**
@@ -353,9 +370,7 @@ interface NowPlayingMessage {
353
370
  /** The boolean indicating if the message has been deleted or not. */
354
371
  deleted?: boolean;
355
372
  /** The delete function. */
356
- delete: () => Promise<void>;
357
- /** The edit function. */
358
- edit: () => Promise<void>;
373
+ delete: () => Promise<any>;
359
374
  }
360
375
 
361
376
  /** Handles the requests sent to the Lavalink REST API. */
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Filters = void 0;
4
+ const filtersEqualizers_1 = require("../utils/filtersEqualizers");
4
5
  class Filters {
5
6
  distortion;
6
7
  equalizer;
@@ -10,6 +11,7 @@ class Filters {
10
11
  timescale;
11
12
  vibrato;
12
13
  volume;
14
+ filterStatus;
13
15
  constructor(player) {
14
16
  this.distortion = null;
15
17
  this.equalizer = [];
@@ -19,10 +21,23 @@ class Filters {
19
21
  this.timescale = null;
20
22
  this.vibrato = null;
21
23
  this.volume = 1.0;
22
- }
23
- updateFilters() {
24
+ // Initialize filter status
25
+ this.filterStatus = {
26
+ bassboost: false,
27
+ distort: false,
28
+ eightD: false,
29
+ karaoke: false,
30
+ nightcore: false,
31
+ slowmo: false,
32
+ soft: false,
33
+ trebleBass: false,
34
+ tv: false,
35
+ vaporwave: false,
36
+ };
37
+ }
38
+ async updateFilters() {
24
39
  const { distortion, equalizer, karaoke, rotation, timescale, vibrato, volume, } = this;
25
- this.player.node.rest.updatePlayer({
40
+ await this.player.node.rest.updatePlayer({
26
41
  data: {
27
42
  filters: {
28
43
  distortion,
@@ -45,6 +60,10 @@ class Filters {
45
60
  }
46
61
  return this;
47
62
  }
63
+ setFilterStatus(filter, status) {
64
+ this.filterStatus[filter] = status;
65
+ return this;
66
+ }
48
67
  /**
49
68
  * Sets the equalizer bands and updates the filters.
50
69
  * @param bands - The equalizer bands.
@@ -54,11 +73,11 @@ class Filters {
54
73
  }
55
74
  /** Applies the eight dimension audio effect. */
56
75
  eightD() {
57
- return this.setRotation({ rotationHz: 0.2 });
76
+ return this.setRotation({ rotationHz: 0.2 }).setFilterStatus("eightD", true);
58
77
  }
59
78
  /** Applies the bass boost effect. */
60
79
  bassBoost() {
61
- return this.setEqualizer(bassBoostEqualizer);
80
+ return this.setEqualizer(filtersEqualizers_1.bassBoostEqualizer).setFilterStatus("bassboost", true);
62
81
  }
63
82
  /** Applies the nightcore effect. */
64
83
  nightcore() {
@@ -66,7 +85,7 @@ class Filters {
66
85
  speed: 1.1,
67
86
  pitch: 1.125,
68
87
  rate: 1.05,
69
- });
88
+ }).setFilterStatus("nightcore", true);
70
89
  }
71
90
  /** Applies the slow motion audio effect. */
72
91
  slowmo() {
@@ -74,23 +93,25 @@ class Filters {
74
93
  speed: 0.7,
75
94
  pitch: 1.0,
76
95
  rate: 0.8,
77
- });
96
+ }).setFilterStatus("slowmo", true);
78
97
  }
79
98
  /** Applies the soft audio effect. */
80
99
  soft() {
81
- return this.setEqualizer(softEqualizer);
100
+ return this.setEqualizer(filtersEqualizers_1.softEqualizer).setFilterStatus("soft", true);
82
101
  }
83
102
  /** Applies the television audio effect. */
84
103
  tv() {
85
- return this.setEqualizer(tvEqualizer);
104
+ return this.setEqualizer(filtersEqualizers_1.tvEqualizer).setFilterStatus("tv", true);
86
105
  }
87
106
  /** Applies the treble bass effect. */
88
107
  trebleBass() {
89
- return this.setEqualizer(trebleBassEqualizer);
108
+ return this.setEqualizer(filtersEqualizers_1.trebleBassEqualizer).setFilterStatus("trebleBass", true);
90
109
  }
91
110
  /** Applies the vaporwave effect. */
92
111
  vaporwave() {
93
- return this.setEqualizer(vaporwaveEqualizer).setTimescale({ pitch: 0.55 });
112
+ return this.setEqualizer(filtersEqualizers_1.vaporwaveEqualizer)
113
+ .setTimescale({ pitch: 0.55 })
114
+ .setFilterStatus("vaporwave", true);
94
115
  }
95
116
  /** Applies the distortion audio effect. */
96
117
  distort() {
@@ -103,11 +124,14 @@ class Filters {
103
124
  tanScale: 0.2,
104
125
  offset: 0,
105
126
  scale: 1.2,
106
- });
127
+ }).setFilterStatus("distort", true);
107
128
  }
108
129
  /** Applies the karaoke options specified by the filter. */
109
130
  setKaraoke(karaoke) {
110
- return this.applyFilter({ property: "karaoke", value: karaoke });
131
+ return this.applyFilter({
132
+ property: "karaoke",
133
+ value: karaoke,
134
+ }).setFilterStatus("karaoke", true);
111
135
  }
112
136
  /** Applies the timescale options specified by the filter. */
113
137
  setTimescale(timescale) {
@@ -125,92 +149,28 @@ class Filters {
125
149
  setDistortion(distortion) {
126
150
  return this.applyFilter({ property: "distortion", value: distortion });
127
151
  }
128
- /** Removes the audio effects. */
129
- clearFilters() {
152
+ /** Removes the audio effects and resets the filter status. */
153
+ async clearFilters() {
130
154
  this.player.filters = new Filters(this.player);
131
- this.updateFilters();
155
+ await this.updateFilters();
156
+ // Reset filter status
157
+ this.filterStatus = {
158
+ bassboost: false,
159
+ distort: false,
160
+ eightD: false,
161
+ karaoke: false,
162
+ nightcore: false,
163
+ slowmo: false,
164
+ soft: false,
165
+ trebleBass: false,
166
+ tv: false,
167
+ vaporwave: false,
168
+ };
132
169
  return this;
133
170
  }
171
+ /** Returns the status of the specified filter . */
172
+ getFilterStatus(filter) {
173
+ return this.filterStatus[filter];
174
+ }
134
175
  }
135
176
  exports.Filters = Filters;
136
- const bassBoostEqualizer = [
137
- { band: 0, gain: 0.2 },
138
- { band: 1, gain: 0.15 },
139
- { band: 2, gain: 0.1 },
140
- { band: 3, gain: 0.05 },
141
- { band: 4, gain: 0.0 },
142
- { band: 5, gain: -0.05 },
143
- { band: 6, gain: -0.1 },
144
- { band: 7, gain: -0.1 },
145
- { band: 8, gain: -0.1 },
146
- { band: 9, gain: -0.1 },
147
- { band: 10, gain: -0.1 },
148
- { band: 11, gain: -0.1 },
149
- { band: 12, gain: -0.1 },
150
- { band: 13, gain: -0.1 },
151
- { band: 14, gain: -0.1 },
152
- ];
153
- const softEqualizer = [
154
- { band: 0, gain: 0 },
155
- { band: 1, gain: 0 },
156
- { band: 2, gain: 0 },
157
- { band: 3, gain: 0 },
158
- { band: 4, gain: 0 },
159
- { band: 5, gain: 0 },
160
- { band: 6, gain: 0 },
161
- { band: 7, gain: 0 },
162
- { band: 8, gain: -0.25 },
163
- { band: 9, gain: -0.25 },
164
- { band: 10, gain: -0.25 },
165
- { band: 11, gain: -0.25 },
166
- { band: 12, gain: -0.25 },
167
- { band: 13, gain: -0.25 },
168
- ];
169
- const tvEqualizer = [
170
- { band: 0, gain: 0 },
171
- { band: 1, gain: 0 },
172
- { band: 2, gain: 0 },
173
- { band: 3, gain: 0 },
174
- { band: 4, gain: 0 },
175
- { band: 5, gain: 0 },
176
- { band: 6, gain: 0 },
177
- { band: 7, gain: 0.65 },
178
- { band: 8, gain: 0.65 },
179
- { band: 9, gain: 0.65 },
180
- { band: 10, gain: 0.65 },
181
- { band: 11, gain: 0.65 },
182
- { band: 12, gain: 0.65 },
183
- { band: 13, gain: 0.65 },
184
- ];
185
- const trebleBassEqualizer = [
186
- { band: 0, gain: 0.6 },
187
- { band: 1, gain: 0.67 },
188
- { band: 2, gain: 0.67 },
189
- { band: 3, gain: 0 },
190
- { band: 4, gain: -0.5 },
191
- { band: 5, gain: 0.15 },
192
- { band: 6, gain: -0.45 },
193
- { band: 7, gain: 0.23 },
194
- { band: 8, gain: 0.35 },
195
- { band: 9, gain: 0.45 },
196
- { band: 10, gain: 0.55 },
197
- { band: 11, gain: 0.6 },
198
- { band: 12, gain: 0.55 },
199
- { band: 13, gain: 0 },
200
- ];
201
- const vaporwaveEqualizer = [
202
- { band: 0, gain: 0 },
203
- { band: 1, gain: 0 },
204
- { band: 2, gain: 0 },
205
- { band: 3, gain: 0 },
206
- { band: 4, gain: 0 },
207
- { band: 5, gain: 0 },
208
- { band: 6, gain: 0 },
209
- { band: 7, gain: 0 },
210
- { band: 8, gain: 0.15 },
211
- { band: 9, gain: 0.15 },
212
- { band: 10, gain: 0.15 },
213
- { band: 11, gain: 0.15 },
214
- { band: 12, gain: 0.15 },
215
- { band: 13, gain: 0.15 },
216
- ];
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vaporwaveEqualizer = exports.trebleBassEqualizer = exports.tvEqualizer = exports.softEqualizer = exports.bassBoostEqualizer = void 0;
4
+ exports.bassBoostEqualizer = [
5
+ { band: 0, gain: 0.2 },
6
+ { band: 1, gain: 0.15 },
7
+ { band: 2, gain: 0.1 },
8
+ { band: 3, gain: 0.05 },
9
+ { band: 4, gain: 0.0 },
10
+ { band: 5, gain: -0.05 },
11
+ { band: 6, gain: -0.1 },
12
+ { band: 7, gain: -0.1 },
13
+ { band: 8, gain: -0.1 },
14
+ { band: 9, gain: -0.1 },
15
+ { band: 10, gain: -0.1 },
16
+ { band: 11, gain: -0.1 },
17
+ { band: 12, gain: -0.1 },
18
+ { band: 13, gain: -0.1 },
19
+ { band: 14, gain: -0.1 },
20
+ ];
21
+ exports.softEqualizer = [
22
+ { band: 0, gain: 0 },
23
+ { band: 1, gain: 0 },
24
+ { band: 2, gain: 0 },
25
+ { band: 3, gain: 0 },
26
+ { band: 4, gain: 0 },
27
+ { band: 5, gain: 0 },
28
+ { band: 6, gain: 0 },
29
+ { band: 7, gain: 0 },
30
+ { band: 8, gain: -0.25 },
31
+ { band: 9, gain: -0.25 },
32
+ { band: 10, gain: -0.25 },
33
+ { band: 11, gain: -0.25 },
34
+ { band: 12, gain: -0.25 },
35
+ { band: 13, gain: -0.25 },
36
+ ];
37
+ exports.tvEqualizer = [
38
+ { band: 0, gain: 0 },
39
+ { band: 1, gain: 0 },
40
+ { band: 2, gain: 0 },
41
+ { band: 3, gain: 0 },
42
+ { band: 4, gain: 0 },
43
+ { band: 5, gain: 0 },
44
+ { band: 6, gain: 0 },
45
+ { band: 7, gain: 0.65 },
46
+ { band: 8, gain: 0.65 },
47
+ { band: 9, gain: 0.65 },
48
+ { band: 10, gain: 0.65 },
49
+ { band: 11, gain: 0.65 },
50
+ { band: 12, gain: 0.65 },
51
+ { band: 13, gain: 0.65 },
52
+ ];
53
+ exports.trebleBassEqualizer = [
54
+ { band: 0, gain: 0.6 },
55
+ { band: 1, gain: 0.67 },
56
+ { band: 2, gain: 0.67 },
57
+ { band: 3, gain: 0 },
58
+ { band: 4, gain: -0.5 },
59
+ { band: 5, gain: 0.15 },
60
+ { band: 6, gain: -0.45 },
61
+ { band: 7, gain: 0.23 },
62
+ { band: 8, gain: 0.35 },
63
+ { band: 9, gain: 0.45 },
64
+ { band: 10, gain: 0.55 },
65
+ { band: 11, gain: 0.6 },
66
+ { band: 12, gain: 0.55 },
67
+ { band: 13, gain: 0 },
68
+ ];
69
+ exports.vaporwaveEqualizer = [
70
+ { band: 0, gain: 0 },
71
+ { band: 1, gain: 0 },
72
+ { band: 2, gain: 0 },
73
+ { band: 3, gain: 0 },
74
+ { band: 4, gain: 0 },
75
+ { band: 5, gain: 0 },
76
+ { band: 6, gain: 0 },
77
+ { band: 7, gain: 0 },
78
+ { band: 8, gain: 0.15 },
79
+ { band: 9, gain: 0.15 },
80
+ { band: 10, gain: 0.15 },
81
+ { band: 11, gain: 0.15 },
82
+ { band: 12, gain: 0.15 },
83
+ { band: 13, gain: 0.15 },
84
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,9 +18,9 @@
18
18
  "@types/lodash": "^4.14.195",
19
19
  "@types/node": "^20.4.2",
20
20
  "@types/ws": "^8.5.3",
21
- "@typescript-eslint/eslint-plugin": "^6.0.0",
22
- "@typescript-eslint/parser": "^6.0.0",
23
- "eslint": "^8.23.1",
21
+ "@typescript-eslint/eslint-plugin": "^6.1.0",
22
+ "@typescript-eslint/parser": "^6.1.0",
23
+ "eslint": "^8.45.0",
24
24
  "npm-run-all": "^1.7.0",
25
25
  "typedoc": "^0.24.8",
26
26
  "typedoc-plugin-no-inherit": "^1.4.0",