magmastream 2.9.0-dev.46 → 2.9.0-dev.48
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 +1055 -1017
- package/dist/statestorage/JsonQueue.js +242 -236
- package/dist/statestorage/MemoryQueue.js +207 -202
- package/dist/statestorage/RedisQueue.js +230 -210
- package/dist/structures/Enums.js +4 -0
- package/dist/structures/Filters.js +149 -99
- package/dist/structures/Player.js +3 -4
- package/dist/structures/Utils.js +7 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Collection } from '@discordjs/collection';
|
|
|
2
2
|
import { GatewayVoiceStateUpdate } from 'discord-api-types/v10';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { User, ClientUser, Message, Client } from 'discord.js';
|
|
5
|
-
import WebSocket, { WebSocket
|
|
5
|
+
import WebSocket$1, { WebSocket } from 'ws';
|
|
6
6
|
import { Redis } from 'ioredis';
|
|
7
7
|
import { Client as Client$1 } from 'eris';
|
|
8
8
|
import { ClusterClient, ShardClient } from 'detritus-client';
|
|
@@ -98,7 +98,8 @@ declare enum PlayerStateEventTypes {
|
|
|
98
98
|
VolumeChange = "volumeChange",
|
|
99
99
|
ChannelChange = "channelChange",
|
|
100
100
|
PlayerCreate = "playerCreate",
|
|
101
|
-
PlayerDestroy = "playerDestroy"
|
|
101
|
+
PlayerDestroy = "playerDestroy",
|
|
102
|
+
FilterChange = "filterChange"
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
105
|
* Track Source Types Enum
|
|
@@ -157,6 +158,9 @@ declare enum TrackPartial {
|
|
|
157
158
|
/** The custom data of the track */
|
|
158
159
|
CustomData = "customData"
|
|
159
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Manager Event Types Enum
|
|
163
|
+
*/
|
|
160
164
|
declare enum ManagerEventTypes {
|
|
161
165
|
ChapterStarted = "chapterStarted",
|
|
162
166
|
ChaptersLoaded = "chaptersLoaded",
|
|
@@ -266,6 +270,9 @@ declare enum AvailableFilters {
|
|
|
266
270
|
declare class JsonQueue implements IQueue {
|
|
267
271
|
readonly guildId: string;
|
|
268
272
|
readonly manager: Manager;
|
|
273
|
+
/**
|
|
274
|
+
* The base path for the queue files.
|
|
275
|
+
*/
|
|
269
276
|
private basePath;
|
|
270
277
|
/**
|
|
271
278
|
* @param guildId The guild ID.
|
|
@@ -273,76 +280,74 @@ declare class JsonQueue implements IQueue {
|
|
|
273
280
|
*/
|
|
274
281
|
constructor(guildId: string, manager: Manager);
|
|
275
282
|
/**
|
|
276
|
-
* @
|
|
283
|
+
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
284
|
+
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
277
285
|
*/
|
|
278
|
-
|
|
286
|
+
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
279
287
|
/**
|
|
280
|
-
* @
|
|
288
|
+
* @param track The track to add.
|
|
281
289
|
*/
|
|
282
|
-
|
|
290
|
+
addPrevious(track: Track | Track[]): Promise<void>;
|
|
283
291
|
/**
|
|
284
|
-
*
|
|
292
|
+
* Clears the queue.
|
|
285
293
|
*/
|
|
286
|
-
|
|
294
|
+
clear(): Promise<void>;
|
|
287
295
|
/**
|
|
288
|
-
*
|
|
296
|
+
* Clears the previous tracks.
|
|
289
297
|
*/
|
|
290
|
-
|
|
298
|
+
clearPrevious(): Promise<void>;
|
|
291
299
|
/**
|
|
292
|
-
*
|
|
300
|
+
* Removes the first track from the queue.
|
|
293
301
|
*/
|
|
294
|
-
|
|
302
|
+
dequeue(): Promise<Track | undefined>;
|
|
295
303
|
/**
|
|
296
|
-
* @
|
|
304
|
+
* @returns The total duration of the queue.
|
|
297
305
|
*/
|
|
298
|
-
|
|
306
|
+
duration(): Promise<number>;
|
|
299
307
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @returns The JSON data.
|
|
308
|
+
* Adds a track to the front of the queue.
|
|
302
309
|
*/
|
|
303
|
-
|
|
310
|
+
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
304
311
|
/**
|
|
305
|
-
*
|
|
306
|
-
* @param data The data to write.
|
|
312
|
+
* Tests whether all elements in the queue pass the test implemented by the provided function.
|
|
307
313
|
*/
|
|
308
|
-
|
|
314
|
+
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
309
315
|
/**
|
|
310
|
-
*
|
|
316
|
+
* Filters the queue.
|
|
311
317
|
*/
|
|
312
|
-
|
|
318
|
+
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
313
319
|
/**
|
|
314
|
-
*
|
|
320
|
+
* Finds the first track in the queue that satisfies the provided testing function.
|
|
315
321
|
*/
|
|
316
|
-
|
|
322
|
+
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
317
323
|
/**
|
|
318
|
-
* @
|
|
324
|
+
* @returns The current track.
|
|
319
325
|
*/
|
|
320
|
-
|
|
326
|
+
getCurrent(): Promise<Track | null>;
|
|
321
327
|
/**
|
|
322
328
|
* @returns The previous tracks.
|
|
323
329
|
*/
|
|
324
330
|
getPrevious(): Promise<Track[]>;
|
|
325
331
|
/**
|
|
326
|
-
* @
|
|
332
|
+
* @returns The tracks in the queue from start to end.
|
|
327
333
|
*/
|
|
328
|
-
|
|
334
|
+
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
329
335
|
/**
|
|
330
|
-
* @
|
|
336
|
+
* @returns The tracks in the queue.
|
|
331
337
|
*/
|
|
332
|
-
|
|
338
|
+
getTracks(): Promise<Track[]>;
|
|
333
339
|
/**
|
|
334
|
-
*
|
|
340
|
+
* Maps the queue to a new array.
|
|
335
341
|
*/
|
|
336
|
-
|
|
342
|
+
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
337
343
|
/**
|
|
338
|
-
*
|
|
344
|
+
* Modifies the queue at the specified index.
|
|
339
345
|
*/
|
|
340
|
-
|
|
346
|
+
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
341
347
|
/**
|
|
342
|
-
* @
|
|
343
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
348
|
+
* @returns The newest track.
|
|
344
349
|
*/
|
|
345
|
-
|
|
350
|
+
popPrevious(): Promise<Track | null>;
|
|
346
351
|
/**
|
|
347
352
|
* Removes a track from the queue.
|
|
348
353
|
* @param position The position to remove the track at.
|
|
@@ -351,73 +356,75 @@ declare class JsonQueue implements IQueue {
|
|
|
351
356
|
remove(position?: number): Promise<Track[]>;
|
|
352
357
|
remove(start: number, end: number): Promise<Track[]>;
|
|
353
358
|
/**
|
|
354
|
-
*
|
|
355
|
-
*/
|
|
356
|
-
clear(): Promise<void>;
|
|
357
|
-
/**
|
|
358
|
-
* @returns The size of the queue.
|
|
359
|
+
* Shuffles the queue by round-robin.
|
|
359
360
|
*/
|
|
360
|
-
|
|
361
|
+
roundRobinShuffle(): Promise<void>;
|
|
361
362
|
/**
|
|
362
|
-
* @
|
|
363
|
+
* @param track The track to set.
|
|
363
364
|
*/
|
|
364
|
-
|
|
365
|
+
setCurrent(track: Track | null): Promise<void>;
|
|
365
366
|
/**
|
|
366
|
-
* @
|
|
367
|
+
* @param track The track to set.
|
|
367
368
|
*/
|
|
368
|
-
|
|
369
|
+
setPrevious(track: Track | Track[]): Promise<void>;
|
|
369
370
|
/**
|
|
370
371
|
* Shuffles the queue.
|
|
371
372
|
*/
|
|
372
373
|
shuffle(): Promise<void>;
|
|
373
374
|
/**
|
|
374
|
-
*
|
|
375
|
+
* @returns The size of the queue.
|
|
375
376
|
*/
|
|
376
|
-
|
|
377
|
+
size(): Promise<number>;
|
|
377
378
|
/**
|
|
378
|
-
*
|
|
379
|
+
* Tests whether at least one element in the queue passes the test implemented by the provided function.
|
|
379
380
|
*/
|
|
380
|
-
|
|
381
|
+
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
381
382
|
/**
|
|
382
|
-
*
|
|
383
|
+
* @returns The total size of the queue.
|
|
383
384
|
*/
|
|
384
|
-
|
|
385
|
+
totalSize(): Promise<number>;
|
|
385
386
|
/**
|
|
386
|
-
*
|
|
387
|
+
* Shuffles the queue by user.
|
|
387
388
|
*/
|
|
388
|
-
|
|
389
|
+
userBlockShuffle(): Promise<void>;
|
|
389
390
|
/**
|
|
390
|
-
* @returns The
|
|
391
|
+
* @returns The current path.
|
|
391
392
|
*/
|
|
392
|
-
|
|
393
|
+
private get currentPath();
|
|
393
394
|
/**
|
|
394
|
-
* @
|
|
395
|
+
* @param filePath The file path.
|
|
395
396
|
*/
|
|
396
|
-
|
|
397
|
+
private deleteFile;
|
|
397
398
|
/**
|
|
398
|
-
*
|
|
399
|
+
* Ensures the directory exists.
|
|
399
400
|
*/
|
|
400
|
-
|
|
401
|
+
private ensureDir;
|
|
401
402
|
/**
|
|
402
|
-
*
|
|
403
|
+
* @returns The queue.
|
|
403
404
|
*/
|
|
404
|
-
|
|
405
|
+
private getQueue;
|
|
405
406
|
/**
|
|
406
|
-
*
|
|
407
|
+
* @returns The previous path.
|
|
407
408
|
*/
|
|
408
|
-
|
|
409
|
+
private get previousPath();
|
|
409
410
|
/**
|
|
410
|
-
*
|
|
411
|
+
* @returns The queue path.
|
|
411
412
|
*/
|
|
412
|
-
|
|
413
|
+
private get queuePath();
|
|
413
414
|
/**
|
|
414
|
-
*
|
|
415
|
+
* @param filePath The file path.
|
|
416
|
+
* @returns The JSON data.
|
|
415
417
|
*/
|
|
416
|
-
|
|
418
|
+
private readJSON;
|
|
417
419
|
/**
|
|
418
|
-
*
|
|
420
|
+
* @param queue The queue.
|
|
419
421
|
*/
|
|
420
|
-
|
|
422
|
+
private setQueue;
|
|
423
|
+
/**
|
|
424
|
+
* @param filePath The file path.
|
|
425
|
+
* @param data The data to write.
|
|
426
|
+
*/
|
|
427
|
+
private writeJSON;
|
|
421
428
|
}
|
|
422
429
|
|
|
423
430
|
/**
|
|
@@ -439,97 +446,71 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
|
|
|
439
446
|
*/
|
|
440
447
|
constructor(guildId: string, manager: Manager);
|
|
441
448
|
/**
|
|
442
|
-
*
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* @param track The track to set.
|
|
449
|
+
* Adds a track to the queue.
|
|
450
|
+
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
451
|
+
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
447
452
|
*/
|
|
448
|
-
|
|
453
|
+
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
449
454
|
/**
|
|
450
|
-
*
|
|
455
|
+
* Adds a track to the previous tracks.
|
|
456
|
+
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
451
457
|
*/
|
|
452
|
-
getPrevious(): Promise<Track[]>;
|
|
453
458
|
addPrevious(track: Track | Track[]): Promise<void>;
|
|
454
459
|
/**
|
|
455
|
-
*
|
|
456
|
-
|
|
457
|
-
setPrevious(tracks: Track[]): Promise<void>;
|
|
458
|
-
/**
|
|
459
|
-
* @returns The newest track.
|
|
460
|
+
* Clears the queue.
|
|
461
|
+
* This will remove all tracks from the queue and emit a state update event.
|
|
460
462
|
*/
|
|
461
|
-
|
|
463
|
+
clear(): Promise<void>;
|
|
462
464
|
/**
|
|
463
465
|
* Clears the previous tracks.
|
|
464
466
|
*/
|
|
465
467
|
clearPrevious(): Promise<void>;
|
|
468
|
+
/**
|
|
469
|
+
* Removes the first element from the queue.
|
|
470
|
+
*/
|
|
471
|
+
dequeue(): Promise<Track | undefined>;
|
|
466
472
|
/**
|
|
467
473
|
* The total duration of the queue in milliseconds.
|
|
468
474
|
* This includes the duration of the currently playing track.
|
|
469
475
|
*/
|
|
470
476
|
duration(): Promise<number>;
|
|
471
477
|
/**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
474
|
-
* @returns The total size of tracks in the queue including the current track.
|
|
475
|
-
*/
|
|
476
|
-
totalSize(): Promise<number>;
|
|
477
|
-
/**
|
|
478
|
-
* The size of tracks in the queue.
|
|
479
|
-
* This does not include the currently playing track.
|
|
480
|
-
* @returns The size of tracks in the queue.
|
|
481
|
-
*/
|
|
482
|
-
size(): Promise<number>;
|
|
483
|
-
/**
|
|
484
|
-
* Adds a track to the queue.
|
|
485
|
-
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
486
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
487
|
-
*/
|
|
488
|
-
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
489
|
-
/**
|
|
490
|
-
* Removes track(s) from the queue.
|
|
491
|
-
* @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
|
|
492
|
-
* If two numbers are provided, they will be used as the start and end of a range of tracks to remove.
|
|
493
|
-
* @param end Optional, end of the range of tracks to remove.
|
|
494
|
-
* @returns The removed track(s).
|
|
478
|
+
* Adds the specified track or tracks to the front of the queue.
|
|
479
|
+
* @param track The track or tracks to add.
|
|
495
480
|
*/
|
|
496
|
-
|
|
497
|
-
remove(start: number, end: number): Promise<Track[]>;
|
|
481
|
+
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
498
482
|
/**
|
|
499
|
-
*
|
|
500
|
-
* This will remove all tracks from the queue and emit a state update event.
|
|
483
|
+
* @returns Whether all elements in the queue satisfy the provided testing function.
|
|
501
484
|
*/
|
|
502
|
-
|
|
485
|
+
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
503
486
|
/**
|
|
504
|
-
*
|
|
505
|
-
* This will randomize the order of the tracks in the queue and emit a state update event.
|
|
487
|
+
* @returns A new array with all elements that pass the test implemented by the provided function.
|
|
506
488
|
*/
|
|
507
|
-
|
|
489
|
+
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
508
490
|
/**
|
|
509
|
-
*
|
|
491
|
+
* @returns The first element in the queue that satisfies the provided testing function.
|
|
510
492
|
*/
|
|
511
|
-
|
|
493
|
+
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
512
494
|
/**
|
|
513
|
-
*
|
|
495
|
+
* @returns The current track.
|
|
514
496
|
*/
|
|
515
|
-
|
|
497
|
+
getCurrent(): Promise<Track | null>;
|
|
516
498
|
/**
|
|
517
|
-
*
|
|
499
|
+
* @returns The previous tracks.
|
|
518
500
|
*/
|
|
519
|
-
|
|
501
|
+
getPrevious(): Promise<Track[]>;
|
|
520
502
|
/**
|
|
521
|
-
*
|
|
522
|
-
* @param track The track or tracks to add.
|
|
503
|
+
* @returns The tracks in the queue from start to end.
|
|
523
504
|
*/
|
|
524
|
-
|
|
505
|
+
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
525
506
|
/**
|
|
526
|
-
* @returns
|
|
507
|
+
* @returns The tracks in the queue.
|
|
527
508
|
*/
|
|
528
509
|
getTracks(): Promise<Track[]>;
|
|
529
510
|
/**
|
|
530
|
-
* @returns A
|
|
511
|
+
* @returns A new array with the results of calling a provided function on every element in the queue.
|
|
531
512
|
*/
|
|
532
|
-
|
|
513
|
+
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
533
514
|
/**
|
|
534
515
|
* Modifies the queue at the specified index.
|
|
535
516
|
* @param start The index at which to start modifying the queue.
|
|
@@ -539,41 +520,71 @@ declare class MemoryQueue extends Array<Track> implements IQueue {
|
|
|
539
520
|
*/
|
|
540
521
|
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
541
522
|
/**
|
|
542
|
-
* @returns
|
|
523
|
+
* @returns The newest track.
|
|
543
524
|
*/
|
|
544
|
-
|
|
525
|
+
popPrevious(): Promise<Track | null>;
|
|
545
526
|
/**
|
|
546
|
-
*
|
|
527
|
+
* Removes track(s) from the queue.
|
|
528
|
+
* @param startOrPosition If a single number is provided, it will be treated as the position of the track to remove.
|
|
529
|
+
* If two numbers are provided, they will be used as the start and end of a range of tracks to remove.
|
|
530
|
+
* @param end Optional, end of the range of tracks to remove.
|
|
531
|
+
* @returns The removed track(s).
|
|
547
532
|
*/
|
|
548
|
-
|
|
533
|
+
remove(position?: number): Promise<Track[]>;
|
|
534
|
+
remove(start: number, end: number): Promise<Track[]>;
|
|
549
535
|
/**
|
|
550
|
-
*
|
|
536
|
+
* Shuffles the queue to play tracks requested by each user one by one.
|
|
551
537
|
*/
|
|
552
|
-
|
|
538
|
+
roundRobinShuffle(): Promise<void>;
|
|
553
539
|
/**
|
|
554
|
-
* @
|
|
540
|
+
* @param track The track to set.
|
|
555
541
|
*/
|
|
556
|
-
|
|
542
|
+
setCurrent(track: Track | null): Promise<void>;
|
|
557
543
|
/**
|
|
558
|
-
* @
|
|
544
|
+
* @param tracks The tracks to set.
|
|
559
545
|
*/
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
546
|
+
setPrevious(tracks: Track[]): Promise<void>;
|
|
547
|
+
/**
|
|
548
|
+
* Shuffles the queue.
|
|
549
|
+
* This will randomize the order of the tracks in the queue and emit a state update event.
|
|
550
|
+
*/
|
|
551
|
+
shuffle(): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* The size of tracks in the queue.
|
|
554
|
+
* This does not include the currently playing track.
|
|
555
|
+
* @returns The size of tracks in the queue.
|
|
556
|
+
*/
|
|
557
|
+
size(): Promise<number>;
|
|
558
|
+
/**
|
|
559
|
+
* @returns Whether at least one element in the queue satisfies the provided testing function.
|
|
560
|
+
*/
|
|
561
|
+
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
562
|
+
/**
|
|
563
|
+
* The total size of tracks in the queue including the current track.
|
|
564
|
+
* This includes the current track if it is not null.
|
|
565
|
+
* @returns The total size of tracks in the queue including the current track.
|
|
566
|
+
*/
|
|
567
|
+
totalSize(): Promise<number>;
|
|
568
|
+
/**
|
|
569
|
+
* Shuffles the queue to play tracks requested by each user one block at a time.
|
|
570
|
+
*/
|
|
571
|
+
userBlockShuffle(): Promise<void>;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
565
576
|
*/
|
|
566
577
|
declare class RedisQueue implements IQueue {
|
|
567
578
|
readonly guildId: string;
|
|
568
579
|
readonly manager: Manager;
|
|
569
|
-
/**
|
|
570
|
-
* The Redis instance.
|
|
571
|
-
*/
|
|
572
|
-
private redis;
|
|
573
580
|
/**
|
|
574
581
|
* The prefix for the Redis keys.
|
|
575
582
|
*/
|
|
576
583
|
redisPrefix: string;
|
|
584
|
+
/**
|
|
585
|
+
* The Redis instance.
|
|
586
|
+
*/
|
|
587
|
+
private redis;
|
|
577
588
|
/**
|
|
578
589
|
* Constructs a new RedisQueue.
|
|
579
590
|
* @param guildId The guild ID.
|
|
@@ -581,133 +592,151 @@ declare class RedisQueue implements IQueue {
|
|
|
581
592
|
*/
|
|
582
593
|
constructor(guildId: string, manager: Manager);
|
|
583
594
|
/**
|
|
584
|
-
*
|
|
595
|
+
* Adds a track or tracks to the queue.
|
|
596
|
+
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
597
|
+
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
585
598
|
*/
|
|
586
|
-
|
|
599
|
+
add(track: Track | Track[], offset?: number): Promise<void>;
|
|
587
600
|
/**
|
|
588
|
-
*
|
|
601
|
+
* Adds a track or tracks to the previous tracks.
|
|
602
|
+
* @param track The track or tracks to add.
|
|
589
603
|
*/
|
|
590
|
-
|
|
604
|
+
addPrevious(track: Track | Track[]): Promise<void>;
|
|
591
605
|
/**
|
|
592
|
-
*
|
|
606
|
+
* Clears the queue.
|
|
593
607
|
*/
|
|
594
|
-
|
|
608
|
+
clear(): Promise<void>;
|
|
595
609
|
/**
|
|
596
|
-
*
|
|
610
|
+
* Clears the previous tracks.
|
|
597
611
|
*/
|
|
598
|
-
|
|
612
|
+
clearPrevious(): Promise<void>;
|
|
599
613
|
/**
|
|
600
|
-
*
|
|
614
|
+
* Removes the first track from the queue.
|
|
601
615
|
*/
|
|
602
|
-
|
|
616
|
+
dequeue(): Promise<Track | undefined>;
|
|
603
617
|
/**
|
|
604
|
-
* @returns The
|
|
618
|
+
* @returns The total duration of the queue in milliseconds.
|
|
619
|
+
* This includes the duration of the currently playing track.
|
|
605
620
|
*/
|
|
606
|
-
|
|
621
|
+
duration(): Promise<number>;
|
|
607
622
|
/**
|
|
608
|
-
*
|
|
623
|
+
* Adds a track to the front of the queue.
|
|
624
|
+
* @param track The track or tracks to add.
|
|
609
625
|
*/
|
|
610
|
-
|
|
626
|
+
enqueueFront(track: Track | Track[]): Promise<void>;
|
|
611
627
|
/**
|
|
612
|
-
*
|
|
628
|
+
* Whether all tracks in the queue match the specified condition.
|
|
629
|
+
* @param callback The condition to match.
|
|
630
|
+
* @returns Whether all tracks in the queue match the specified condition.
|
|
613
631
|
*/
|
|
614
|
-
|
|
632
|
+
everyAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
615
633
|
/**
|
|
616
|
-
*
|
|
634
|
+
* Filters the tracks in the queue.
|
|
635
|
+
* @param callback The condition to match.
|
|
636
|
+
* @returns The tracks that match the condition.
|
|
617
637
|
*/
|
|
618
|
-
|
|
638
|
+
filterAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track[]>;
|
|
619
639
|
/**
|
|
620
|
-
*
|
|
640
|
+
* Finds the first track in the queue that matches the specified condition.
|
|
641
|
+
* @param callback The condition to match.
|
|
642
|
+
* @returns The first track that matches the condition.
|
|
621
643
|
*/
|
|
622
|
-
|
|
644
|
+
findAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<Track | undefined>;
|
|
623
645
|
/**
|
|
624
|
-
* @returns The
|
|
646
|
+
* @returns The current track.
|
|
625
647
|
*/
|
|
626
|
-
|
|
648
|
+
getCurrent(): Promise<Track | null>;
|
|
627
649
|
/**
|
|
628
|
-
*
|
|
650
|
+
* @returns The previous tracks.
|
|
629
651
|
*/
|
|
630
|
-
|
|
652
|
+
getPrevious(): Promise<Track[]>;
|
|
631
653
|
/**
|
|
632
|
-
* @
|
|
633
|
-
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
654
|
+
* @returns The tracks in the queue from the start to the end.
|
|
634
655
|
*/
|
|
635
|
-
|
|
656
|
+
getSlice(start?: number, end?: number): Promise<Track[]>;
|
|
636
657
|
/**
|
|
637
|
-
* @
|
|
638
|
-
* @param end The end position to remove the track at.
|
|
658
|
+
* @returns The tracks in the queue.
|
|
639
659
|
*/
|
|
640
|
-
|
|
641
|
-
remove(start: number, end: number): Promise<Track[]>;
|
|
660
|
+
getTracks(): Promise<Track[]>;
|
|
642
661
|
/**
|
|
643
|
-
*
|
|
662
|
+
* Maps the tracks in the queue.
|
|
663
|
+
* @returns The tracks in the queue after the specified index.
|
|
644
664
|
*/
|
|
645
|
-
|
|
665
|
+
mapAsync<T>(callback: (track: Track, index: number, array: Track[]) => T): Promise<T[]>;
|
|
646
666
|
/**
|
|
647
|
-
*
|
|
667
|
+
* Modifies the queue at the specified index.
|
|
668
|
+
* @param start The start index.
|
|
669
|
+
* @param deleteCount The number of tracks to delete.
|
|
670
|
+
* @param items The tracks to insert.
|
|
671
|
+
* @returns The removed tracks.
|
|
648
672
|
*/
|
|
649
|
-
|
|
673
|
+
modifyAt(start: number, deleteCount?: number, ...items: Track[]): Promise<Track[]>;
|
|
650
674
|
/**
|
|
651
|
-
*
|
|
675
|
+
* Removes the newest track.
|
|
676
|
+
* @returns The newest track.
|
|
652
677
|
*/
|
|
653
|
-
|
|
678
|
+
popPrevious(): Promise<Track | null>;
|
|
654
679
|
/**
|
|
655
|
-
*
|
|
656
|
-
*
|
|
680
|
+
* Removes the track at the specified index.
|
|
681
|
+
* @param position The position to remove the track at.
|
|
682
|
+
* @param end The end position to remove the track at.
|
|
657
683
|
*/
|
|
658
|
-
|
|
684
|
+
remove(position?: number): Promise<Track[]>;
|
|
685
|
+
remove(start: number, end: number): Promise<Track[]>;
|
|
659
686
|
/**
|
|
660
|
-
* Shuffles the queue.
|
|
687
|
+
* Shuffles the queue round-robin style.
|
|
661
688
|
*/
|
|
662
|
-
|
|
689
|
+
roundRobinShuffle(): Promise<void>;
|
|
663
690
|
/**
|
|
664
|
-
*
|
|
691
|
+
* Sets the current track.
|
|
692
|
+
* @param track The track to set.
|
|
665
693
|
*/
|
|
666
|
-
|
|
694
|
+
setCurrent(track: Track | null): Promise<void>;
|
|
667
695
|
/**
|
|
668
|
-
*
|
|
696
|
+
* Sets the previous track(s).
|
|
697
|
+
* @param track The track to set.
|
|
669
698
|
*/
|
|
670
|
-
|
|
699
|
+
setPrevious(track: Track | Track[]): Promise<void>;
|
|
671
700
|
/**
|
|
672
|
-
*
|
|
701
|
+
* Shuffles the queue.
|
|
673
702
|
*/
|
|
674
|
-
|
|
703
|
+
shuffle(): Promise<void>;
|
|
675
704
|
/**
|
|
676
|
-
*
|
|
705
|
+
* @returns The size of the queue.
|
|
677
706
|
*/
|
|
678
|
-
|
|
707
|
+
size(): Promise<number>;
|
|
679
708
|
/**
|
|
680
|
-
* @returns
|
|
709
|
+
* @returns Whether any tracks in the queue match the specified condition.
|
|
681
710
|
*/
|
|
682
|
-
|
|
711
|
+
someAsync(callback: (track: Track, index: number, array: Track[]) => boolean): Promise<boolean>;
|
|
683
712
|
/**
|
|
684
|
-
* @returns The tracks in the queue
|
|
713
|
+
* @returns The total size of tracks in the queue including the current track.
|
|
685
714
|
*/
|
|
686
|
-
|
|
715
|
+
totalSize(): Promise<number>;
|
|
687
716
|
/**
|
|
688
|
-
*
|
|
717
|
+
* Shuffles the queue, but keeps the tracks of the same user together.
|
|
689
718
|
*/
|
|
690
|
-
|
|
719
|
+
userBlockShuffle(): Promise<void>;
|
|
691
720
|
/**
|
|
692
|
-
* @returns The
|
|
721
|
+
* @returns The current key.
|
|
693
722
|
*/
|
|
694
|
-
|
|
723
|
+
private get currentKey();
|
|
695
724
|
/**
|
|
696
|
-
*
|
|
725
|
+
* Deserializes a track from a string.
|
|
697
726
|
*/
|
|
698
|
-
|
|
727
|
+
private deserialize;
|
|
699
728
|
/**
|
|
700
|
-
* @returns The
|
|
729
|
+
* @returns The previous key.
|
|
701
730
|
*/
|
|
702
|
-
|
|
731
|
+
private get previousKey();
|
|
703
732
|
/**
|
|
704
|
-
* @returns
|
|
733
|
+
* @returns The queue key.
|
|
705
734
|
*/
|
|
706
|
-
|
|
735
|
+
private get queueKey();
|
|
707
736
|
/**
|
|
708
|
-
*
|
|
737
|
+
* Helper to serialize/deserialize Track
|
|
709
738
|
*/
|
|
710
|
-
|
|
739
|
+
private serialize;
|
|
711
740
|
}
|
|
712
741
|
|
|
713
742
|
/**
|
|
@@ -960,6 +989,9 @@ type PlayerStateUpdateEvent = {
|
|
|
960
989
|
} | {
|
|
961
990
|
changeType: PlayerStateEventTypes.RepeatChange;
|
|
962
991
|
details: RepeatChangeEvent;
|
|
992
|
+
} | {
|
|
993
|
+
changeType: PlayerStateEventTypes.FilterChange;
|
|
994
|
+
details: FilterChangeEvent;
|
|
963
995
|
};
|
|
964
996
|
/**
|
|
965
997
|
* Autoplay Change Event
|
|
@@ -979,6 +1011,10 @@ interface ConnectionChangeEvent {
|
|
|
979
1011
|
previousConnection: boolean | null;
|
|
980
1012
|
currentConnection: boolean | null;
|
|
981
1013
|
}
|
|
1014
|
+
interface FilterChangeEvent {
|
|
1015
|
+
type: "filter";
|
|
1016
|
+
action: "change";
|
|
1017
|
+
}
|
|
982
1018
|
/**
|
|
983
1019
|
* Repeat Change Event
|
|
984
1020
|
*/
|
|
@@ -1914,1058 +1950,1059 @@ type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
|
|
|
1914
1950
|
*/
|
|
1915
1951
|
type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
|
|
1916
1952
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
/** The
|
|
1920
|
-
|
|
1921
|
-
/** The
|
|
1922
|
-
|
|
1923
|
-
/**
|
|
1924
|
-
|
|
1925
|
-
/**
|
|
1926
|
-
|
|
1927
|
-
/**
|
|
1953
|
+
declare class Player {
|
|
1954
|
+
options: PlayerOptions;
|
|
1955
|
+
/** The Queue for the Player. */
|
|
1956
|
+
queue: IQueue;
|
|
1957
|
+
/** The filters applied to the audio. */
|
|
1958
|
+
filters: Filters;
|
|
1959
|
+
/** Whether the queue repeats the track. */
|
|
1960
|
+
trackRepeat: boolean;
|
|
1961
|
+
/** Whether the queue repeats the queue. */
|
|
1962
|
+
queueRepeat: boolean;
|
|
1963
|
+
/**Whether the queue repeats and shuffles after each song. */
|
|
1964
|
+
dynamicRepeat: boolean;
|
|
1965
|
+
/** The time the player is in the track. */
|
|
1966
|
+
position: number;
|
|
1967
|
+
/** Whether the player is playing. */
|
|
1968
|
+
playing: boolean;
|
|
1969
|
+
/** Whether the player is paused. */
|
|
1970
|
+
paused: boolean;
|
|
1971
|
+
/** The volume for the player */
|
|
1972
|
+
volume: number;
|
|
1973
|
+
/** The Node for the Player. */
|
|
1974
|
+
node: Node;
|
|
1975
|
+
/** The guild ID for the player. */
|
|
1976
|
+
guildId: string;
|
|
1977
|
+
/** The voice channel for the player. */
|
|
1978
|
+
voiceChannelId: string | null;
|
|
1979
|
+
/** The text channel for the player. */
|
|
1980
|
+
textChannelId: string | null;
|
|
1981
|
+
/**The now playing message. */
|
|
1982
|
+
nowPlayingMessage?: Message;
|
|
1983
|
+
/** The current state of the player. */
|
|
1984
|
+
state: StateTypes;
|
|
1985
|
+
/** The equalizer bands array. */
|
|
1986
|
+
bands: number[];
|
|
1987
|
+
/** The voice state object from Discord. */
|
|
1988
|
+
voiceState: VoiceState;
|
|
1989
|
+
/** The Manager. */
|
|
1928
1990
|
manager: Manager;
|
|
1929
|
-
/**
|
|
1930
|
-
|
|
1931
|
-
|
|
1991
|
+
/** The autoplay state of the player. */
|
|
1992
|
+
isAutoplay: boolean;
|
|
1993
|
+
/** The number of times to try autoplay before emitting queueEnd. */
|
|
1994
|
+
autoplayTries: number;
|
|
1995
|
+
/** The cluster ID for the player. */
|
|
1996
|
+
clusterId: number;
|
|
1997
|
+
private readonly data;
|
|
1998
|
+
private dynamicLoopInterval;
|
|
1999
|
+
dynamicRepeatIntervalMs: number | null;
|
|
2000
|
+
private static _manager;
|
|
2001
|
+
/** Should only be used when the node is a NodeLink */
|
|
2002
|
+
protected voiceReceiverWsClient: WebSocket | null;
|
|
2003
|
+
protected isConnectToVoiceReceiver: boolean;
|
|
2004
|
+
protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
|
|
2005
|
+
protected voiceReceiverAttempt: number;
|
|
2006
|
+
protected voiceReceiverReconnectTries: number;
|
|
1932
2007
|
/**
|
|
1933
|
-
*
|
|
1934
|
-
*
|
|
1935
|
-
* @
|
|
1936
|
-
* @returns {string} Returns the set session ID.
|
|
2008
|
+
* Creates a new player, returns one if it already exists.
|
|
2009
|
+
* @param options The player options.
|
|
2010
|
+
* @see https://docs.magmastream.com/main/introduction/getting-started
|
|
1937
2011
|
*/
|
|
1938
|
-
|
|
2012
|
+
constructor(options: PlayerOptions);
|
|
1939
2013
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
* @
|
|
2014
|
+
* Initializes the static properties of the Player class.
|
|
2015
|
+
* @hidden
|
|
2016
|
+
* @param manager The Manager to use.
|
|
1942
2017
|
*/
|
|
1943
|
-
|
|
2018
|
+
static init(manager: Manager): void;
|
|
1944
2019
|
/**
|
|
1945
|
-
*
|
|
1946
|
-
* @param
|
|
1947
|
-
* @
|
|
2020
|
+
* Set custom data.
|
|
2021
|
+
* @param key - The key to set the data for.
|
|
2022
|
+
* @param value - The value to set the data to.
|
|
1948
2023
|
*/
|
|
1949
|
-
|
|
1950
|
-
/**
|
|
1951
|
-
* Sends a DELETE request to the server to destroy the player.
|
|
1952
|
-
* @param {string} guildId The guild ID of the player to destroy.
|
|
1953
|
-
* @returns {Promise<unknown>} Returns the result of the DELETE request.
|
|
1954
|
-
*/
|
|
1955
|
-
destroyPlayer(guildId: string): Promise<unknown>;
|
|
1956
|
-
/**
|
|
1957
|
-
* Updates the session status for resuming.
|
|
1958
|
-
* This method sends a PATCH request to update the session's resuming status and timeout.
|
|
1959
|
-
*
|
|
1960
|
-
* @param {boolean} resuming - Indicates whether the session should be set to resuming.
|
|
1961
|
-
* @param {number} timeout - The timeout duration for the session resume.
|
|
1962
|
-
* @returns {Promise<unknown>} The result of the PATCH request.
|
|
1963
|
-
*/
|
|
1964
|
-
updateSession(resuming: boolean, timeout: number): Promise<unknown>;
|
|
1965
|
-
/**
|
|
1966
|
-
* Sends a request to the specified endpoint and returns the response data.
|
|
1967
|
-
* @param {string} method The HTTP method to use for the request.
|
|
1968
|
-
* @param {string} endpoint The endpoint to send the request to.
|
|
1969
|
-
* @param {unknown} [body] The data to send in the request body.
|
|
1970
|
-
* @returns {Promise<unknown>} The response data of the request.
|
|
1971
|
-
*/
|
|
1972
|
-
private request;
|
|
2024
|
+
set(key: string, value: unknown): void;
|
|
1973
2025
|
/**
|
|
1974
|
-
*
|
|
1975
|
-
* @
|
|
1976
|
-
* @
|
|
2026
|
+
* Retrieves custom data associated with a given key.
|
|
2027
|
+
* @template T - The expected type of the data.
|
|
2028
|
+
* @param {string} key - The key to retrieve the data for.
|
|
2029
|
+
* @returns {T} - The data associated with the key, cast to the specified type.
|
|
1977
2030
|
*/
|
|
1978
|
-
get(
|
|
2031
|
+
get<T>(key: string): T;
|
|
1979
2032
|
/**
|
|
1980
|
-
*
|
|
1981
|
-
* @param
|
|
1982
|
-
* @param
|
|
1983
|
-
* @returns {Promise<unknown>} The response data of the PATCH request.
|
|
2033
|
+
* Same as Manager#search() but a shortcut on the player itself.
|
|
2034
|
+
* @param query
|
|
2035
|
+
* @param requester
|
|
1984
2036
|
*/
|
|
1985
|
-
|
|
2037
|
+
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
1986
2038
|
/**
|
|
1987
|
-
*
|
|
1988
|
-
* @
|
|
1989
|
-
* @
|
|
1990
|
-
* @returns {Promise<unknown>} The response data of the POST request.
|
|
2039
|
+
* Connects the player to the voice channel.
|
|
2040
|
+
* @throws {RangeError} If no voice channel has been set.
|
|
2041
|
+
* @returns {void}
|
|
1991
2042
|
*/
|
|
1992
|
-
|
|
2043
|
+
connect(): void;
|
|
1993
2044
|
/**
|
|
1994
|
-
*
|
|
1995
|
-
* @
|
|
1996
|
-
* @param {unknown} body The data to send in the request body.
|
|
1997
|
-
* @returns {Promise<unknown>} The response data of the PUT request.
|
|
2045
|
+
* Disconnects the player from the voice channel.
|
|
2046
|
+
* @returns {this} The player instance.
|
|
1998
2047
|
*/
|
|
1999
|
-
|
|
2048
|
+
disconnect(): Promise<this>;
|
|
2000
2049
|
/**
|
|
2001
|
-
*
|
|
2002
|
-
* @param {
|
|
2003
|
-
* @returns {Promise<
|
|
2050
|
+
* Destroys the player and clears the queue.
|
|
2051
|
+
* @param {boolean} disconnect - Whether to disconnect the player from the voice channel.
|
|
2052
|
+
* @returns {Promise<boolean>} - Whether the player was successfully destroyed.
|
|
2053
|
+
* @emits {PlayerDestroy} - Emitted when the player is destroyed.
|
|
2054
|
+
* @emits {PlayerStateUpdate} - Emitted when the player state is updated.
|
|
2004
2055
|
*/
|
|
2005
|
-
|
|
2006
|
-
}
|
|
2007
|
-
|
|
2008
|
-
declare class Node {
|
|
2009
|
-
manager: Manager;
|
|
2010
|
-
options: NodeOptions;
|
|
2011
|
-
/** The socket for the node. */
|
|
2012
|
-
socket: WebSocket | null;
|
|
2013
|
-
/** The stats for the node. */
|
|
2014
|
-
stats: NodeStats;
|
|
2015
|
-
/** The manager for the node */
|
|
2016
|
-
/** The node's session ID. */
|
|
2017
|
-
sessionId: string | null;
|
|
2018
|
-
/** The REST instance. */
|
|
2019
|
-
readonly rest: Rest;
|
|
2020
|
-
/** Actual Lavalink information of the node. */
|
|
2021
|
-
info: LavalinkInfo | null;
|
|
2022
|
-
/** Whether the node is a NodeLink. */
|
|
2023
|
-
isNodeLink: boolean;
|
|
2024
|
-
private reconnectTimeout?;
|
|
2025
|
-
private reconnectAttempts;
|
|
2026
|
-
private redisPrefix?;
|
|
2027
|
-
private sessionIdsFilePath?;
|
|
2028
|
-
private sessionIdsMap;
|
|
2056
|
+
destroy(disconnect?: boolean): Promise<boolean>;
|
|
2029
2057
|
/**
|
|
2030
|
-
*
|
|
2031
|
-
* @param
|
|
2032
|
-
* @
|
|
2058
|
+
* Sets the player voice channel.
|
|
2059
|
+
* @param {string} channel - The new voice channel ID.
|
|
2060
|
+
* @returns {this} - The player instance.
|
|
2061
|
+
* @throws {TypeError} If the channel parameter is not a string.
|
|
2033
2062
|
*/
|
|
2034
|
-
|
|
2063
|
+
setVoiceChannelId(channel: string): this;
|
|
2035
2064
|
/**
|
|
2036
|
-
*
|
|
2037
|
-
*
|
|
2065
|
+
* Sets the player text channel.
|
|
2066
|
+
*
|
|
2067
|
+
* This method updates the text channel associated with the player. It also
|
|
2068
|
+
* emits a player state update event indicating the change in the channel.
|
|
2069
|
+
*
|
|
2070
|
+
* @param {string} channel - The new text channel ID.
|
|
2071
|
+
* @returns {this} - The player instance for method chaining.
|
|
2072
|
+
* @throws {TypeError} If the channel parameter is not a string.
|
|
2038
2073
|
*/
|
|
2039
|
-
|
|
2040
|
-
/** Returns the full address for this node, including the host and port. */
|
|
2041
|
-
get address(): string;
|
|
2074
|
+
setTextChannelId(channel: string): this;
|
|
2042
2075
|
/**
|
|
2043
|
-
*
|
|
2044
|
-
*
|
|
2045
|
-
*
|
|
2076
|
+
* Sets the now playing message.
|
|
2077
|
+
*
|
|
2078
|
+
* @param message - The message of the now playing message.
|
|
2079
|
+
* @returns The now playing message.
|
|
2046
2080
|
*/
|
|
2047
|
-
|
|
2081
|
+
setNowPlayingMessage<T = Message>(message: T): Message;
|
|
2048
2082
|
/**
|
|
2049
|
-
*
|
|
2050
|
-
* The session IDs are used to resume sessions for each node.
|
|
2083
|
+
* Plays the next track.
|
|
2051
2084
|
*
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2054
|
-
*
|
|
2085
|
+
* If a track is provided, it will be played. Otherwise, the next track in the queue will be played.
|
|
2086
|
+
* If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track.
|
|
2087
|
+
*
|
|
2088
|
+
* @param {object} [optionsOrTrack] - The track to play or the options to play with.
|
|
2089
|
+
* @param {object} [playOptions] - The options to play with.
|
|
2090
|
+
*
|
|
2091
|
+
* @returns {Promise<void>}
|
|
2055
2092
|
*/
|
|
2056
|
-
|
|
2093
|
+
play(): Promise<Player>;
|
|
2094
|
+
play(track: Track): Promise<Player>;
|
|
2095
|
+
play(options: PlayOptions): Promise<Player>;
|
|
2096
|
+
play(track: Track, options: PlayOptions): Promise<Player>;
|
|
2057
2097
|
/**
|
|
2058
|
-
*
|
|
2098
|
+
* Sets the autoplay-state of the player.
|
|
2059
2099
|
*
|
|
2060
|
-
*
|
|
2061
|
-
*
|
|
2100
|
+
* Autoplay is a feature that makes the player play a recommended
|
|
2101
|
+
* track when the current track ends.
|
|
2062
2102
|
*
|
|
2063
|
-
* @
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
2103
|
+
* @param {boolean} autoplayState - Whether or not autoplay should be enabled.
|
|
2104
|
+
* @param {object} botUser - The user-object that should be used as the bot-user.
|
|
2105
|
+
* @param {number} [tries=3] - The number of times the player should try to find a
|
|
2106
|
+
* recommended track if the first one doesn't work.
|
|
2107
|
+
* @returns {this} - The player instance.
|
|
2067
2108
|
*/
|
|
2068
|
-
|
|
2109
|
+
setAutoplay<T = unknown>(autoplayState: boolean, botUser?: T, tries?: number): this;
|
|
2069
2110
|
/**
|
|
2070
|
-
*
|
|
2071
|
-
*
|
|
2072
|
-
* @
|
|
2073
|
-
* If the node is already connected, this method will do nothing.
|
|
2074
|
-
* If the node has a session ID, it will be sent in the headers of the WebSocket connection.
|
|
2075
|
-
* If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID
|
|
2076
|
-
* stored in the sessionIds.json file if it exists.
|
|
2111
|
+
* Gets recommended tracks and returns an array of tracks.
|
|
2112
|
+
* @param {Track} track - The track to find recommendations for.
|
|
2113
|
+
* @returns {Promise<Track[]>} - Array of recommended tracks.
|
|
2077
2114
|
*/
|
|
2078
|
-
|
|
2115
|
+
getRecommendedTracks(track: Track): Promise<Track[]>;
|
|
2079
2116
|
/**
|
|
2080
|
-
*
|
|
2081
|
-
*
|
|
2082
|
-
*
|
|
2083
|
-
*
|
|
2084
|
-
*
|
|
2085
|
-
*
|
|
2086
|
-
*
|
|
2087
|
-
*
|
|
2117
|
+
* Sets the volume of the player.
|
|
2118
|
+
* @param {number} volume - The new volume. Must be between 0 and 1000.
|
|
2119
|
+
* @returns {Promise<Player>} - The updated player.
|
|
2120
|
+
* @throws {TypeError} If the volume is not a number.
|
|
2121
|
+
* @throws {RangeError} If the volume is not between 0 and 1000.
|
|
2122
|
+
* @emits {PlayerStateUpdate} - Emitted when the volume is changed.
|
|
2123
|
+
* @example
|
|
2124
|
+
* player.setVolume(50);
|
|
2125
|
+
* player.setVolume(50, { gradual: true, interval: 50, step: 5 });
|
|
2088
2126
|
*/
|
|
2089
|
-
|
|
2127
|
+
setVolume(volume: number): Promise<this>;
|
|
2090
2128
|
/**
|
|
2091
|
-
*
|
|
2092
|
-
*
|
|
2093
|
-
*
|
|
2094
|
-
* unexpectedly. It will attempt to reconnect to the node after a
|
|
2095
|
-
* specified delay, and will continue to do so until the maximum
|
|
2096
|
-
* number of retry attempts is reached or the node is manually destroyed.
|
|
2097
|
-
* If the maximum number of retry attempts is reached, an error event
|
|
2098
|
-
* will be emitted and the node will be destroyed.
|
|
2099
|
-
*
|
|
2100
|
-
* @returns {Promise<void>} - Resolves when the reconnection attempt is scheduled.
|
|
2101
|
-
* @emits {debug} - Emits a debug event indicating the node is attempting to reconnect.
|
|
2102
|
-
* @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect.
|
|
2103
|
-
* @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached.
|
|
2104
|
-
* @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached.
|
|
2129
|
+
* Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.
|
|
2130
|
+
* @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
|
|
2131
|
+
* @returns {Promise<void>} The promise is resolved when the operation is complete.
|
|
2105
2132
|
*/
|
|
2106
|
-
|
|
2133
|
+
setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
|
|
2107
2134
|
/**
|
|
2108
|
-
*
|
|
2109
|
-
*
|
|
2110
|
-
* @param request - The incoming message.
|
|
2135
|
+
* Gets the sponsorblock for the player.
|
|
2136
|
+
* @returns {Promise<SponsorBlockSegment[]>} The sponsorblock segments.
|
|
2111
2137
|
*/
|
|
2112
|
-
|
|
2138
|
+
getSponsorBlock(): Promise<SponsorBlockSegment[]>;
|
|
2113
2139
|
/**
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
* This method is called when the WebSocket connection is established.
|
|
2117
|
-
* It clears any existing reconnect timeouts, emits a debug event
|
|
2118
|
-
* indicating the node is connected, and emits a "nodeConnect" event
|
|
2119
|
-
* with the node as the argument.
|
|
2140
|
+
* Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.
|
|
2141
|
+
* @returns {Promise<void>}
|
|
2120
2142
|
*/
|
|
2121
|
-
|
|
2143
|
+
deleteSponsorBlock(): Promise<void>;
|
|
2122
2144
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
*
|
|
2125
|
-
*
|
|
2126
|
-
* It emits a "nodeDisconnect" event with the node and the close event as arguments,
|
|
2127
|
-
* and a debug event indicating the node is disconnected.
|
|
2128
|
-
* It then attempts to move all players connected to that node to a useable one.
|
|
2129
|
-
* If the close event was not initiated by the user, it will also attempt to reconnect.
|
|
2145
|
+
* Sets the track repeat mode.
|
|
2146
|
+
* When track repeat is enabled, the current track will replay after it ends.
|
|
2147
|
+
* Disables queueRepeat and dynamicRepeat modes if enabled.
|
|
2130
2148
|
*
|
|
2131
|
-
* @param
|
|
2132
|
-
* @
|
|
2133
|
-
* @
|
|
2149
|
+
* @param repeat - A boolean indicating whether to enable track repeat.
|
|
2150
|
+
* @returns {this} - The player instance.
|
|
2151
|
+
* @throws {TypeError} If the repeat parameter is not a boolean.
|
|
2134
2152
|
*/
|
|
2135
|
-
|
|
2153
|
+
setTrackRepeat(repeat: boolean): this;
|
|
2136
2154
|
/**
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2139
|
-
*
|
|
2140
|
-
*
|
|
2141
|
-
* a debug event indicating the error on the node.
|
|
2142
|
-
* @param {Error} error The error that occurred.
|
|
2155
|
+
* Sets the queue repeat.
|
|
2156
|
+
* @param repeat Whether to repeat the queue or not
|
|
2157
|
+
* @returns {this} - The player instance.
|
|
2158
|
+
* @throws {TypeError} If the repeat parameter is not a boolean
|
|
2143
2159
|
*/
|
|
2144
|
-
|
|
2160
|
+
setQueueRepeat(repeat: boolean): this;
|
|
2145
2161
|
/**
|
|
2146
|
-
*
|
|
2147
|
-
* @param
|
|
2148
|
-
* @
|
|
2149
|
-
* @
|
|
2150
|
-
* @
|
|
2151
|
-
* @
|
|
2152
|
-
* @private
|
|
2162
|
+
* Sets the queue to repeat and shuffles the queue after each song.
|
|
2163
|
+
* @param repeat "true" or "false".
|
|
2164
|
+
* @param ms After how many milliseconds to trigger dynamic repeat.
|
|
2165
|
+
* @returns {this} - The player instance.
|
|
2166
|
+
* @throws {TypeError} If the repeat parameter is not a boolean.
|
|
2167
|
+
* @throws {RangeError} If the queue size is less than or equal to 1.
|
|
2153
2168
|
*/
|
|
2154
|
-
|
|
2169
|
+
setDynamicRepeat(repeat: boolean, ms: number): Promise<this>;
|
|
2155
2170
|
/**
|
|
2156
|
-
*
|
|
2157
|
-
*
|
|
2158
|
-
* @returns {Promise<
|
|
2159
|
-
* @private
|
|
2171
|
+
* Restarts the currently playing track from the beginning.
|
|
2172
|
+
* If there is no track playing, it will play the next track in the queue.
|
|
2173
|
+
* @returns {Promise<Player>} The current instance of the Player class for method chaining.
|
|
2160
2174
|
*/
|
|
2161
|
-
|
|
2175
|
+
restart(): Promise<Player>;
|
|
2162
2176
|
/**
|
|
2163
|
-
*
|
|
2164
|
-
* @param {
|
|
2165
|
-
* @
|
|
2166
|
-
* @
|
|
2167
|
-
* @private
|
|
2177
|
+
* Stops the player and optionally removes tracks from the queue.
|
|
2178
|
+
* @param {number} [amount] The amount of tracks to remove from the queue. If not provided, removes the current track if it exists.
|
|
2179
|
+
* @returns {Promise<this>} - The player instance.
|
|
2180
|
+
* @throws {RangeError} If the amount is greater than the queue length.
|
|
2168
2181
|
*/
|
|
2169
|
-
|
|
2182
|
+
stop(amount?: number): Promise<this>;
|
|
2170
2183
|
/**
|
|
2171
|
-
*
|
|
2172
|
-
* @
|
|
2173
|
-
* @
|
|
2174
|
-
* @
|
|
2175
|
-
* @private
|
|
2184
|
+
* Skips the current track.
|
|
2185
|
+
* @returns {this} - The player instance.
|
|
2186
|
+
* @throws {Error} If there are no tracks in the queue.
|
|
2187
|
+
* @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
|
|
2176
2188
|
*/
|
|
2177
|
-
|
|
2189
|
+
pause(pause: boolean): Promise<this>;
|
|
2178
2190
|
/**
|
|
2179
|
-
*
|
|
2180
|
-
*
|
|
2181
|
-
*
|
|
2182
|
-
*
|
|
2183
|
-
* @param {Player} player - The player to handle autoplay for.
|
|
2184
|
-
* @param {number} attempt - The current attempt number of the autoplay.
|
|
2185
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if autoplay was successful.
|
|
2186
|
-
* @private
|
|
2191
|
+
* Skips to the previous track in the queue.
|
|
2192
|
+
* @returns {this} - The player instance.
|
|
2193
|
+
* @throws {Error} If there are no previous tracks in the queue.
|
|
2194
|
+
* @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
|
|
2187
2195
|
*/
|
|
2188
|
-
|
|
2196
|
+
previous(): Promise<this>;
|
|
2189
2197
|
/**
|
|
2190
|
-
*
|
|
2191
|
-
*
|
|
2192
|
-
*
|
|
2193
|
-
*
|
|
2194
|
-
*
|
|
2195
|
-
* @param {Player} player - The player instance associated with the track.
|
|
2196
|
-
* @param {Track} track - The track that failed.
|
|
2197
|
-
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
2198
|
-
* @returns {Promise<void>} A promise that resolves when the track failure has been processed.
|
|
2199
|
-
* @private
|
|
2198
|
+
* Seeks to a given position in the currently playing track.
|
|
2199
|
+
* @param position - The position in milliseconds to seek to.
|
|
2200
|
+
* @returns {this} - The player instance.
|
|
2201
|
+
* @throws {Error} If the position is invalid.
|
|
2202
|
+
* @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
|
|
2200
2203
|
*/
|
|
2201
|
-
|
|
2204
|
+
seek(position: number): Promise<this>;
|
|
2202
2205
|
/**
|
|
2203
|
-
*
|
|
2204
|
-
*
|
|
2205
|
-
*
|
|
2206
|
-
* If autoplay is enabled, plays the next track.
|
|
2207
|
-
*
|
|
2208
|
-
* @param {Player} player - The player instance associated with the track.
|
|
2209
|
-
* @param {Track} track - The track that is repeated.
|
|
2210
|
-
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
2211
|
-
* @returns {Promise<void>} A promise that resolves when the repeated track has been processed.
|
|
2212
|
-
* @private
|
|
2206
|
+
* Returns the current repeat state of the player.
|
|
2207
|
+
* @param player The player to get the repeat state from.
|
|
2208
|
+
* @returns The repeat state of the player, or null if it is not repeating.
|
|
2213
2209
|
*/
|
|
2214
|
-
private
|
|
2210
|
+
private getRepeatState;
|
|
2215
2211
|
/**
|
|
2216
|
-
*
|
|
2217
|
-
*
|
|
2218
|
-
* and plays the next track if autoplay is enabled.
|
|
2219
|
-
*
|
|
2220
|
-
* @param {Player} player - The player associated with the track.
|
|
2221
|
-
* @param {Track} track - The track that has ended.
|
|
2222
|
-
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
2223
|
-
* @returns {void}
|
|
2224
|
-
* @private
|
|
2212
|
+
* Automatically moves the player to a usable node.
|
|
2213
|
+
* @returns {Promise<Player | void>} - The player instance or void if not moved.
|
|
2225
2214
|
*/
|
|
2226
|
-
|
|
2215
|
+
autoMoveNode(): Promise<Player | void>;
|
|
2227
2216
|
/**
|
|
2228
|
-
*
|
|
2229
|
-
*
|
|
2230
|
-
*
|
|
2231
|
-
* @param {Player} player - The player associated with the track.
|
|
2232
|
-
* @param {Track} track - The track that has ended.
|
|
2233
|
-
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
2234
|
-
* @returns {Promise<void>} A promise that resolves when the queue end processing is complete.
|
|
2217
|
+
* Moves the player to another node.
|
|
2218
|
+
* @param {string} identifier - The identifier of the node to move to.
|
|
2219
|
+
* @returns {Promise<Player>} - The player instance after being moved.
|
|
2235
2220
|
*/
|
|
2236
|
-
|
|
2221
|
+
moveNode(identifier: string): Promise<Player>;
|
|
2237
2222
|
/**
|
|
2238
|
-
*
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2241
|
-
*
|
|
2242
|
-
*
|
|
2243
|
-
*
|
|
2244
|
-
*
|
|
2245
|
-
* @param {Track} track - The track to fetch the lyrics for.
|
|
2246
|
-
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
2247
|
-
* @param {string} [language="en"] - The language of the lyrics.
|
|
2248
|
-
* @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
|
|
2223
|
+
* Transfers the player to a new server. If the player already exists on the new server
|
|
2224
|
+
* and force is false, this method will return the existing player. Otherwise, a new player
|
|
2225
|
+
* will be created and the current player will be destroyed.
|
|
2226
|
+
* @param {PlayerOptions} newOptions - The new options for the player.
|
|
2227
|
+
* @param {boolean} force - Whether to force the creation of a new player.
|
|
2228
|
+
* @returns {Promise<Player>} - The new player instance.
|
|
2249
2229
|
*/
|
|
2250
|
-
|
|
2230
|
+
switchGuild(newOptions: PlayerOptions, force?: boolean): Promise<Player>;
|
|
2251
2231
|
/**
|
|
2252
|
-
*
|
|
2253
|
-
* @param
|
|
2254
|
-
* @
|
|
2255
|
-
* @
|
|
2256
|
-
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
2232
|
+
* Retrieves the current lyrics for the playing track.
|
|
2233
|
+
* @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics.
|
|
2234
|
+
* @returns {Promise<Lyrics>} - The lyrics of the current track.
|
|
2235
|
+
* @throws {RangeError} - If the 'lavalyrics-plugin' is not available on the Lavalink node.
|
|
2257
2236
|
*/
|
|
2258
|
-
|
|
2237
|
+
getCurrentLyrics(skipTrackSource?: boolean): Promise<Lyrics>;
|
|
2259
2238
|
/**
|
|
2260
|
-
*
|
|
2261
|
-
* @
|
|
2262
|
-
* @
|
|
2263
|
-
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
2239
|
+
* Sets up the voice receiver for the player.
|
|
2240
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is set up.
|
|
2241
|
+
* @throws {Error} - If the node is not a NodeLink.
|
|
2264
2242
|
*/
|
|
2265
|
-
|
|
2243
|
+
setupVoiceReceiver(): Promise<void>;
|
|
2266
2244
|
/**
|
|
2267
|
-
*
|
|
2268
|
-
*
|
|
2269
|
-
*
|
|
2270
|
-
* @param {Player} player - The player associated with the track that became stuck.
|
|
2271
|
-
* @param {Track} track - The track that became stuck.
|
|
2272
|
-
* @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event.
|
|
2273
|
-
* @returns {void}
|
|
2274
|
-
* @protected
|
|
2245
|
+
* Removes the voice receiver for the player.
|
|
2246
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is removed.
|
|
2247
|
+
* @throws {Error} - If the node is not a NodeLink.
|
|
2275
2248
|
*/
|
|
2276
|
-
|
|
2249
|
+
removeVoiceReceiver(): Promise<void>;
|
|
2277
2250
|
/**
|
|
2278
|
-
*
|
|
2279
|
-
*
|
|
2280
|
-
*
|
|
2281
|
-
* @
|
|
2282
|
-
* @param {Track} track - The track that had an error.
|
|
2283
|
-
* @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event.
|
|
2284
|
-
* @returns {void}
|
|
2285
|
-
* @protected
|
|
2251
|
+
* Closes the voice receiver for the player.
|
|
2252
|
+
* @param {number} code - The code to close the voice receiver with.
|
|
2253
|
+
* @param {string} reason - The reason to close the voice receiver with.
|
|
2254
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is closed.
|
|
2286
2255
|
*/
|
|
2287
|
-
|
|
2256
|
+
private closeVoiceReceiver;
|
|
2288
2257
|
/**
|
|
2289
|
-
*
|
|
2290
|
-
*
|
|
2291
|
-
* @param {Player} player - The player associated with the WebSocket connection.
|
|
2292
|
-
* @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event.
|
|
2258
|
+
* Reconnects the voice receiver for the player.
|
|
2259
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is reconnected.
|
|
2293
2260
|
*/
|
|
2294
|
-
|
|
2261
|
+
private reconnectVoiceReceiver;
|
|
2295
2262
|
/**
|
|
2296
|
-
*
|
|
2297
|
-
*
|
|
2298
|
-
* @param {Player} player - The player associated with the segments.
|
|
2299
|
-
* @param {Track} track - The track associated with the segments.
|
|
2300
|
-
* @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event.
|
|
2263
|
+
* Disconnects the voice receiver for the player.
|
|
2264
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is disconnected.
|
|
2301
2265
|
*/
|
|
2302
|
-
private
|
|
2266
|
+
private disconnectVoiceReceiver;
|
|
2303
2267
|
/**
|
|
2304
|
-
*
|
|
2305
|
-
*
|
|
2306
|
-
* @param {Player} player - The player associated with the skipped segment.
|
|
2307
|
-
* @param {Track} track - The track associated with the skipped segment.
|
|
2308
|
-
* @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event.
|
|
2268
|
+
* Opens the voice receiver for the player.
|
|
2269
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver is opened.
|
|
2309
2270
|
*/
|
|
2310
|
-
private
|
|
2271
|
+
private openVoiceReceiver;
|
|
2311
2272
|
/**
|
|
2312
|
-
*
|
|
2313
|
-
*
|
|
2314
|
-
* @
|
|
2315
|
-
* @param {Track} track - The track associated with the chapters.
|
|
2316
|
-
* @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event.
|
|
2273
|
+
* Handles a voice receiver message.
|
|
2274
|
+
* @param {string} payload - The payload to handle.
|
|
2275
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver message is handled.
|
|
2317
2276
|
*/
|
|
2318
|
-
private
|
|
2277
|
+
private onVoiceReceiverMessage;
|
|
2319
2278
|
/**
|
|
2320
|
-
*
|
|
2321
|
-
*
|
|
2322
|
-
* @
|
|
2323
|
-
* @param {Track} track - The track associated with the started chapter.
|
|
2324
|
-
* @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
|
|
2279
|
+
* Handles a voice receiver error.
|
|
2280
|
+
* @param {Error} error - The error to handle.
|
|
2281
|
+
* @returns {Promise<void>} - A promise that resolves when the voice receiver error is handled.
|
|
2325
2282
|
*/
|
|
2326
|
-
private
|
|
2283
|
+
private onVoiceReceiverError;
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
/** Handles the requests sent to the Lavalink REST API. */
|
|
2287
|
+
declare class Rest {
|
|
2288
|
+
/** The Node that this Rest instance is connected to. */
|
|
2289
|
+
private node;
|
|
2290
|
+
/** The ID of the current session. */
|
|
2291
|
+
private sessionId;
|
|
2292
|
+
/** The password for the Node. */
|
|
2293
|
+
private readonly password;
|
|
2294
|
+
/** The URL of the Node. */
|
|
2295
|
+
private readonly url;
|
|
2296
|
+
/** The Manager instance. */
|
|
2297
|
+
manager: Manager;
|
|
2298
|
+
/** Whether the node is a NodeLink. */
|
|
2299
|
+
isNodeLink: boolean;
|
|
2300
|
+
constructor(node: Node, manager: Manager);
|
|
2327
2301
|
/**
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
* @param {
|
|
2331
|
-
* @
|
|
2332
|
-
* @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
|
|
2302
|
+
* Sets the session ID.
|
|
2303
|
+
* This method is used to set the session ID after a resume operation is done.
|
|
2304
|
+
* @param {string} sessionId The session ID to set.
|
|
2305
|
+
* @returns {string} Returns the set session ID.
|
|
2333
2306
|
*/
|
|
2334
|
-
|
|
2307
|
+
setSessionId(sessionId: string): string;
|
|
2335
2308
|
/**
|
|
2336
|
-
*
|
|
2337
|
-
*
|
|
2338
|
-
* @param {Player} player - The player associated with the lyrics.
|
|
2339
|
-
* @param {Track} track - The track associated with the lyrics.
|
|
2340
|
-
* @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
|
|
2309
|
+
* Retrieves all the players that are currently running on the node.
|
|
2310
|
+
* @returns {Promise<unknown>} Returns the result of the GET request.
|
|
2341
2311
|
*/
|
|
2342
|
-
|
|
2312
|
+
getAllPlayers(): Promise<unknown>;
|
|
2343
2313
|
/**
|
|
2344
|
-
*
|
|
2345
|
-
*
|
|
2346
|
-
* @
|
|
2347
|
-
* @param {Track} track - The track associated with the lyrics line.
|
|
2348
|
-
* @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
|
|
2314
|
+
* Sends a PATCH request to update player related data.
|
|
2315
|
+
* @param {RestPlayOptions} options The options to update the player with.
|
|
2316
|
+
* @returns {Promise<unknown>} Returns the result of the PATCH request.
|
|
2349
2317
|
*/
|
|
2350
|
-
|
|
2318
|
+
updatePlayer(options: RestPlayOptions): Promise<unknown>;
|
|
2351
2319
|
/**
|
|
2352
|
-
*
|
|
2353
|
-
* @
|
|
2320
|
+
* Sends a DELETE request to the server to destroy the player.
|
|
2321
|
+
* @param {string} guildId The guild ID of the player to destroy.
|
|
2322
|
+
* @returns {Promise<unknown>} Returns the result of the DELETE request.
|
|
2354
2323
|
*/
|
|
2355
|
-
|
|
2324
|
+
destroyPlayer(guildId: string): Promise<unknown>;
|
|
2356
2325
|
/**
|
|
2357
|
-
*
|
|
2358
|
-
*
|
|
2359
|
-
*
|
|
2360
|
-
* @
|
|
2326
|
+
* Updates the session status for resuming.
|
|
2327
|
+
* This method sends a PATCH request to update the session's resuming status and timeout.
|
|
2328
|
+
*
|
|
2329
|
+
* @param {boolean} resuming - Indicates whether the session should be set to resuming.
|
|
2330
|
+
* @param {number} timeout - The timeout duration for the session resume.
|
|
2331
|
+
* @returns {Promise<unknown>} The result of the PATCH request.
|
|
2361
2332
|
*/
|
|
2362
|
-
|
|
2333
|
+
updateSession(resuming: boolean, timeout: number): Promise<unknown>;
|
|
2363
2334
|
/**
|
|
2364
|
-
*
|
|
2365
|
-
* @param {
|
|
2366
|
-
* @param {
|
|
2367
|
-
* @
|
|
2368
|
-
* @
|
|
2369
|
-
* @throws {RangeError} If no segments are provided.
|
|
2370
|
-
* @throws {SyntaxError} If an invalid sponsorblock is provided.
|
|
2371
|
-
* @example
|
|
2372
|
-
* ```ts
|
|
2373
|
-
* // use it on the player via player.setSponsorBlock();
|
|
2374
|
-
* player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]);
|
|
2375
|
-
* ```
|
|
2335
|
+
* Sends a request to the specified endpoint and returns the response data.
|
|
2336
|
+
* @param {string} method The HTTP method to use for the request.
|
|
2337
|
+
* @param {string} endpoint The endpoint to send the request to.
|
|
2338
|
+
* @param {unknown} [body] The data to send in the request body.
|
|
2339
|
+
* @returns {Promise<unknown>} The response data of the request.
|
|
2376
2340
|
*/
|
|
2377
|
-
|
|
2341
|
+
private request;
|
|
2378
2342
|
/**
|
|
2379
|
-
*
|
|
2380
|
-
* @param {
|
|
2381
|
-
* @returns {Promise<
|
|
2382
|
-
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
2343
|
+
* Sends a GET request to the specified endpoint and returns the response data.
|
|
2344
|
+
* @param {string} endpoint The endpoint to send the GET request to.
|
|
2345
|
+
* @returns {Promise<unknown>} The response data of the GET request.
|
|
2383
2346
|
*/
|
|
2384
|
-
|
|
2347
|
+
get(endpoint: string): Promise<unknown>;
|
|
2385
2348
|
/**
|
|
2386
|
-
*
|
|
2387
|
-
*
|
|
2388
|
-
*
|
|
2389
|
-
* @
|
|
2349
|
+
* Sends a PATCH request to the specified endpoint and returns the response data.
|
|
2350
|
+
* @param {string} endpoint The endpoint to send the PATCH request to.
|
|
2351
|
+
* @param {unknown} body The data to send in the request body.
|
|
2352
|
+
* @returns {Promise<unknown>} The response data of the PATCH request.
|
|
2390
2353
|
*/
|
|
2391
|
-
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
/**
|
|
2395
|
-
* The main hub for interacting with Lavalink and using Magmastream.
|
|
2396
|
-
*/
|
|
2397
|
-
declare class Manager extends EventEmitter {
|
|
2398
|
-
/** The map of players. */
|
|
2399
|
-
readonly players: Collection<string, Player>;
|
|
2400
|
-
/** The map of nodes. */
|
|
2401
|
-
readonly nodes: Collection<string, Node>;
|
|
2402
|
-
/** The options that were set. */
|
|
2403
|
-
readonly options: ManagerOptions;
|
|
2404
|
-
initiated: boolean;
|
|
2405
|
-
redis?: Redis;
|
|
2406
|
-
private _send;
|
|
2407
|
-
private loadedPlugins;
|
|
2354
|
+
patch(endpoint: string, body: unknown): Promise<unknown>;
|
|
2408
2355
|
/**
|
|
2409
|
-
*
|
|
2410
|
-
* @param
|
|
2411
|
-
* @param
|
|
2412
|
-
* @
|
|
2413
|
-
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
2414
|
-
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
2415
|
-
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
2416
|
-
* @param options.clientName - The name of the client to send to Lavalink.
|
|
2417
|
-
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
2418
|
-
* @param options.useNode - The strategy to use when selecting a node to play on.
|
|
2419
|
-
* @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
|
|
2420
|
-
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
2421
|
-
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
2356
|
+
* Sends a POST request to the specified endpoint and returns the response data.
|
|
2357
|
+
* @param {string} endpoint The endpoint to send the POST request to.
|
|
2358
|
+
* @param {unknown} body The data to send in the request body.
|
|
2359
|
+
* @returns {Promise<unknown>} The response data of the POST request.
|
|
2422
2360
|
*/
|
|
2423
|
-
|
|
2361
|
+
post(endpoint: string, body: unknown): Promise<unknown>;
|
|
2424
2362
|
/**
|
|
2425
|
-
*
|
|
2426
|
-
* @param
|
|
2427
|
-
* @param
|
|
2428
|
-
* @returns The
|
|
2363
|
+
* Sends a PUT request to the specified endpoint and returns the response data.
|
|
2364
|
+
* @param {string} endpoint The endpoint to send the PUT request to.
|
|
2365
|
+
* @param {unknown} body The data to send in the request body.
|
|
2366
|
+
* @returns {Promise<unknown>} The response data of the PUT request.
|
|
2429
2367
|
*/
|
|
2430
|
-
|
|
2368
|
+
put(endpoint: string, body: unknown): Promise<unknown>;
|
|
2431
2369
|
/**
|
|
2432
|
-
*
|
|
2433
|
-
* @param
|
|
2434
|
-
* @
|
|
2435
|
-
* @returns The search result.
|
|
2370
|
+
* Sends a DELETE request to the specified endpoint.
|
|
2371
|
+
* @param {string} endpoint - The endpoint to send the DELETE request to.
|
|
2372
|
+
* @returns {Promise<unknown>} The response data of the DELETE request.
|
|
2436
2373
|
*/
|
|
2437
|
-
|
|
2374
|
+
delete(endpoint: string): Promise<unknown>;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
declare class Node {
|
|
2378
|
+
manager: Manager;
|
|
2379
|
+
options: NodeOptions;
|
|
2380
|
+
/** The socket for the node. */
|
|
2381
|
+
socket: WebSocket$1 | null;
|
|
2382
|
+
/** The stats for the node. */
|
|
2383
|
+
stats: NodeStats;
|
|
2384
|
+
/** The manager for the node */
|
|
2385
|
+
/** The node's session ID. */
|
|
2386
|
+
sessionId: string | null;
|
|
2387
|
+
/** The REST instance. */
|
|
2388
|
+
readonly rest: Rest;
|
|
2389
|
+
/** Actual Lavalink information of the node. */
|
|
2390
|
+
info: LavalinkInfo | null;
|
|
2391
|
+
/** Whether the node is a NodeLink. */
|
|
2392
|
+
isNodeLink: boolean;
|
|
2393
|
+
private reconnectTimeout?;
|
|
2394
|
+
private reconnectAttempts;
|
|
2395
|
+
private redisPrefix?;
|
|
2396
|
+
private sessionIdsFilePath?;
|
|
2397
|
+
private sessionIdsMap;
|
|
2438
2398
|
/**
|
|
2439
|
-
*
|
|
2440
|
-
* @param
|
|
2441
|
-
* @
|
|
2399
|
+
* Creates an instance of Node.
|
|
2400
|
+
* @param manager - The manager for the node.
|
|
2401
|
+
* @param options - The options for the node.
|
|
2442
2402
|
*/
|
|
2443
|
-
|
|
2403
|
+
constructor(manager: Manager, options: NodeOptions);
|
|
2444
2404
|
/**
|
|
2445
|
-
*
|
|
2446
|
-
*
|
|
2447
|
-
* @returns The created player.
|
|
2405
|
+
* Checks if the Node is currently connected.
|
|
2406
|
+
* This method returns true if the Node has an active WebSocket connection, indicating it is ready to receive and process commands.
|
|
2448
2407
|
*/
|
|
2449
|
-
|
|
2408
|
+
get connected(): boolean;
|
|
2409
|
+
/** Returns the full address for this node, including the host and port. */
|
|
2410
|
+
get address(): string;
|
|
2450
2411
|
/**
|
|
2451
|
-
*
|
|
2452
|
-
*
|
|
2453
|
-
*
|
|
2412
|
+
* Creates the sessionIds.json file if it doesn't exist. This file is used to
|
|
2413
|
+
* store the session IDs for each node. The session IDs are used to identify
|
|
2414
|
+
* the node when resuming a session.
|
|
2454
2415
|
*/
|
|
2455
|
-
|
|
2416
|
+
createSessionIdsFile(): void;
|
|
2456
2417
|
/**
|
|
2457
|
-
*
|
|
2458
|
-
*
|
|
2459
|
-
*
|
|
2418
|
+
* Loads session IDs from the sessionIds.json file if it exists.
|
|
2419
|
+
* The session IDs are used to resume sessions for each node.
|
|
2420
|
+
*
|
|
2421
|
+
* The session IDs are stored in the sessionIds.json file as a composite key
|
|
2422
|
+
* of the node identifier and cluster ID. This allows multiple clusters to
|
|
2423
|
+
* be used with the same node identifier.
|
|
2460
2424
|
*/
|
|
2461
|
-
|
|
2425
|
+
loadSessionIds(): Promise<void>;
|
|
2462
2426
|
/**
|
|
2463
|
-
*
|
|
2464
|
-
*
|
|
2465
|
-
*
|
|
2466
|
-
*
|
|
2427
|
+
* Updates the session ID in the sessionIds.json file.
|
|
2428
|
+
*
|
|
2429
|
+
* This method is called after the session ID has been updated, and it
|
|
2430
|
+
* writes the new session ID to the sessionIds.json file.
|
|
2431
|
+
*
|
|
2432
|
+
* @remarks
|
|
2433
|
+
* The session ID is stored in the sessionIds.json file as a composite key
|
|
2434
|
+
* of the node identifier and cluster ID. This allows multiple clusters to
|
|
2435
|
+
* be used with the same node identifier.
|
|
2467
2436
|
*/
|
|
2468
|
-
|
|
2437
|
+
updateSessionId(): Promise<void>;
|
|
2469
2438
|
/**
|
|
2470
|
-
*
|
|
2471
|
-
*
|
|
2472
|
-
* @
|
|
2473
|
-
*
|
|
2439
|
+
* Connects to the Node.
|
|
2440
|
+
*
|
|
2441
|
+
* @remarks
|
|
2442
|
+
* If the node is already connected, this method will do nothing.
|
|
2443
|
+
* If the node has a session ID, it will be sent in the headers of the WebSocket connection.
|
|
2444
|
+
* If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID
|
|
2445
|
+
* stored in the sessionIds.json file if it exists.
|
|
2474
2446
|
*/
|
|
2475
|
-
|
|
2447
|
+
connect(): Promise<void>;
|
|
2476
2448
|
/**
|
|
2477
|
-
*
|
|
2478
|
-
*
|
|
2479
|
-
*
|
|
2480
|
-
*
|
|
2449
|
+
* Destroys the node and cleans up associated resources.
|
|
2450
|
+
*
|
|
2451
|
+
* This method emits a debug event indicating that the node is being destroyed and attempts
|
|
2452
|
+
* to automatically move all players connected to the node to a usable one. It then closes
|
|
2453
|
+
* the WebSocket connection, removes all event listeners, and clears the reconnect timeout.
|
|
2454
|
+
* Finally, it emits a "nodeDestroy" event and removes the node from the manager.
|
|
2455
|
+
*
|
|
2456
|
+
* @returns {Promise<void>} A promise that resolves when the node and its resources have been destroyed.
|
|
2481
2457
|
*/
|
|
2482
|
-
|
|
2458
|
+
destroy(): Promise<void>;
|
|
2483
2459
|
/**
|
|
2484
|
-
*
|
|
2485
|
-
*
|
|
2486
|
-
*
|
|
2487
|
-
*
|
|
2488
|
-
*
|
|
2460
|
+
* Attempts to reconnect to the node if the connection is lost.
|
|
2461
|
+
*
|
|
2462
|
+
* This method is called when the WebSocket connection is closed
|
|
2463
|
+
* unexpectedly. It will attempt to reconnect to the node after a
|
|
2464
|
+
* specified delay, and will continue to do so until the maximum
|
|
2465
|
+
* number of retry attempts is reached or the node is manually destroyed.
|
|
2466
|
+
* If the maximum number of retry attempts is reached, an error event
|
|
2467
|
+
* will be emitted and the node will be destroyed.
|
|
2468
|
+
*
|
|
2469
|
+
* @returns {Promise<void>} - Resolves when the reconnection attempt is scheduled.
|
|
2470
|
+
* @emits {debug} - Emits a debug event indicating the node is attempting to reconnect.
|
|
2471
|
+
* @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect.
|
|
2472
|
+
* @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached.
|
|
2473
|
+
* @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached.
|
|
2489
2474
|
*/
|
|
2490
|
-
|
|
2475
|
+
private reconnect;
|
|
2491
2476
|
/**
|
|
2492
|
-
*
|
|
2493
|
-
*
|
|
2494
|
-
* @
|
|
2495
|
-
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
2477
|
+
* Upgrades the node to a NodeLink.
|
|
2478
|
+
*
|
|
2479
|
+
* @param request - The incoming message.
|
|
2496
2480
|
*/
|
|
2497
|
-
|
|
2481
|
+
private upgrade;
|
|
2498
2482
|
/**
|
|
2499
|
-
*
|
|
2500
|
-
*
|
|
2483
|
+
* Handles the "open" event emitted by the WebSocket connection.
|
|
2484
|
+
*
|
|
2485
|
+
* This method is called when the WebSocket connection is established.
|
|
2486
|
+
* It clears any existing reconnect timeouts, emits a debug event
|
|
2487
|
+
* indicating the node is connected, and emits a "nodeConnect" event
|
|
2488
|
+
* with the node as the argument.
|
|
2501
2489
|
*/
|
|
2502
|
-
|
|
2490
|
+
protected open(): void;
|
|
2503
2491
|
/**
|
|
2504
|
-
*
|
|
2505
|
-
*
|
|
2506
|
-
*
|
|
2492
|
+
* Handles the "close" event emitted by the WebSocket connection.
|
|
2493
|
+
*
|
|
2494
|
+
* This method is called when the WebSocket connection is closed.
|
|
2495
|
+
* It emits a "nodeDisconnect" event with the node and the close event as arguments,
|
|
2496
|
+
* and a debug event indicating the node is disconnected.
|
|
2497
|
+
* It then attempts to move all players connected to that node to a useable one.
|
|
2498
|
+
* If the close event was not initiated by the user, it will also attempt to reconnect.
|
|
2499
|
+
*
|
|
2500
|
+
* @param {number} code The close code of the WebSocket connection.
|
|
2501
|
+
* @param {string} reason The reason for the close event.
|
|
2502
|
+
* @returns {Promise<void>} A promise that resolves when the disconnection is handled.
|
|
2507
2503
|
*/
|
|
2508
|
-
|
|
2504
|
+
protected close(code: number, reason: string): Promise<void>;
|
|
2509
2505
|
/**
|
|
2510
|
-
*
|
|
2511
|
-
*
|
|
2512
|
-
*
|
|
2506
|
+
* Handles the "error" event emitted by the WebSocket connection.
|
|
2507
|
+
*
|
|
2508
|
+
* This method is called when an error occurs on the WebSocket connection.
|
|
2509
|
+
* It emits a "nodeError" event with the node and the error as arguments and
|
|
2510
|
+
* a debug event indicating the error on the node.
|
|
2511
|
+
* @param {Error} error The error that occurred.
|
|
2513
2512
|
*/
|
|
2514
|
-
|
|
2513
|
+
protected error(error: Error): void;
|
|
2515
2514
|
/**
|
|
2516
|
-
*
|
|
2517
|
-
*
|
|
2518
|
-
*
|
|
2519
|
-
*
|
|
2520
|
-
* @
|
|
2515
|
+
* Handles incoming messages from the Lavalink WebSocket connection.
|
|
2516
|
+
* @param {Buffer | string} d The message received from the WebSocket connection.
|
|
2517
|
+
* @returns {Promise<void>} A promise that resolves when the message is handled.
|
|
2518
|
+
* @emits {debug} - Emits a debug event with the message received from the WebSocket connection.
|
|
2519
|
+
* @emits {nodeError} - Emits a nodeError event if an unexpected op is received.
|
|
2520
|
+
* @emits {nodeRaw} - Emits a nodeRaw event with the raw message received from the WebSocket connection.
|
|
2521
|
+
* @private
|
|
2521
2522
|
*/
|
|
2522
|
-
|
|
2523
|
+
protected message(d: Buffer | string): Promise<void>;
|
|
2523
2524
|
/**
|
|
2524
|
-
* Handles
|
|
2525
|
-
*
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
* After saving and cleaning up, it exits the process.
|
|
2525
|
+
* Handles an event emitted from the Lavalink node.
|
|
2526
|
+
* @param {PlayerEvent & PlayerEvents} payload The event emitted from the node.
|
|
2527
|
+
* @returns {Promise<void>} A promise that resolves when the event has been handled.
|
|
2528
|
+
* @private
|
|
2529
2529
|
*/
|
|
2530
|
-
|
|
2530
|
+
protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>;
|
|
2531
2531
|
/**
|
|
2532
|
-
*
|
|
2533
|
-
* @param
|
|
2534
|
-
* @param
|
|
2535
|
-
* @
|
|
2532
|
+
* Emitted when a new track starts playing.
|
|
2533
|
+
* @param {Player} player The player that started playing the track.
|
|
2534
|
+
* @param {Track} track The track that started playing.
|
|
2535
|
+
* @param {TrackStartEvent} payload The payload of the event emitted by the node.
|
|
2536
|
+
* @private
|
|
2536
2537
|
*/
|
|
2537
|
-
|
|
2538
|
+
protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void;
|
|
2538
2539
|
/**
|
|
2539
|
-
*
|
|
2540
|
-
* @param
|
|
2541
|
-
* @
|
|
2540
|
+
* Emitted when a track ends playing.
|
|
2541
|
+
* @param {Player} player - The player that the track ended on.
|
|
2542
|
+
* @param {Track} track - The track that ended.
|
|
2543
|
+
* @param {TrackEndEvent} payload - The payload of the event emitted by the node.
|
|
2544
|
+
* @private
|
|
2542
2545
|
*/
|
|
2543
|
-
|
|
2546
|
+
trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
|
|
2544
2547
|
/**
|
|
2545
|
-
*
|
|
2546
|
-
*
|
|
2547
|
-
*
|
|
2548
|
+
* Handles autoplay logic for a player.
|
|
2549
|
+
* This method is responsible for selecting an appropriate method of autoplay
|
|
2550
|
+
* and executing it. If autoplay is not enabled or all attempts have failed,
|
|
2551
|
+
* it will return false.
|
|
2552
|
+
* @param {Player} player - The player to handle autoplay for.
|
|
2553
|
+
* @param {number} attempt - The current attempt number of the autoplay.
|
|
2554
|
+
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if autoplay was successful.
|
|
2555
|
+
* @private
|
|
2548
2556
|
*/
|
|
2549
|
-
private
|
|
2557
|
+
private handleAutoplay;
|
|
2550
2558
|
/**
|
|
2551
|
-
*
|
|
2552
|
-
*
|
|
2553
|
-
*
|
|
2559
|
+
* Handles the scenario when a track fails to play or load.
|
|
2560
|
+
* Shifts the queue to the next track and emits a track end event.
|
|
2561
|
+
* If there is no next track, handles the queue end scenario.
|
|
2562
|
+
* If autoplay is enabled, plays the next track.
|
|
2563
|
+
*
|
|
2564
|
+
* @param {Player} player - The player instance associated with the track.
|
|
2565
|
+
* @param {Track} track - The track that failed.
|
|
2566
|
+
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
2567
|
+
* @returns {Promise<void>} A promise that resolves when the track failure has been processed.
|
|
2568
|
+
* @private
|
|
2554
2569
|
*/
|
|
2555
|
-
private
|
|
2570
|
+
private handleFailedTrack;
|
|
2556
2571
|
/**
|
|
2557
|
-
*
|
|
2558
|
-
*
|
|
2572
|
+
* Handles the scenario when a track is repeated.
|
|
2573
|
+
* Shifts the queue to the next track and emits a track end event.
|
|
2574
|
+
* If there is no next track, handles the queue end scenario.
|
|
2575
|
+
* If autoplay is enabled, plays the next track.
|
|
2559
2576
|
*
|
|
2560
|
-
* @param
|
|
2561
|
-
* @
|
|
2577
|
+
* @param {Player} player - The player instance associated with the track.
|
|
2578
|
+
* @param {Track} track - The track that is repeated.
|
|
2579
|
+
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
2580
|
+
* @returns {Promise<void>} A promise that resolves when the repeated track has been processed.
|
|
2581
|
+
* @private
|
|
2562
2582
|
*/
|
|
2563
|
-
private
|
|
2583
|
+
private handleRepeatedTrack;
|
|
2564
2584
|
/**
|
|
2565
|
-
*
|
|
2566
|
-
*
|
|
2567
|
-
*
|
|
2568
|
-
*
|
|
2569
|
-
* @
|
|
2585
|
+
* Plays the next track in the queue.
|
|
2586
|
+
* Updates the queue by shifting the current track to the previous track
|
|
2587
|
+
* and plays the next track if autoplay is enabled.
|
|
2588
|
+
*
|
|
2589
|
+
* @param {Player} player - The player associated with the track.
|
|
2590
|
+
* @param {Track} track - The track that has ended.
|
|
2591
|
+
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
2592
|
+
* @returns {void}
|
|
2593
|
+
* @private
|
|
2570
2594
|
*/
|
|
2571
|
-
private
|
|
2595
|
+
private playNextTrack;
|
|
2572
2596
|
/**
|
|
2573
|
-
* Handles
|
|
2574
|
-
*
|
|
2575
|
-
*
|
|
2576
|
-
* @
|
|
2577
|
-
* @
|
|
2597
|
+
* Handles the event when a queue ends.
|
|
2598
|
+
* If autoplay is enabled, attempts to play the next track in the queue using the autoplay logic.
|
|
2599
|
+
* If all attempts fail, resets the player state and emits the `queueEnd` event.
|
|
2600
|
+
* @param {Player} player - The player associated with the track.
|
|
2601
|
+
* @param {Track} track - The track that has ended.
|
|
2602
|
+
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
2603
|
+
* @returns {Promise<void>} A promise that resolves when the queue end processing is complete.
|
|
2578
2604
|
*/
|
|
2579
|
-
|
|
2605
|
+
queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
|
|
2580
2606
|
/**
|
|
2581
|
-
*
|
|
2582
|
-
*
|
|
2607
|
+
* Fetches the lyrics of a track from the Lavalink node.
|
|
2608
|
+
*
|
|
2609
|
+
* If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
|
|
2610
|
+
*
|
|
2611
|
+
* Requires the `lavalyrics-plugin` to be present in the Lavalink node.
|
|
2612
|
+
* Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
|
|
2613
|
+
*
|
|
2614
|
+
* @param {Track} track - The track to fetch the lyrics for.
|
|
2615
|
+
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
2616
|
+
* @param {string} [language="en"] - The language of the lyrics.
|
|
2617
|
+
* @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
|
|
2583
2618
|
*/
|
|
2584
|
-
|
|
2619
|
+
getLyrics(track: Track, skipTrackSource?: boolean, language?: string): Promise<Lyrics | NodeLinkGetLyrics>;
|
|
2585
2620
|
/**
|
|
2586
|
-
*
|
|
2587
|
-
*
|
|
2588
|
-
* @param
|
|
2621
|
+
* Subscribes to lyrics for a player.
|
|
2622
|
+
* @param {string} guildId - The ID of the guild to subscribe to lyrics for.
|
|
2623
|
+
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
2624
|
+
* @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
|
|
2625
|
+
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
2589
2626
|
*/
|
|
2590
|
-
|
|
2627
|
+
lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
|
|
2591
2628
|
/**
|
|
2592
|
-
*
|
|
2629
|
+
* Unsubscribes from lyrics for a player.
|
|
2630
|
+
* @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
|
|
2631
|
+
* @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
|
|
2632
|
+
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
2593
2633
|
*/
|
|
2594
|
-
|
|
2634
|
+
lyricsUnsubscribe(guildId: string): Promise<unknown>;
|
|
2595
2635
|
/**
|
|
2596
|
-
*
|
|
2636
|
+
* Handles the event when a track becomes stuck during playback.
|
|
2637
|
+
* Stops the current track and emits a `trackStuck` event.
|
|
2638
|
+
*
|
|
2639
|
+
* @param {Player} player - The player associated with the track that became stuck.
|
|
2640
|
+
* @param {Track} track - The track that became stuck.
|
|
2641
|
+
* @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event.
|
|
2642
|
+
* @returns {void}
|
|
2643
|
+
* @protected
|
|
2597
2644
|
*/
|
|
2598
|
-
|
|
2645
|
+
protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): Promise<void>;
|
|
2599
2646
|
/**
|
|
2600
|
-
*
|
|
2601
|
-
*
|
|
2647
|
+
* Handles the event when a track has an error during playback.
|
|
2648
|
+
* Stops the current track and emits a `trackError` event.
|
|
2649
|
+
*
|
|
2650
|
+
* @param {Player} player - The player associated with the track that had an error.
|
|
2651
|
+
* @param {Track} track - The track that had an error.
|
|
2652
|
+
* @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event.
|
|
2653
|
+
* @returns {void}
|
|
2654
|
+
* @protected
|
|
2602
2655
|
*/
|
|
2603
|
-
|
|
2656
|
+
protected trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise<void>;
|
|
2604
2657
|
/**
|
|
2605
|
-
*
|
|
2606
|
-
* The
|
|
2607
|
-
*
|
|
2608
|
-
* @
|
|
2658
|
+
* Emitted when the WebSocket connection for a player closes.
|
|
2659
|
+
* The payload of the event will contain the close code and reason if provided.
|
|
2660
|
+
* @param {Player} player - The player associated with the WebSocket connection.
|
|
2661
|
+
* @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event.
|
|
2609
2662
|
*/
|
|
2610
|
-
|
|
2663
|
+
protected socketClosed(player: Player, payload: WebSocketClosedEvent): void;
|
|
2611
2664
|
/**
|
|
2612
|
-
*
|
|
2613
|
-
*
|
|
2614
|
-
*
|
|
2615
|
-
* @
|
|
2665
|
+
* Emitted when the segments for a track are loaded.
|
|
2666
|
+
* The payload of the event will contain the segments.
|
|
2667
|
+
* @param {Player} player - The player associated with the segments.
|
|
2668
|
+
* @param {Track} track - The track associated with the segments.
|
|
2669
|
+
* @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event.
|
|
2616
2670
|
*/
|
|
2617
|
-
private
|
|
2671
|
+
private sponsorBlockSegmentLoaded;
|
|
2618
2672
|
/**
|
|
2619
|
-
*
|
|
2620
|
-
* The
|
|
2621
|
-
*
|
|
2622
|
-
*
|
|
2623
|
-
*
|
|
2624
|
-
* lowest load is returned.
|
|
2625
|
-
* @returns {Node} The node to use.
|
|
2673
|
+
* Emitted when a segment of a track is skipped using the sponsorblock plugin.
|
|
2674
|
+
* The payload of the event will contain the skipped segment.
|
|
2675
|
+
* @param {Player} player - The player associated with the skipped segment.
|
|
2676
|
+
* @param {Track} track - The track associated with the skipped segment.
|
|
2677
|
+
* @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event.
|
|
2626
2678
|
*/
|
|
2627
|
-
private
|
|
2628
|
-
protected send(packet: GatewayVoiceStateUpdate): unknown;
|
|
2629
|
-
sendPacket(packet: GatewayVoiceStateUpdate): unknown;
|
|
2630
|
-
}
|
|
2631
|
-
|
|
2632
|
-
declare class Player {
|
|
2633
|
-
options: PlayerOptions;
|
|
2634
|
-
/** The Queue for the Player. */
|
|
2635
|
-
queue: IQueue;
|
|
2636
|
-
/** The filters applied to the audio. */
|
|
2637
|
-
filters: Filters;
|
|
2638
|
-
/** Whether the queue repeats the track. */
|
|
2639
|
-
trackRepeat: boolean;
|
|
2640
|
-
/** Whether the queue repeats the queue. */
|
|
2641
|
-
queueRepeat: boolean;
|
|
2642
|
-
/**Whether the queue repeats and shuffles after each song. */
|
|
2643
|
-
dynamicRepeat: boolean;
|
|
2644
|
-
/** The time the player is in the track. */
|
|
2645
|
-
position: number;
|
|
2646
|
-
/** Whether the player is playing. */
|
|
2647
|
-
playing: boolean;
|
|
2648
|
-
/** Whether the player is paused. */
|
|
2649
|
-
paused: boolean;
|
|
2650
|
-
/** The volume for the player */
|
|
2651
|
-
volume: number;
|
|
2652
|
-
/** The Node for the Player. */
|
|
2653
|
-
node: Node;
|
|
2654
|
-
/** The guild ID for the player. */
|
|
2655
|
-
guildId: string;
|
|
2656
|
-
/** The voice channel for the player. */
|
|
2657
|
-
voiceChannelId: string | null;
|
|
2658
|
-
/** The text channel for the player. */
|
|
2659
|
-
textChannelId: string | null;
|
|
2660
|
-
/**The now playing message. */
|
|
2661
|
-
nowPlayingMessage?: Message;
|
|
2662
|
-
/** The current state of the player. */
|
|
2663
|
-
state: StateTypes;
|
|
2664
|
-
/** The equalizer bands array. */
|
|
2665
|
-
bands: number[];
|
|
2666
|
-
/** The voice state object from Discord. */
|
|
2667
|
-
voiceState: VoiceState;
|
|
2668
|
-
/** The Manager. */
|
|
2669
|
-
manager: Manager;
|
|
2670
|
-
/** The autoplay state of the player. */
|
|
2671
|
-
isAutoplay: boolean;
|
|
2672
|
-
/** The number of times to try autoplay before emitting queueEnd. */
|
|
2673
|
-
autoplayTries: number;
|
|
2674
|
-
/** The cluster ID for the player. */
|
|
2675
|
-
clusterId: number;
|
|
2676
|
-
private readonly data;
|
|
2677
|
-
private dynamicLoopInterval;
|
|
2678
|
-
dynamicRepeatIntervalMs: number | null;
|
|
2679
|
-
private static _manager;
|
|
2680
|
-
/** Should only be used when the node is a NodeLink */
|
|
2681
|
-
protected voiceReceiverWsClient: WebSocket$1 | null;
|
|
2682
|
-
protected isConnectToVoiceReceiver: boolean;
|
|
2683
|
-
protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
|
|
2684
|
-
protected voiceReceiverAttempt: number;
|
|
2685
|
-
protected voiceReceiverReconnectTries: number;
|
|
2679
|
+
private sponsorBlockSegmentSkipped;
|
|
2686
2680
|
/**
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
2689
|
-
* @
|
|
2681
|
+
* Emitted when chapters for a track are loaded using the sponsorblock plugin.
|
|
2682
|
+
* The payload of the event will contain the chapters.
|
|
2683
|
+
* @param {Player} player - The player associated with the chapters.
|
|
2684
|
+
* @param {Track} track - The track associated with the chapters.
|
|
2685
|
+
* @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event.
|
|
2690
2686
|
*/
|
|
2691
|
-
|
|
2687
|
+
private sponsorBlockChaptersLoaded;
|
|
2692
2688
|
/**
|
|
2693
|
-
*
|
|
2694
|
-
*
|
|
2695
|
-
* @param
|
|
2689
|
+
* Emitted when a chapter of a track is started using the sponsorblock plugin.
|
|
2690
|
+
* The payload of the event will contain the started chapter.
|
|
2691
|
+
* @param {Player} player - The player associated with the started chapter.
|
|
2692
|
+
* @param {Track} track - The track associated with the started chapter.
|
|
2693
|
+
* @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
|
|
2696
2694
|
*/
|
|
2697
|
-
|
|
2695
|
+
private sponsorBlockChapterStarted;
|
|
2698
2696
|
/**
|
|
2699
|
-
*
|
|
2700
|
-
*
|
|
2701
|
-
* @param
|
|
2697
|
+
* Emitted when lyrics for a track are found.
|
|
2698
|
+
* The payload of the event will contain the lyrics.
|
|
2699
|
+
* @param {Player} player - The player associated with the lyrics.
|
|
2700
|
+
* @param {Track} track - The track associated with the lyrics.
|
|
2701
|
+
* @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
|
|
2702
2702
|
*/
|
|
2703
|
-
|
|
2703
|
+
private lyricsFound;
|
|
2704
2704
|
/**
|
|
2705
|
-
*
|
|
2706
|
-
*
|
|
2707
|
-
* @param {
|
|
2708
|
-
* @
|
|
2705
|
+
* Emitted when lyrics for a track are not found.
|
|
2706
|
+
* The payload of the event will contain the track.
|
|
2707
|
+
* @param {Player} player - The player associated with the lyrics.
|
|
2708
|
+
* @param {Track} track - The track associated with the lyrics.
|
|
2709
|
+
* @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
|
|
2709
2710
|
*/
|
|
2710
|
-
|
|
2711
|
+
private lyricsNotFound;
|
|
2711
2712
|
/**
|
|
2712
|
-
*
|
|
2713
|
-
*
|
|
2714
|
-
* @param
|
|
2713
|
+
* Emitted when a line of lyrics for a track is received.
|
|
2714
|
+
* The payload of the event will contain the lyrics line.
|
|
2715
|
+
* @param {Player} player - The player associated with the lyrics line.
|
|
2716
|
+
* @param {Track} track - The track associated with the lyrics line.
|
|
2717
|
+
* @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
|
|
2715
2718
|
*/
|
|
2716
|
-
|
|
2719
|
+
private lyricsLine;
|
|
2717
2720
|
/**
|
|
2718
|
-
*
|
|
2719
|
-
* @
|
|
2720
|
-
* @returns {void}
|
|
2721
|
+
* Fetches Lavalink node information.
|
|
2722
|
+
* @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
|
|
2721
2723
|
*/
|
|
2722
|
-
|
|
2724
|
+
fetchInfo(): Promise<LavalinkInfo>;
|
|
2723
2725
|
/**
|
|
2724
|
-
*
|
|
2725
|
-
* @
|
|
2726
|
+
* Gets the current sponsorblock segments for a player.
|
|
2727
|
+
* @param {Player} player - The player to get the sponsorblocks for.
|
|
2728
|
+
* @returns {Promise<SponsorBlockSegment[]>} A promise that resolves to the sponsorblock segments.
|
|
2729
|
+
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
2726
2730
|
*/
|
|
2727
|
-
|
|
2731
|
+
getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
|
|
2728
2732
|
/**
|
|
2729
|
-
*
|
|
2730
|
-
* @param {
|
|
2731
|
-
* @
|
|
2732
|
-
* @
|
|
2733
|
-
* @
|
|
2733
|
+
* Sets the sponsorblock segments for a player.
|
|
2734
|
+
* @param {Player} player - The player to set the sponsor blocks for.
|
|
2735
|
+
* @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
|
|
2736
|
+
* @returns {Promise<void>} The promise is resolved when the operation is complete.
|
|
2737
|
+
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
2738
|
+
* @throws {RangeError} If no segments are provided.
|
|
2739
|
+
* @throws {SyntaxError} If an invalid sponsorblock is provided.
|
|
2740
|
+
* @example
|
|
2741
|
+
* ```ts
|
|
2742
|
+
* // use it on the player via player.setSponsorBlock();
|
|
2743
|
+
* player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]);
|
|
2744
|
+
* ```
|
|
2734
2745
|
*/
|
|
2735
|
-
|
|
2746
|
+
setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
|
|
2736
2747
|
/**
|
|
2737
|
-
*
|
|
2738
|
-
* @param {
|
|
2739
|
-
* @returns {
|
|
2740
|
-
* @throws {
|
|
2748
|
+
* Deletes the sponsorblock segments for a player.
|
|
2749
|
+
* @param {Player} player - The player to delete the sponsorblocks for.
|
|
2750
|
+
* @returns {Promise<void>} The promise is resolved when the operation is complete.
|
|
2751
|
+
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
2741
2752
|
*/
|
|
2742
|
-
|
|
2753
|
+
deleteSponsorBlock(player: Player): Promise<void>;
|
|
2743
2754
|
/**
|
|
2744
|
-
*
|
|
2745
|
-
*
|
|
2746
|
-
*
|
|
2747
|
-
*
|
|
2748
|
-
*
|
|
2749
|
-
* @param {string} channel - The new text channel ID.
|
|
2750
|
-
* @returns {this} - The player instance for method chaining.
|
|
2751
|
-
* @throws {TypeError} If the channel parameter is not a string.
|
|
2755
|
+
* Creates a README.md or README.txt file in the magmastream directory
|
|
2756
|
+
* if it doesn't already exist. This file is used to store player data
|
|
2757
|
+
* for autoresume and other features.
|
|
2758
|
+
* @private
|
|
2752
2759
|
*/
|
|
2753
|
-
|
|
2760
|
+
private createReadmeFile;
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
/**
|
|
2764
|
+
* The main hub for interacting with Lavalink and using Magmastream.
|
|
2765
|
+
*/
|
|
2766
|
+
declare class Manager extends EventEmitter {
|
|
2767
|
+
/** The map of players. */
|
|
2768
|
+
readonly players: Collection<string, Player>;
|
|
2769
|
+
/** The map of nodes. */
|
|
2770
|
+
readonly nodes: Collection<string, Node>;
|
|
2771
|
+
/** The options that were set. */
|
|
2772
|
+
readonly options: ManagerOptions;
|
|
2773
|
+
initiated: boolean;
|
|
2774
|
+
redis?: Redis;
|
|
2775
|
+
private _send;
|
|
2776
|
+
private loadedPlugins;
|
|
2754
2777
|
/**
|
|
2755
|
-
*
|
|
2756
|
-
*
|
|
2757
|
-
* @param
|
|
2758
|
-
* @
|
|
2778
|
+
* Initiates the Manager class.
|
|
2779
|
+
* @param options
|
|
2780
|
+
* @param options.enabledPlugins - An array of enabledPlugins to load.
|
|
2781
|
+
* @param options.nodes - An array of node options to create nodes from.
|
|
2782
|
+
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
2783
|
+
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
2784
|
+
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
2785
|
+
* @param options.clientName - The name of the client to send to Lavalink.
|
|
2786
|
+
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
2787
|
+
* @param options.useNode - The strategy to use when selecting a node to play on.
|
|
2788
|
+
* @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
|
|
2789
|
+
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
2790
|
+
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
2759
2791
|
*/
|
|
2760
|
-
|
|
2792
|
+
constructor(options: ManagerOptions);
|
|
2761
2793
|
/**
|
|
2762
|
-
*
|
|
2763
|
-
*
|
|
2764
|
-
*
|
|
2765
|
-
*
|
|
2766
|
-
*
|
|
2767
|
-
* @param {object} [optionsOrTrack] - The track to play or the options to play with.
|
|
2768
|
-
* @param {object} [playOptions] - The options to play with.
|
|
2769
|
-
*
|
|
2770
|
-
* @returns {Promise<void>}
|
|
2794
|
+
* Initiates the Manager.
|
|
2795
|
+
* @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
|
|
2796
|
+
* @param clusterId - The cluster ID which runs the current process (required).
|
|
2797
|
+
* @returns The manager instance.
|
|
2771
2798
|
*/
|
|
2772
|
-
|
|
2773
|
-
play(track: Track): Promise<Player>;
|
|
2774
|
-
play(options: PlayOptions): Promise<Player>;
|
|
2775
|
-
play(track: Track, options: PlayOptions): Promise<Player>;
|
|
2799
|
+
init(options?: ManagerInitOptions): Promise<this>;
|
|
2776
2800
|
/**
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2780
|
-
*
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
*
|
|
2785
|
-
*
|
|
2786
|
-
* @returns
|
|
2801
|
+
* Searches the enabled sources based off the URL or the `source` property.
|
|
2802
|
+
* @param query
|
|
2803
|
+
* @param requester
|
|
2804
|
+
* @returns The search result.
|
|
2805
|
+
*/
|
|
2806
|
+
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
2807
|
+
/**
|
|
2808
|
+
* Returns a player or undefined if it does not exist.
|
|
2809
|
+
* @param guildId The guild ID of the player to retrieve.
|
|
2810
|
+
* @returns The player if it exists, undefined otherwise.
|
|
2811
|
+
*/
|
|
2812
|
+
getPlayer(guildId: string): Player | undefined;
|
|
2813
|
+
/**
|
|
2814
|
+
* Creates a player or returns one if it already exists.
|
|
2815
|
+
* @param options The options to create the player with.
|
|
2816
|
+
* @returns The created player.
|
|
2787
2817
|
*/
|
|
2788
|
-
|
|
2818
|
+
create(options: PlayerOptions): Player;
|
|
2789
2819
|
/**
|
|
2790
|
-
*
|
|
2791
|
-
* @param
|
|
2792
|
-
* @returns
|
|
2820
|
+
* Destroys a player.
|
|
2821
|
+
* @param guildId The guild ID of the player to destroy.
|
|
2822
|
+
* @returns A promise that resolves when the player has been destroyed.
|
|
2793
2823
|
*/
|
|
2794
|
-
|
|
2824
|
+
destroy(guildId: string): Promise<void>;
|
|
2795
2825
|
/**
|
|
2796
|
-
*
|
|
2797
|
-
* @param
|
|
2798
|
-
* @returns
|
|
2799
|
-
* @throws {TypeError} If the volume is not a number.
|
|
2800
|
-
* @throws {RangeError} If the volume is not between 0 and 1000.
|
|
2801
|
-
* @emits {PlayerStateUpdate} - Emitted when the volume is changed.
|
|
2802
|
-
* @example
|
|
2803
|
-
* player.setVolume(50);
|
|
2804
|
-
* player.setVolume(50, { gradual: true, interval: 50, step: 5 });
|
|
2826
|
+
* Creates a new node or returns an existing one if it already exists.
|
|
2827
|
+
* @param options - The options to create the node with.
|
|
2828
|
+
* @returns The created node.
|
|
2805
2829
|
*/
|
|
2806
|
-
|
|
2830
|
+
createNode(options: NodeOptions): Node;
|
|
2807
2831
|
/**
|
|
2808
|
-
*
|
|
2809
|
-
* @param
|
|
2810
|
-
* @returns {
|
|
2832
|
+
* Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
|
|
2833
|
+
* @param identifier - The identifier of the node to destroy.
|
|
2834
|
+
* @returns {void}
|
|
2835
|
+
* @emits {debug} - Emits a debug message indicating the node is being destroyed.
|
|
2811
2836
|
*/
|
|
2812
|
-
|
|
2837
|
+
destroyNode(identifier: string): Promise<void>;
|
|
2813
2838
|
/**
|
|
2814
|
-
*
|
|
2815
|
-
* @
|
|
2839
|
+
* Attaches an event listener to the manager.
|
|
2840
|
+
* @param event The event to listen for.
|
|
2841
|
+
* @param listener The function to call when the event is emitted.
|
|
2842
|
+
* @returns The manager instance for chaining.
|
|
2816
2843
|
*/
|
|
2817
|
-
|
|
2844
|
+
on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this;
|
|
2818
2845
|
/**
|
|
2819
|
-
*
|
|
2820
|
-
* @
|
|
2846
|
+
* Updates the voice state of a player based on the provided data.
|
|
2847
|
+
* @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
2848
|
+
* @returns A promise that resolves when the voice state update is handled.
|
|
2849
|
+
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
2821
2850
|
*/
|
|
2822
|
-
|
|
2851
|
+
updateVoiceState(data: VoicePacket | VoiceServer | VoiceState): Promise<void>;
|
|
2823
2852
|
/**
|
|
2824
|
-
*
|
|
2825
|
-
*
|
|
2826
|
-
*
|
|
2827
|
-
*
|
|
2828
|
-
* @
|
|
2829
|
-
* @returns {this} - The player instance.
|
|
2830
|
-
* @throws {TypeError} If the repeat parameter is not a boolean.
|
|
2853
|
+
* Decodes an array of base64 encoded tracks and returns an array of TrackData.
|
|
2854
|
+
* Emits a debug event with the tracks being decoded.
|
|
2855
|
+
* @param tracks - An array of base64 encoded track strings.
|
|
2856
|
+
* @returns A promise that resolves to an array of TrackData objects.
|
|
2857
|
+
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
2831
2858
|
*/
|
|
2832
|
-
|
|
2859
|
+
decodeTracks(tracks: string[]): Promise<TrackData[]>;
|
|
2833
2860
|
/**
|
|
2834
|
-
*
|
|
2835
|
-
* @param
|
|
2836
|
-
* @returns
|
|
2837
|
-
* @throws
|
|
2861
|
+
* Decodes a base64 encoded track and returns a TrackData.
|
|
2862
|
+
* @param track - The base64 encoded track string.
|
|
2863
|
+
* @returns A promise that resolves to a TrackData object.
|
|
2864
|
+
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
2838
2865
|
*/
|
|
2839
|
-
|
|
2866
|
+
decodeTrack(track: string): Promise<TrackData>;
|
|
2840
2867
|
/**
|
|
2841
|
-
*
|
|
2842
|
-
* @param
|
|
2843
|
-
* @param ms After how many milliseconds to trigger dynamic repeat.
|
|
2844
|
-
* @returns {this} - The player instance.
|
|
2845
|
-
* @throws {TypeError} If the repeat parameter is not a boolean.
|
|
2846
|
-
* @throws {RangeError} If the queue size is less than or equal to 1.
|
|
2868
|
+
* Saves player states.
|
|
2869
|
+
* @param {string} guildId - The guild ID of the player to save
|
|
2847
2870
|
*/
|
|
2848
|
-
|
|
2871
|
+
savePlayerState(guildId: string): Promise<void>;
|
|
2849
2872
|
/**
|
|
2850
|
-
*
|
|
2851
|
-
*
|
|
2852
|
-
* @returns
|
|
2873
|
+
* Sleeps for a specified amount of time.
|
|
2874
|
+
* @param ms The amount of time to sleep in milliseconds.
|
|
2875
|
+
* @returns A promise that resolves after the specified amount of time.
|
|
2853
2876
|
*/
|
|
2854
|
-
|
|
2877
|
+
private sleep;
|
|
2855
2878
|
/**
|
|
2856
|
-
*
|
|
2857
|
-
* @param
|
|
2858
|
-
* @returns
|
|
2859
|
-
* @throws {RangeError} If the amount is greater than the queue length.
|
|
2879
|
+
* Loads player states from the JSON file.
|
|
2880
|
+
* @param nodeId The ID of the node to load player states from.
|
|
2881
|
+
* @returns A promise that resolves when the player states have been loaded.
|
|
2860
2882
|
*/
|
|
2861
|
-
|
|
2883
|
+
loadPlayerStates(nodeId: string): Promise<void>;
|
|
2862
2884
|
/**
|
|
2863
|
-
*
|
|
2864
|
-
*
|
|
2865
|
-
*
|
|
2866
|
-
*
|
|
2885
|
+
* Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
|
|
2886
|
+
* If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option.
|
|
2887
|
+
* If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen.
|
|
2888
|
+
* If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen.
|
|
2889
|
+
* @returns {Node} The node to use.
|
|
2867
2890
|
*/
|
|
2868
|
-
|
|
2891
|
+
get useableNode(): Node;
|
|
2869
2892
|
/**
|
|
2870
|
-
*
|
|
2871
|
-
*
|
|
2872
|
-
*
|
|
2873
|
-
*
|
|
2893
|
+
* Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
|
|
2894
|
+
* This function is called when the process is about to exit.
|
|
2895
|
+
* It iterates through all players and calls {@link savePlayerState} to save their states.
|
|
2896
|
+
* Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
|
|
2897
|
+
* After saving and cleaning up, it exits the process.
|
|
2874
2898
|
*/
|
|
2875
|
-
|
|
2899
|
+
handleShutdown(): Promise<void>;
|
|
2876
2900
|
/**
|
|
2877
|
-
*
|
|
2878
|
-
* @param
|
|
2879
|
-
* @
|
|
2880
|
-
* @
|
|
2881
|
-
* @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
|
|
2901
|
+
* Parses a YouTube title into a clean title and author.
|
|
2902
|
+
* @param title - The original title of the YouTube video.
|
|
2903
|
+
* @param originalAuthor - The original author of the YouTube video.
|
|
2904
|
+
* @returns An object with the clean title and author.
|
|
2882
2905
|
*/
|
|
2883
|
-
|
|
2906
|
+
private parseYouTubeTitle;
|
|
2884
2907
|
/**
|
|
2885
|
-
*
|
|
2886
|
-
* @param
|
|
2887
|
-
* @returns
|
|
2908
|
+
* Balances brackets in a given string by ensuring all opened brackets are closed correctly.
|
|
2909
|
+
* @param str - The input string that may contain unbalanced brackets.
|
|
2910
|
+
* @returns A new string with balanced brackets.
|
|
2888
2911
|
*/
|
|
2889
|
-
private
|
|
2912
|
+
private balanceBrackets;
|
|
2890
2913
|
/**
|
|
2891
|
-
*
|
|
2892
|
-
* @
|
|
2914
|
+
* Escapes a string by replacing special regex characters with their escaped counterparts.
|
|
2915
|
+
* @param string - The string to escape.
|
|
2916
|
+
* @returns The escaped string.
|
|
2893
2917
|
*/
|
|
2894
|
-
|
|
2918
|
+
private escapeRegExp;
|
|
2895
2919
|
/**
|
|
2896
|
-
*
|
|
2897
|
-
* @param
|
|
2898
|
-
* @returns
|
|
2920
|
+
* Checks if the given data is a voice update.
|
|
2921
|
+
* @param data The data to check.
|
|
2922
|
+
* @returns Whether the data is a voice update.
|
|
2899
2923
|
*/
|
|
2900
|
-
|
|
2924
|
+
private isVoiceUpdate;
|
|
2901
2925
|
/**
|
|
2902
|
-
*
|
|
2903
|
-
*
|
|
2904
|
-
*
|
|
2905
|
-
* @param
|
|
2906
|
-
* @
|
|
2907
|
-
* @returns {Promise<Player>} - The new player instance.
|
|
2926
|
+
* Determines if the provided update is a valid voice update.
|
|
2927
|
+
* A valid update must contain either a token or a session_id.
|
|
2928
|
+
*
|
|
2929
|
+
* @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
2930
|
+
* @returns {boolean} - True if the update is valid, otherwise false.
|
|
2908
2931
|
*/
|
|
2909
|
-
|
|
2932
|
+
private isValidUpdate;
|
|
2910
2933
|
/**
|
|
2911
|
-
*
|
|
2912
|
-
* @param
|
|
2913
|
-
* @
|
|
2914
|
-
* @
|
|
2934
|
+
* Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node.
|
|
2935
|
+
* @param player The player for which the voice state is being updated.
|
|
2936
|
+
* @param update The voice server data received from Discord.
|
|
2937
|
+
* @returns A promise that resolves when the voice state update is handled.
|
|
2938
|
+
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
2915
2939
|
*/
|
|
2916
|
-
|
|
2940
|
+
private handleVoiceServerUpdate;
|
|
2917
2941
|
/**
|
|
2918
|
-
*
|
|
2919
|
-
* @
|
|
2920
|
-
* @
|
|
2942
|
+
* 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.
|
|
2943
|
+
* @param player The player for which the voice state is being updated.
|
|
2944
|
+
* @param update The voice state data received from Discord.
|
|
2945
|
+
* @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel.
|
|
2946
|
+
* @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null.
|
|
2921
2947
|
*/
|
|
2922
|
-
|
|
2948
|
+
private handleVoiceStateUpdate;
|
|
2923
2949
|
/**
|
|
2924
|
-
*
|
|
2925
|
-
*
|
|
2926
|
-
* @throws {Error} - If the node is not a NodeLink.
|
|
2950
|
+
* Cleans up inactive players by removing their state files from the file system.
|
|
2951
|
+
* This is done to prevent stale state files from accumulating on the file system.
|
|
2927
2952
|
*/
|
|
2928
|
-
|
|
2953
|
+
cleanupInactivePlayers(): Promise<void>;
|
|
2929
2954
|
/**
|
|
2930
|
-
*
|
|
2931
|
-
*
|
|
2932
|
-
* @param
|
|
2933
|
-
* @returns {Promise<void>} - A promise that resolves when the voice receiver is closed.
|
|
2955
|
+
* Cleans up an inactive player by removing its state data.
|
|
2956
|
+
* This is done to prevent stale state data from accumulating.
|
|
2957
|
+
* @param guildId The guild ID of the player to clean up.
|
|
2934
2958
|
*/
|
|
2935
|
-
|
|
2959
|
+
cleanupInactivePlayer(guildId: string): Promise<void>;
|
|
2936
2960
|
/**
|
|
2937
|
-
*
|
|
2938
|
-
* @returns {Promise<void>} - A promise that resolves when the voice receiver is reconnected.
|
|
2961
|
+
* Loads the enabled plugins.
|
|
2939
2962
|
*/
|
|
2940
|
-
private
|
|
2963
|
+
private loadPlugins;
|
|
2941
2964
|
/**
|
|
2942
|
-
*
|
|
2943
|
-
* @returns {Promise<void>} - A promise that resolves when the voice receiver is disconnected.
|
|
2965
|
+
* Unloads the enabled plugins.
|
|
2944
2966
|
*/
|
|
2945
|
-
private
|
|
2967
|
+
private unloadPlugins;
|
|
2946
2968
|
/**
|
|
2947
|
-
*
|
|
2948
|
-
*
|
|
2969
|
+
* Clears all player states from the file system.
|
|
2970
|
+
* This is done to prevent stale state files from accumulating on the file system.
|
|
2949
2971
|
*/
|
|
2950
|
-
private
|
|
2972
|
+
private clearAllStoredPlayers;
|
|
2951
2973
|
/**
|
|
2952
|
-
*
|
|
2953
|
-
*
|
|
2954
|
-
*
|
|
2974
|
+
* Returns the nodes that has the least load.
|
|
2975
|
+
* The load is calculated by dividing the lavalink load by the number of cores.
|
|
2976
|
+
* The result is multiplied by 100 to get a percentage.
|
|
2977
|
+
* @returns {Collection<string, Node>}
|
|
2955
2978
|
*/
|
|
2956
|
-
private
|
|
2979
|
+
private get leastLoadNode();
|
|
2957
2980
|
/**
|
|
2958
|
-
*
|
|
2959
|
-
*
|
|
2960
|
-
*
|
|
2981
|
+
* Returns the nodes that have the least amount of players.
|
|
2982
|
+
* Filters out disconnected nodes and sorts the remaining nodes
|
|
2983
|
+
* by the number of players in ascending order.
|
|
2984
|
+
* @returns {Collection<string, Node>} A collection of nodes sorted by player count.
|
|
2961
2985
|
*/
|
|
2962
|
-
private
|
|
2986
|
+
private get leastPlayersNode();
|
|
2987
|
+
/**
|
|
2988
|
+
* Returns a node based on priority.
|
|
2989
|
+
* The nodes are sorted by priority in descending order, and then a random number
|
|
2990
|
+
* between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the
|
|
2991
|
+
* random number is returned.
|
|
2992
|
+
* If no node has a cumulative weight greater than or equal to the random number, the node with the
|
|
2993
|
+
* lowest load is returned.
|
|
2994
|
+
* @returns {Node} The node to use.
|
|
2995
|
+
*/
|
|
2996
|
+
private get priorityNode();
|
|
2997
|
+
protected send(packet: GatewayVoiceStateUpdate): unknown;
|
|
2998
|
+
sendPacket(packet: GatewayVoiceStateUpdate): unknown;
|
|
2963
2999
|
}
|
|
2964
3000
|
|
|
2965
3001
|
declare class Filters {
|
|
2966
3002
|
distortion: DistortionOptions | null;
|
|
2967
3003
|
equalizer: Band[];
|
|
2968
3004
|
karaoke: KaraokeOptions | null;
|
|
3005
|
+
manager: Manager;
|
|
2969
3006
|
player: Player;
|
|
2970
3007
|
rotation: RotationOptions | null;
|
|
2971
3008
|
timescale: TimescaleOptions | null;
|
|
@@ -2974,7 +3011,7 @@ declare class Filters {
|
|
|
2974
3011
|
volume: number;
|
|
2975
3012
|
bassBoostlevel: number;
|
|
2976
3013
|
filtersStatus: Record<AvailableFilters, boolean>;
|
|
2977
|
-
constructor(player: Player);
|
|
3014
|
+
constructor(player: Player, manager: Manager);
|
|
2978
3015
|
/**
|
|
2979
3016
|
* Updates the player's audio filters.
|
|
2980
3017
|
*
|
|
@@ -2999,6 +3036,7 @@ declare class Filters {
|
|
|
2999
3036
|
* @returns {Promise<this>} - Returns the current instance of the Filters class for method chaining.
|
|
3000
3037
|
*/
|
|
3001
3038
|
private applyFilter;
|
|
3039
|
+
private emitPlayersTasteUpdate;
|
|
3002
3040
|
/**
|
|
3003
3041
|
* Sets the status of a specific filter.
|
|
3004
3042
|
*
|