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