magmastream 2.9.3-dev.3 → 2.9.3-dev.30
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/config/blockedWords.d.ts +1 -0
- package/dist/index.d.ts +19 -3687
- package/dist/index.js +1 -1
- package/dist/statestorage/JsonQueue.d.ts +173 -0
- package/dist/statestorage/JsonQueue.js +32 -4
- package/dist/statestorage/MemoryQueue.d.ts +154 -0
- package/dist/statestorage/MemoryQueue.js +56 -36
- package/dist/statestorage/RedisQueue.d.ts +178 -0
- package/dist/statestorage/RedisQueue.js +29 -7
- package/dist/structures/Enums.d.ts +310 -0
- package/dist/structures/Enums.js +6 -0
- package/dist/structures/Filters.d.ts +352 -0
- package/dist/structures/Filters.js +5 -4
- package/dist/structures/MagmastreamError.d.ts +14 -0
- package/dist/structures/Manager.d.ts +259 -0
- package/dist/structures/Manager.js +297 -555
- package/dist/structures/Node.d.ts +390 -0
- package/dist/structures/Node.js +98 -143
- package/dist/structures/Player.d.ts +347 -0
- package/dist/structures/Player.js +53 -127
- package/dist/structures/Plugin.d.ts +23 -0
- package/dist/structures/Rest.d.ts +93 -0
- package/dist/structures/Rest.js +41 -21
- package/dist/structures/Types.d.ts +1315 -0
- package/dist/structures/Utils.d.ts +169 -0
- package/dist/structures/Utils.js +145 -71
- package/dist/utils/filtersEqualizers.d.ts +16 -0
- package/dist/utils/managerCheck.d.ts +7 -0
- package/dist/utils/nodeCheck.d.ts +7 -0
- package/dist/utils/playerCheck.d.ts +7 -0
- package/dist/wrappers/discord.js.d.ts +15 -0
- package/dist/wrappers/discord.js.js +19 -4
- package/dist/wrappers/discordeno.d.ts +19 -0
- package/dist/wrappers/discordeno.js +77 -0
- package/dist/wrappers/eris.d.ts +15 -0
- package/dist/wrappers/eris.js +20 -3
- package/dist/wrappers/oceanic.d.ts +15 -0
- package/dist/wrappers/oceanic.js +22 -4
- package/dist/wrappers/seyfert.d.ts +37 -0
- package/dist/wrappers/seyfert.js +25 -1
- package/package.json +106 -98
- package/dist/wrappers/detritus.js +0 -52
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { Band } from "../utils/filtersEqualizers";
|
|
2
|
+
import { AvailableFilters } from "./Enums";
|
|
3
|
+
import { Manager } from "./Manager";
|
|
4
|
+
import { Player } from "./Player";
|
|
5
|
+
import { DistortionOptions, KaraokeOptions, ReverbOptions, RotationOptions, TimescaleOptions, VibratoOptions } from "./Types";
|
|
6
|
+
export declare class Filters {
|
|
7
|
+
distortion: DistortionOptions | null;
|
|
8
|
+
equalizer: Band[];
|
|
9
|
+
karaoke: KaraokeOptions | null;
|
|
10
|
+
rotation: RotationOptions | null;
|
|
11
|
+
timescale: TimescaleOptions | null;
|
|
12
|
+
vibrato: VibratoOptions | null;
|
|
13
|
+
reverb: ReverbOptions | null;
|
|
14
|
+
volume: number;
|
|
15
|
+
bassBoostlevel: number;
|
|
16
|
+
filtersStatus: Record<AvailableFilters, boolean>;
|
|
17
|
+
manager: Manager;
|
|
18
|
+
player: Player;
|
|
19
|
+
constructor(player: Player, manager: Manager);
|
|
20
|
+
/**
|
|
21
|
+
* Updates the player's audio filters.
|
|
22
|
+
*
|
|
23
|
+
* This method sends a request to the player's node to update the filter settings
|
|
24
|
+
* based on the current properties of the `Filters` instance. The filters include
|
|
25
|
+
* distortion, equalizer, karaoke, rotation, timescale, vibrato, and volume. Once
|
|
26
|
+
* the request is sent, it ensures that the player's audio output reflects the
|
|
27
|
+
* changes in filter settings.
|
|
28
|
+
*
|
|
29
|
+
* @returns {Promise<this>} - Returns a promise that resolves to the current instance
|
|
30
|
+
* of the Filters class for method chaining.
|
|
31
|
+
*/
|
|
32
|
+
updateFilters(): Promise<this>;
|
|
33
|
+
/**
|
|
34
|
+
* Applies a specific filter to the player.
|
|
35
|
+
*
|
|
36
|
+
* This method allows you to set the value of a specific filter property.
|
|
37
|
+
* The filter property must be a valid key of the Filters object.
|
|
38
|
+
*
|
|
39
|
+
* @param {{ property: T; value: Filters[T] }} filter - An object containing the filter property and value.
|
|
40
|
+
* @param {boolean} [updateFilters=true] - Whether to update the filters after applying the filter.
|
|
41
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
42
|
+
*/
|
|
43
|
+
private applyFilter;
|
|
44
|
+
private emitPlayersTasteUpdate;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the status of a specific filter.
|
|
47
|
+
*
|
|
48
|
+
* This method updates the filter status to either true or false, indicating whether
|
|
49
|
+
* the filter is applied or not. This helps track which filters are active.
|
|
50
|
+
*
|
|
51
|
+
* @param {AvailableFilters} filter - The filter to update.
|
|
52
|
+
* @param {boolean} status - The status to set (true for active, false for inactive).
|
|
53
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining.
|
|
54
|
+
*/
|
|
55
|
+
private setFilterStatus;
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves the status of a specific filter.
|
|
58
|
+
*
|
|
59
|
+
* This method returns whether a specific filter is currently applied or not.
|
|
60
|
+
*
|
|
61
|
+
* @param {AvailableFilters} filter - The filter to check.
|
|
62
|
+
* @returns {boolean} - Returns true if the filter is active, false otherwise.
|
|
63
|
+
*/
|
|
64
|
+
getFilterStatus(filter: AvailableFilters): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Clears all filters applied to the audio.
|
|
67
|
+
*
|
|
68
|
+
* This method resets all filter settings to their default values and removes any
|
|
69
|
+
* active filters from the player.
|
|
70
|
+
*
|
|
71
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining.
|
|
72
|
+
*/
|
|
73
|
+
clearFilters(): Promise<this>;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the own equalizer bands on the audio.
|
|
76
|
+
*
|
|
77
|
+
* This method adjusts the equalization curve of the player's audio output,
|
|
78
|
+
* allowing you to control the frequency response.
|
|
79
|
+
*
|
|
80
|
+
* @param {Band[]} [bands] - The equalizer bands to apply (band, gain).
|
|
81
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
82
|
+
*/
|
|
83
|
+
setEqualizer(bands?: Band[]): Promise<this>;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the own karaoke options to the audio.
|
|
86
|
+
*
|
|
87
|
+
* This method adjusts the audio so that it sounds like a karaoke song, with the
|
|
88
|
+
* original vocals removed. Note that not all songs can be successfully made into
|
|
89
|
+
* karaoke tracks, and some tracks may not sound as good.
|
|
90
|
+
*
|
|
91
|
+
* @param {KaraokeOptions} [karaoke] - The karaoke settings to apply (level, monoLevel, filterBand, filterWidth).
|
|
92
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
93
|
+
*/
|
|
94
|
+
setKaraoke(karaoke?: KaraokeOptions): Promise<this>;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the own timescale options to the audio.
|
|
97
|
+
*
|
|
98
|
+
* This method adjusts the speed and pitch of the audio, allowing you to control the playback speed.
|
|
99
|
+
*
|
|
100
|
+
* @param {TimescaleOptions} [timescale] - The timescale settings to apply (speed and pitch).
|
|
101
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
102
|
+
*/
|
|
103
|
+
setTimescale(timescale?: TimescaleOptions): Promise<this>;
|
|
104
|
+
/**
|
|
105
|
+
* Sets the own vibrato options to the audio.
|
|
106
|
+
*
|
|
107
|
+
* This method applies a vibrato effect to the audio, which adds a wavering,
|
|
108
|
+
* pulsing quality to the sound. The effect is created by rapidly varying the
|
|
109
|
+
* pitch of the audio.
|
|
110
|
+
*
|
|
111
|
+
* @param {VibratoOptions} [vibrato] - The vibrato settings to apply (frequency, depth).
|
|
112
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
113
|
+
*/
|
|
114
|
+
setVibrato(vibrato?: VibratoOptions): Promise<this>;
|
|
115
|
+
/**
|
|
116
|
+
* Sets the own rotation options effect to the audio.
|
|
117
|
+
*
|
|
118
|
+
* This method applies a rotation effect to the audio, which simulates the sound
|
|
119
|
+
* moving around the listener's head. This effect can create a dynamic and immersive
|
|
120
|
+
* audio experience by altering the directionality of the sound.
|
|
121
|
+
*
|
|
122
|
+
* @param {RotationOptions} [rotation] - The rotation settings to apply (rotationHz).
|
|
123
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
124
|
+
*/
|
|
125
|
+
setRotation(rotation?: RotationOptions): Promise<this>;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the own distortion options effect to the audio.
|
|
128
|
+
*
|
|
129
|
+
* This method applies a distortion effect to the audio, which adds a rougher,
|
|
130
|
+
* more intense quality to the sound. The effect is created by altering the
|
|
131
|
+
* audio signal to create a more jagged, irregular waveform.
|
|
132
|
+
*
|
|
133
|
+
* @param {DistortionOptions} [distortion] - The distortion settings to apply (sinOffset, sinScale, cosOffset, cosScale, tanOffset, tanScale, offset, scale).
|
|
134
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
135
|
+
*/
|
|
136
|
+
setDistortion(distortion?: DistortionOptions): Promise<this>;
|
|
137
|
+
/**
|
|
138
|
+
* Sets the bass boost level on the audio.
|
|
139
|
+
*
|
|
140
|
+
* This method scales the gain of a predefined equalizer curve to the specified level.
|
|
141
|
+
* The curve is designed to emphasize or reduce low frequencies, creating a bass-heavy
|
|
142
|
+
* or bass-reduced effect.
|
|
143
|
+
*
|
|
144
|
+
* @param {number} level - The level of bass boost to apply. The value ranges from -3 to 3,
|
|
145
|
+
* where negative values reduce bass, 0 disables the effect,
|
|
146
|
+
* and positive values increase bass.
|
|
147
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* // Apply different levels of bass boost or reduction:
|
|
151
|
+
* await player.bassBoost(3); // Maximum Bass Boost
|
|
152
|
+
* await player.bassBoost(2); // Medium Bass Boost
|
|
153
|
+
* await player.bassBoost(1); // Mild Bass Boost
|
|
154
|
+
* await player.bassBoost(0); // No Effect (Disabled)
|
|
155
|
+
* await player.bassBoost(-1); // Mild Bass Reduction
|
|
156
|
+
* await player.bassBoost(-2); // Medium Bass Reduction
|
|
157
|
+
* await player.bassBoost(-3); // Maximum Bass Removal
|
|
158
|
+
*/
|
|
159
|
+
bassBoost(stage: number): Promise<this>;
|
|
160
|
+
/**
|
|
161
|
+
* Toggles the chipmunk effect on the audio.
|
|
162
|
+
*
|
|
163
|
+
* This method applies or removes a chipmunk effect by adjusting the timescale settings.
|
|
164
|
+
* When enabled, it increases the speed, pitch, and rate of the audio, resulting in a high-pitched, fast playback
|
|
165
|
+
* similar to the sound of a chipmunk.
|
|
166
|
+
*
|
|
167
|
+
* @param {boolean} status - Whether to enable or disable the chipmunk effect.
|
|
168
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
169
|
+
*/
|
|
170
|
+
chipmunk(status: boolean): Promise<this>;
|
|
171
|
+
/**
|
|
172
|
+
* Toggles the "China" effect on the audio.
|
|
173
|
+
*
|
|
174
|
+
* This method applies or removes a filter that reduces the pitch of the audio by half,
|
|
175
|
+
* without changing the speed or rate. This creates a "hollow" or "echoey" sound.
|
|
176
|
+
*
|
|
177
|
+
* @param {boolean} status - Whether to enable or disable the "China" effect.
|
|
178
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
179
|
+
*/
|
|
180
|
+
china(status: boolean): Promise<this>;
|
|
181
|
+
/**
|
|
182
|
+
* Toggles the 8D audio effect on the audio.
|
|
183
|
+
*
|
|
184
|
+
* This method applies or removes an 8D audio effect by adjusting the rotation settings.
|
|
185
|
+
* When enabled, it creates a sensation of the audio moving around the listener's head,
|
|
186
|
+
* providing an immersive audio experience.
|
|
187
|
+
*
|
|
188
|
+
* @param {boolean} status - Whether to enable or disable the 8D effect.
|
|
189
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
190
|
+
*/
|
|
191
|
+
eightD(status: boolean): Promise<this>;
|
|
192
|
+
/**
|
|
193
|
+
* Toggles the nightcore effect on the audio.
|
|
194
|
+
*
|
|
195
|
+
* This method applies or removes a nightcore effect by adjusting the timescale settings.
|
|
196
|
+
* When enabled, it increases the speed and pitch of the audio, giving it a more
|
|
197
|
+
* upbeat and energetic feel.
|
|
198
|
+
*
|
|
199
|
+
* @param {boolean} status - Whether to enable or disable the nightcore effect.
|
|
200
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
201
|
+
*/
|
|
202
|
+
nightcore(status: boolean): Promise<this>;
|
|
203
|
+
/**
|
|
204
|
+
* Toggles the slowmo effect on the audio.
|
|
205
|
+
*
|
|
206
|
+
* This method applies or removes a slowmo effect by adjusting the timescale settings.
|
|
207
|
+
* When enabled, it slows down the audio while keeping the pitch the same, giving it
|
|
208
|
+
* a more relaxed and calming feel.
|
|
209
|
+
*
|
|
210
|
+
* @param {boolean} status - Whether to enable or disable the slowmo effect.
|
|
211
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
212
|
+
*/
|
|
213
|
+
slowmo(status: boolean): Promise<this>;
|
|
214
|
+
/**
|
|
215
|
+
* Toggles a soft equalizer effect to the audio.
|
|
216
|
+
*
|
|
217
|
+
* This method applies or removes a soft equalizer effect by adjusting the equalizer settings.
|
|
218
|
+
* When enabled, it reduces the bass and treble frequencies, giving the audio a softer and more
|
|
219
|
+
* mellow sound.
|
|
220
|
+
*
|
|
221
|
+
* @param {boolean} status - Whether to enable or disable the soft equalizer effect.
|
|
222
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
223
|
+
*/
|
|
224
|
+
soft(status: boolean): Promise<this>;
|
|
225
|
+
/**
|
|
226
|
+
* Toggles the TV equalizer effect on the audio.
|
|
227
|
+
*
|
|
228
|
+
* This method applies or removes a TV equalizer effect by adjusting the equalizer settings.
|
|
229
|
+
* When enabled, it enhances specific frequency bands to mimic the audio characteristics
|
|
230
|
+
* typically found in television audio outputs.
|
|
231
|
+
*
|
|
232
|
+
* @param {boolean} status - Whether to enable or disable the TV equalizer effect.
|
|
233
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
234
|
+
*/
|
|
235
|
+
tv(status: boolean): Promise<this>;
|
|
236
|
+
/**
|
|
237
|
+
* Toggles the treble/bass equalizer effect on the audio.
|
|
238
|
+
*
|
|
239
|
+
* This method applies or removes a treble/bass equalizer effect by adjusting the equalizer settings.
|
|
240
|
+
* When enabled, it enhances the treble and bass frequencies, giving the audio a more balanced sound.
|
|
241
|
+
*
|
|
242
|
+
* @param {boolean} status - Whether to enable or disable the treble/bass equalizer effect.
|
|
243
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
244
|
+
*/
|
|
245
|
+
trebleBass(status: boolean): Promise<this>;
|
|
246
|
+
/**
|
|
247
|
+
* Toggles the vaporwave effect on the audio.
|
|
248
|
+
*
|
|
249
|
+
* This method applies or removes a vaporwave effect by adjusting the equalizer settings.
|
|
250
|
+
* When enabled, it gives the audio a dreamy and nostalgic feel, characteristic of the vaporwave genre.
|
|
251
|
+
*
|
|
252
|
+
* @param {boolean} status - Whether to enable or disable the vaporwave effect.
|
|
253
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
254
|
+
*/
|
|
255
|
+
vaporwave(status: boolean): Promise<this>;
|
|
256
|
+
/**
|
|
257
|
+
* Toggles the distortion effect on the audio.
|
|
258
|
+
*
|
|
259
|
+
* This method applies or removes a distortion effect by adjusting the distortion settings.
|
|
260
|
+
* When enabled, it adds a rougher, more intense quality to the sound by altering the
|
|
261
|
+
* audio signal to create a more jagged, irregular waveform.
|
|
262
|
+
*
|
|
263
|
+
* @param {boolean} status - Whether to enable or disable the distortion effect.
|
|
264
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
265
|
+
*/
|
|
266
|
+
distort(status: boolean): Promise<this>;
|
|
267
|
+
/**
|
|
268
|
+
* Toggles the party effect on the audio.
|
|
269
|
+
*
|
|
270
|
+
* This method applies or removes a party effect by adjusting the equalizer settings.
|
|
271
|
+
* When enabled, it enhances the bass and treble frequencies, providing a more energetic and lively sound.
|
|
272
|
+
*
|
|
273
|
+
* @param {boolean} status - Whether to enable or disable the party effect.
|
|
274
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
275
|
+
*/
|
|
276
|
+
pop(status: boolean): Promise<this>;
|
|
277
|
+
/**
|
|
278
|
+
* Toggles a party effect on the audio.
|
|
279
|
+
*
|
|
280
|
+
* This method applies a party effect to audio.
|
|
281
|
+
* @param {boolean} status - Whether to enable or disable the party effect.
|
|
282
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
283
|
+
*/
|
|
284
|
+
party(status: boolean): Promise<this>;
|
|
285
|
+
/**
|
|
286
|
+
* Toggles earrape effect on the audio.
|
|
287
|
+
*
|
|
288
|
+
* This method applies earrape effect to audio.
|
|
289
|
+
* @param {boolean} status - Whether to enable or disable the earrape effect.
|
|
290
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
291
|
+
*/
|
|
292
|
+
earrape(status: boolean): Promise<this>;
|
|
293
|
+
/**
|
|
294
|
+
* Toggles electronic effect on the audio.
|
|
295
|
+
*
|
|
296
|
+
* This method applies electronic effect to audio.
|
|
297
|
+
* @param {boolean} status - Whether to enable or disable the electronic effect.
|
|
298
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
299
|
+
*/
|
|
300
|
+
electronic(status: boolean): Promise<this>;
|
|
301
|
+
/**
|
|
302
|
+
* Toggles radio effect on the audio.
|
|
303
|
+
*
|
|
304
|
+
* This method applies radio effect to audio.
|
|
305
|
+
* @param {boolean} status - Whether to enable or disable the radio effect.
|
|
306
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
307
|
+
*/
|
|
308
|
+
radio(status: boolean): Promise<this>;
|
|
309
|
+
/**
|
|
310
|
+
* Toggles a tremolo effect on the audio.
|
|
311
|
+
*
|
|
312
|
+
* This method applies a tremolo effect to audio.
|
|
313
|
+
* @param {boolean} status - Whether to enable or disable the tremolo effect.
|
|
314
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining.
|
|
315
|
+
*/
|
|
316
|
+
tremolo(status: boolean): Promise<this>;
|
|
317
|
+
/**
|
|
318
|
+
* Toggless a darthvader effect on the audio.
|
|
319
|
+
*
|
|
320
|
+
* This method applies a darthvader effect to audio.
|
|
321
|
+
* @param {boolean} status - Whether to enable or disable the darthvader effect.
|
|
322
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining.
|
|
323
|
+
*/
|
|
324
|
+
darthvader(status: boolean): Promise<this>;
|
|
325
|
+
/**
|
|
326
|
+
* Toggles a daycore effect on the audio.
|
|
327
|
+
*
|
|
328
|
+
* This method applies a daycore effect to audio.
|
|
329
|
+
* @param {boolean} status - Whether to enable or disable the daycore effect.
|
|
330
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining.
|
|
331
|
+
*/
|
|
332
|
+
daycore(status: boolean): Promise<this>;
|
|
333
|
+
/**
|
|
334
|
+
* Toggles a doubletime effect on the audio.
|
|
335
|
+
*
|
|
336
|
+
* This method applies a doubletime effect to audio.
|
|
337
|
+
* @param {boolean} status - Whether to enable or disable the doubletime effect.
|
|
338
|
+
* @returns {this} - Returns the current instance of the Filters class for method chaining
|
|
339
|
+
*/
|
|
340
|
+
doubletime(status: boolean): Promise<this>;
|
|
341
|
+
/**
|
|
342
|
+
* Toggles the demon effect on the audio.
|
|
343
|
+
*
|
|
344
|
+
* This method applies or removes a demon effect by adjusting the equalizer,
|
|
345
|
+
* timescale, and reverb settings. When enabled, it creates a deeper and more
|
|
346
|
+
* intense sound by lowering the pitch and adding reverb to the audio.
|
|
347
|
+
*
|
|
348
|
+
* @param {boolean} status - Whether to enable or disable the demon effect.
|
|
349
|
+
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
350
|
+
*/
|
|
351
|
+
demon(status: boolean): Promise<this>;
|
|
352
|
+
}
|
|
@@ -8,8 +8,6 @@ class Filters {
|
|
|
8
8
|
distortion;
|
|
9
9
|
equalizer;
|
|
10
10
|
karaoke;
|
|
11
|
-
manager;
|
|
12
|
-
player;
|
|
13
11
|
rotation;
|
|
14
12
|
timescale;
|
|
15
13
|
vibrato;
|
|
@@ -17,15 +15,16 @@ class Filters {
|
|
|
17
15
|
volume;
|
|
18
16
|
bassBoostlevel;
|
|
19
17
|
filtersStatus;
|
|
18
|
+
manager;
|
|
19
|
+
player;
|
|
20
20
|
constructor(player, manager) {
|
|
21
21
|
this.distortion = null;
|
|
22
22
|
this.equalizer = [];
|
|
23
23
|
this.karaoke = null;
|
|
24
|
-
this.manager = manager;
|
|
25
|
-
this.player = player;
|
|
26
24
|
this.rotation = null;
|
|
27
25
|
this.timescale = null;
|
|
28
26
|
this.vibrato = null;
|
|
27
|
+
this.reverb = null;
|
|
29
28
|
this.volume = 1.0;
|
|
30
29
|
this.bassBoostlevel = 0;
|
|
31
30
|
// Initialize filter status
|
|
@@ -33,6 +32,8 @@ class Filters {
|
|
|
33
32
|
acc[filter] = false;
|
|
34
33
|
return acc;
|
|
35
34
|
}, {});
|
|
35
|
+
this.manager = manager;
|
|
36
|
+
this.player = player;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Updates the player's audio filters.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MagmaStreamErrorCode } from "./Enums";
|
|
2
|
+
interface MagmaStreamErrorOptions<T = unknown> {
|
|
3
|
+
code: MagmaStreamErrorCode;
|
|
4
|
+
message?: string;
|
|
5
|
+
cause?: Error;
|
|
6
|
+
context?: T;
|
|
7
|
+
}
|
|
8
|
+
export declare class MagmaStreamError<T = unknown> extends Error {
|
|
9
|
+
readonly code: MagmaStreamErrorCode;
|
|
10
|
+
readonly number: number;
|
|
11
|
+
readonly context?: T;
|
|
12
|
+
constructor({ code, message, cause, context }: MagmaStreamErrorOptions<T>);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { Collection } from "@discordjs/collection";
|
|
2
|
+
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import { Node } from "./Node";
|
|
5
|
+
import { Player } from "./Player";
|
|
6
|
+
import { Redis as RedisClient } from "ioredis";
|
|
7
|
+
import { AnyGuild, AnyUser, ManagerEvents, ManagerInitOptions, ManagerOptions, NodeOptions, PlayerOptions, SearchQuery, SearchResult, TrackData, VoicePacket, VoiceServer, VoiceState } from "./Types";
|
|
8
|
+
/**
|
|
9
|
+
* The main hub for interacting with Lavalink and using Magmastream.
|
|
10
|
+
*/
|
|
11
|
+
export declare class Manager extends EventEmitter {
|
|
12
|
+
/** The map of players. */
|
|
13
|
+
readonly players: Collection<string, Player>;
|
|
14
|
+
/** The map of nodes. */
|
|
15
|
+
readonly nodes: Collection<string, Node>;
|
|
16
|
+
/** The options that were set. */
|
|
17
|
+
readonly options: ManagerOptions;
|
|
18
|
+
initiated: boolean;
|
|
19
|
+
redis?: RedisClient;
|
|
20
|
+
private _send;
|
|
21
|
+
private _getUser?;
|
|
22
|
+
private _getGuild?;
|
|
23
|
+
private loadedPlugins;
|
|
24
|
+
/**
|
|
25
|
+
* Initiates the Manager class.
|
|
26
|
+
* @param options
|
|
27
|
+
* @param options.enabledPlugins - An array of enabledPlugins to load.
|
|
28
|
+
* @param options.nodes - An array of node options to create nodes from.
|
|
29
|
+
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
30
|
+
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
31
|
+
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
32
|
+
* @param options.clientName - The name of the client to send to Lavalink.
|
|
33
|
+
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
34
|
+
* @param options.useNode - The strategy to use when selecting a node to play on.
|
|
35
|
+
* @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
|
|
36
|
+
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
37
|
+
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
38
|
+
*/
|
|
39
|
+
constructor(options: ManagerOptions);
|
|
40
|
+
/**
|
|
41
|
+
* Initiates the Manager.
|
|
42
|
+
* @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
|
|
43
|
+
* @param clusterId - The cluster ID which runs the current process (required).
|
|
44
|
+
* @returns The manager instance.
|
|
45
|
+
*/
|
|
46
|
+
init(options?: ManagerInitOptions): Promise<this>;
|
|
47
|
+
/**
|
|
48
|
+
* Searches the enabled sources based off the URL or the `source` property.
|
|
49
|
+
* @param query
|
|
50
|
+
* @param requester
|
|
51
|
+
* @returns The search result.
|
|
52
|
+
*/
|
|
53
|
+
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a player or undefined if it does not exist.
|
|
56
|
+
* @param guildId The guild ID of the player to retrieve.
|
|
57
|
+
* @returns The player if it exists, undefined otherwise.
|
|
58
|
+
*/
|
|
59
|
+
getPlayer(guildId: string): Player | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a player or returns one if it already exists.
|
|
62
|
+
* @param options The options to create the player with.
|
|
63
|
+
* @returns The created player.
|
|
64
|
+
*/
|
|
65
|
+
create(options: PlayerOptions): Player;
|
|
66
|
+
/**
|
|
67
|
+
* Destroys a player.
|
|
68
|
+
* @param guildId The guild ID of the player to destroy.
|
|
69
|
+
* @returns A promise that resolves when the player has been destroyed.
|
|
70
|
+
*/
|
|
71
|
+
destroy(guildId: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new node or returns an existing one if it already exists.
|
|
74
|
+
* @param options - The options to create the node with.
|
|
75
|
+
* @returns The created node.
|
|
76
|
+
*/
|
|
77
|
+
createNode(options: NodeOptions): Node;
|
|
78
|
+
/**
|
|
79
|
+
* Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
|
|
80
|
+
* @param identifier - The identifier of the node to destroy.
|
|
81
|
+
* @returns {void}
|
|
82
|
+
* @emits {debug} - Emits a debug message indicating the node is being destroyed.
|
|
83
|
+
*/
|
|
84
|
+
destroyNode(identifier: string): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Attaches an event listener to the manager.
|
|
87
|
+
* @param event The event to listen for.
|
|
88
|
+
* @param listener The function to call when the event is emitted.
|
|
89
|
+
* @returns The manager instance for chaining.
|
|
90
|
+
*/
|
|
91
|
+
on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this;
|
|
92
|
+
/**
|
|
93
|
+
* Updates the voice state of a player based on the provided data.
|
|
94
|
+
* @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
95
|
+
* @returns A promise that resolves when the voice state update is handled.
|
|
96
|
+
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
97
|
+
*/
|
|
98
|
+
updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Decodes an array of base64 encoded tracks and returns an array of TrackData.
|
|
101
|
+
* Emits a debug event with the tracks being decoded.
|
|
102
|
+
* @param tracks - An array of base64 encoded track strings.
|
|
103
|
+
* @returns A promise that resolves to an array of TrackData objects.
|
|
104
|
+
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
105
|
+
*/
|
|
106
|
+
decodeTracks(tracks: string[]): Promise<TrackData[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Decodes a base64 encoded track and returns a TrackData.
|
|
109
|
+
* @param track - The base64 encoded track string.
|
|
110
|
+
* @returns A promise that resolves to a TrackData object.
|
|
111
|
+
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
112
|
+
*/
|
|
113
|
+
decodeTrack(track: string): Promise<TrackData>;
|
|
114
|
+
/**
|
|
115
|
+
* Saves player states.
|
|
116
|
+
* @param {string} guildId - The guild ID of the player to save
|
|
117
|
+
*/
|
|
118
|
+
savePlayerState(guildId: string): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Sleeps for a specified amount of time.
|
|
121
|
+
* @param ms The amount of time to sleep in milliseconds.
|
|
122
|
+
* @returns A promise that resolves after the specified amount of time.
|
|
123
|
+
*/
|
|
124
|
+
private sleep;
|
|
125
|
+
private restorePlayerFromState;
|
|
126
|
+
private restoreQueue;
|
|
127
|
+
private restorePreviousQueue;
|
|
128
|
+
private restoreRepeatState;
|
|
129
|
+
private restorePlayerData;
|
|
130
|
+
private restoreFilters;
|
|
131
|
+
/**
|
|
132
|
+
* Loads player states from the JSON file.
|
|
133
|
+
* @param nodeId The ID of the node to load player states from.
|
|
134
|
+
* @returns A promise that resolves when the player states have been loaded.
|
|
135
|
+
*/
|
|
136
|
+
loadPlayerStates(nodeId: string): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
|
|
139
|
+
* If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option.
|
|
140
|
+
* If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen.
|
|
141
|
+
* If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen.
|
|
142
|
+
* @returns {Node} The node to use.
|
|
143
|
+
*/
|
|
144
|
+
get useableNode(): Node;
|
|
145
|
+
/**
|
|
146
|
+
* Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
|
|
147
|
+
* This function is called when the process is about to exit.
|
|
148
|
+
* It iterates through all players and calls {@link savePlayerState} to save their states.
|
|
149
|
+
* Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
|
|
150
|
+
* After saving and cleaning up, it exits the process.
|
|
151
|
+
*/
|
|
152
|
+
handleShutdown(): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Parses a YouTube title into a clean title and author.
|
|
155
|
+
* @param title - The original title of the YouTube video.
|
|
156
|
+
* @param originalAuthor - The original author of the YouTube video.
|
|
157
|
+
* @returns An object with the clean title and author.
|
|
158
|
+
*/
|
|
159
|
+
private parseYouTubeTitle;
|
|
160
|
+
/**
|
|
161
|
+
* Balances brackets in a given string by ensuring all opened brackets are closed correctly.
|
|
162
|
+
* @param str - The input string that may contain unbalanced brackets.
|
|
163
|
+
* @returns A new string with balanced brackets.
|
|
164
|
+
*/
|
|
165
|
+
private balanceBrackets;
|
|
166
|
+
/**
|
|
167
|
+
* Escapes a string by replacing special regex characters with their escaped counterparts.
|
|
168
|
+
* @param string - The string to escape.
|
|
169
|
+
* @returns The escaped string.
|
|
170
|
+
*/
|
|
171
|
+
private escapeRegExp;
|
|
172
|
+
/**
|
|
173
|
+
* Checks if the given data is a voice update.
|
|
174
|
+
* @param data The data to check.
|
|
175
|
+
* @returns Whether the data is a voice update.
|
|
176
|
+
*/
|
|
177
|
+
private isVoiceUpdate;
|
|
178
|
+
/**
|
|
179
|
+
* Determines if the provided update is a valid voice update.
|
|
180
|
+
* A valid update must contain either a token or a session_id.
|
|
181
|
+
*
|
|
182
|
+
* @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
183
|
+
* @returns {boolean} - True if the update is valid, otherwise false.
|
|
184
|
+
*/
|
|
185
|
+
private isValidUpdate;
|
|
186
|
+
/**
|
|
187
|
+
* Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node.
|
|
188
|
+
* @param player The player for which the voice state is being updated.
|
|
189
|
+
* @param update The voice server data received from Discord.
|
|
190
|
+
* @returns A promise that resolves when the voice state update is handled.
|
|
191
|
+
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
192
|
+
*/
|
|
193
|
+
private handleVoiceServerUpdate;
|
|
194
|
+
/**
|
|
195
|
+
* Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null.
|
|
196
|
+
* @param player The player for which the voice state is being updated.
|
|
197
|
+
* @param update The voice state data received from Discord.
|
|
198
|
+
* @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel.
|
|
199
|
+
* @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null.
|
|
200
|
+
*/
|
|
201
|
+
private handleVoiceStateUpdate;
|
|
202
|
+
/**
|
|
203
|
+
* Cleans up an inactive player by removing its state data.
|
|
204
|
+
* This is done to prevent stale state data from accumulating.
|
|
205
|
+
* @param guildId The guild ID of the player to clean up.
|
|
206
|
+
*/
|
|
207
|
+
cleanupInactivePlayer(guildId: string): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Loads the enabled plugins.
|
|
210
|
+
*/
|
|
211
|
+
private loadPlugins;
|
|
212
|
+
/**
|
|
213
|
+
* Unloads the enabled plugins.
|
|
214
|
+
*/
|
|
215
|
+
private unloadPlugins;
|
|
216
|
+
/**
|
|
217
|
+
* Clears all player states from the file system.
|
|
218
|
+
* This is done to prevent stale state files from accumulating on the file system.
|
|
219
|
+
*/
|
|
220
|
+
private clearAllStoredPlayers;
|
|
221
|
+
/**
|
|
222
|
+
* Returns the nodes that has the least load.
|
|
223
|
+
* The load is calculated by dividing the lavalink load by the number of cores.
|
|
224
|
+
* The result is multiplied by 100 to get a percentage.
|
|
225
|
+
* @returns {Collection<string, Node>}
|
|
226
|
+
*/
|
|
227
|
+
private get leastLoadNode();
|
|
228
|
+
/**
|
|
229
|
+
* Returns the nodes that have the least amount of players.
|
|
230
|
+
* Filters out disconnected nodes and sorts the remaining nodes
|
|
231
|
+
* by the number of players in ascending order.
|
|
232
|
+
* @returns {Collection<string, Node>} A collection of nodes sorted by player count.
|
|
233
|
+
*/
|
|
234
|
+
private get leastPlayersNode();
|
|
235
|
+
/**
|
|
236
|
+
* Returns a node based on priority.
|
|
237
|
+
* The nodes are sorted by priority in descending order, and then a random number
|
|
238
|
+
* between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the
|
|
239
|
+
* random number is returned.
|
|
240
|
+
* If no node has a cumulative weight greater than or equal to the random number, the node with the
|
|
241
|
+
* lowest load is returned.
|
|
242
|
+
* @returns {Node} The node to use.
|
|
243
|
+
*/
|
|
244
|
+
private get priorityNode();
|
|
245
|
+
protected send(packet: GatewayVoiceStateUpdate): unknown;
|
|
246
|
+
protected getUserFromCache(id: string): AnyUser | undefined;
|
|
247
|
+
protected getGuildFromCache(id: string): AnyGuild | undefined;
|
|
248
|
+
sendPacket(packet: GatewayVoiceStateUpdate): unknown;
|
|
249
|
+
/**
|
|
250
|
+
* Resolves a PortableUser or ID to a real user object.
|
|
251
|
+
* Can be overridden by wrapper managers to return wrapper-specific User classes.
|
|
252
|
+
*/
|
|
253
|
+
resolveUser(user: AnyUser | string): Promise<AnyUser>;
|
|
254
|
+
/**
|
|
255
|
+
* Resolves a Guild ID to a real guild object.
|
|
256
|
+
* Can be overridden by wrapper managers to return wrapper-specific Guild classes.
|
|
257
|
+
*/
|
|
258
|
+
resolveGuild(guildId: string): AnyGuild;
|
|
259
|
+
}
|