aqualink 2.1.3 → 2.3.0

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/build/index.d.ts CHANGED
@@ -1,1324 +1,368 @@
1
- declare module "aqualink" {
2
- import { EventEmitter } from "events";
1
+ import { EventEmitter } from "events";
3
2
 
4
- /**
5
- * Main Aqua client for managing audio nodes and players
6
- * @extends EventEmitter
7
- */
3
+ declare module "aqualink" {
8
4
  export class Aqua extends EventEmitter {
9
- /**
10
- * Creates a new Aqua instance
11
- * @param client The Discord client instance
12
- * @param nodes Array of node configurations
13
- * @param options Optional Aqua configuration
14
- */
15
- constructor(client: any, nodes: NodeConfig[], options?: AquaOptions);
16
-
17
- /**
18
- * Initializes the Aqua instance with the client ID
19
- * @param clientId The Discord client ID
20
- * @returns This Aqua instance
21
- */
22
- init(clientId: string): this;
23
-
24
- /**
25
- * Creates a new Node instance
26
- * @param options Node configuration
27
- * @returns The created Node
28
- */
29
- createNode(options: NodeConfig): Node;
30
-
31
- /**
32
- * Creates a new Player instance
33
- * @param node Node to create the player on
34
- * @param options Player configuration
35
- * @returns The created Player
36
- */
37
- createPlayer(node: Node, options: PlayerOptions): Player;
38
-
39
- /**
40
- * Destroys a player by guild ID
41
- * @param guildId The guild ID
42
- */
43
- destroyPlayer(guildId: string): Promise<void>;
44
-
45
- /**
46
- * Resolves a track query
47
- * @param options Track resolve options
48
- * @returns Track resolution response
49
- */
50
- resolve(options: ResolveOptions): Promise<ResolveResponse>;
51
-
52
- /**
53
- * Updates voice state based on Discord voice state update
54
- * @param data Voice state update data
55
- */
56
- updateVoiceState(data: VoiceStateUpdate): void;
57
-
58
- /**
59
- * Gets an option with a default fallback
60
- * @param options Options object
61
- * @param key Key to retrieve
62
- * @param defaultValue Default value if key doesn't exist
63
- * @returns The option value or default
64
- */
65
- getOption<T>(options: Record<string, any>, key: string, defaultValue: T): T;
66
-
67
- /**
68
- * Default function for sending voice updates to Discord
69
- * @param payload Voice payload
70
- */
71
- defaultSendFunction(payload: any): void;
72
-
73
- /**
74
- * Validates client and nodes input
75
- * @param client Discord client
76
- * @param nodes Array of node configurations
77
- */
78
- validateInputs(client: any, nodes: NodeConfig[]): void;
79
-
80
- /**
81
- * Gets nodes sorted by least load
82
- */
83
- get leastUsedNodes(): Node[];
84
-
85
- /**
86
- * Fetches nodes by region
87
- * @param region Region to filter by
88
- * @returns Nodes in the specified region
89
- */
90
- fetchRegion(region: string): Node[];
91
-
92
- /**
93
- * Calculates load on a node
94
- * @param node Node to calculate load for
95
- * @returns Load metric
96
- */
97
- calculateLoad(node: Node): number;
98
-
99
- /**
100
- * Creates a player connection
101
- * @param options Player options
102
- * @returns The created Player
103
- */
104
- createConnection(options: PlayerOptions): Player;
105
-
106
- /**
107
- * Gets a node for making requests
108
- * @param nodes Optional node specification
109
- * @returns Selected node
110
- */
111
- getRequestNode(nodes?: string | Node): Node;
112
-
113
- /**
114
- * Ensures the Aqua instance is initialized
115
- * @throws If not initialized
116
- */
117
- ensureInitialized(): void;
118
-
119
- /**
120
- * Formats a query for a specific source
121
- * @param query Search query
122
- * @param source Source platform
123
- * @returns Formatted query string
124
- */
125
- formatQuery(query: string, source: string): string;
126
-
127
- /**
128
- * Handles when no matches are found for a query
129
- * @param rest Rest instance
130
- * @param query Search query
131
- * @returns Resolve response
132
- */
133
- handleNoMatches(rest: Rest, query: string): Promise<ResolveResponse>;
134
-
135
- /**
136
- * Constructs a response for track resolution
137
- * @param response Raw response
138
- * @param requester Requester
139
- * @param requestNode Node used for the request
140
- * @returns Formatted resolve response
141
- */
142
- constructorResponse(response: any, requester: any, requestNode: Node): ResolveResponse;
143
-
144
- /**
145
- * Gets a player by guild ID
146
- * @param guildId Guild ID
147
- * @returns Player instance or undefined
148
- */
149
- get(guildId: string): Player | undefined;
150
-
151
- /**
152
- * Cleans up a player
153
- * @param player Player to clean up
154
- */
155
- cleanupPlayer(player: Player): void;
156
-
157
- /** Discord client instance */
5
+ constructor(client: any, nodes: NodeOptions[], options?: AquaOptions);
158
6
  client: any;
159
-
160
- /** Array of node configurations */
161
- nodes: NodeConfig[];
162
-
163
- /** Map of node names to Node instances */
7
+ nodes: NodeOptions[];
164
8
  nodeMap: Map<string, Node>;
165
-
166
- /** Map of guild IDs to Player instances */
167
9
  players: Map<string, Player>;
168
-
169
- /** Discord client ID */
170
10
  clientId: string | null;
171
-
172
- /** Whether the client has been initialized */
173
11
  initiated: boolean;
174
-
175
- /** Aqua options */
176
- options: AquaOptions;
177
-
178
- /** Whether to delete nowplaying messages */
179
12
  shouldDeleteMessage: boolean;
180
-
181
- /** Default platform for searching */
182
13
  defaultSearchPlatform: string;
183
-
184
- /** Whether to leave voice channel when queue ends */
185
14
  leaveOnEnd: boolean;
186
-
187
- /** REST API version to use */
188
15
  restVersion: string;
189
-
190
- /** Loaded plugins */
191
16
  plugins: Plugin[];
192
-
193
- /** Aqualink version */
194
17
  version: string;
195
-
196
- /** Function for sending voice updates to Discord */
197
18
  send: (payload: any) => void;
198
-
199
- /** Whether to auto-resume sessions */
200
19
  autoResume: boolean;
201
-
202
- /** Whether to reconnect indefinitely */
203
20
  infiniteReconnects: boolean;
204
-
205
- /** Cache for least used nodes */
21
+ options: AquaOptions;
206
22
  _leastUsedCache: { nodes: Node[], timestamp: number };
207
- }
208
-
209
- /**
210
- * Aqua client configuration options
211
- */
212
- export interface AquaOptions {
213
- /** Function for sending voice updates to Discord */
214
- send?: (payload: any) => void;
215
-
216
- /** Default platform for searching */
217
- defaultSearchPlatform?: string;
218
-
219
- /** REST API version to use */
220
- restVersion?: string;
221
-
222
- /** Plugins to load */
223
- plugins?: Plugin[];
224
-
225
- /** Whether to auto-resume sessions */
226
- autoResume?: boolean;
227
-
228
- /** Whether to reconnect indefinitely */
229
- infiniteReconnects?: boolean;
230
-
231
- /** Whether to delete nowplaying messages */
232
- shouldDeleteMessage?: boolean;
233
-
234
- /** Whether to leave voice channel when queue ends */
235
- leaveOnEnd?: boolean;
236
- }
237
-
238
- /**
239
- * Configuration for a Lavalink node
240
- */
241
- export interface NodeConfig {
242
- /** Node name for identification */
243
- name?: string;
244
-
245
- /** Node hostname */
246
- host: string;
247
-
248
- /** Node port */
249
- port: number;
250
-
251
- /** Node password */
252
- password: string;
253
-
254
- /** Whether to use secure connection */
255
- secure?: boolean;
256
-
257
- /** Session ID for resuming */
258
- sessionId?: string;
259
-
260
- /** Regions this node handles */
261
- regions?: string[];
262
- }
263
-
264
- /**
265
- * Configuration for a player
266
- */
267
- export interface PlayerOptions {
268
- /** Guild ID */
269
- guildId: string;
270
-
271
- /** Text channel ID */
272
- textChannel?: string;
273
-
274
- /** Voice channel ID */
275
- voiceChannel?: string;
276
-
277
- /** Default volume (0-1000) */
278
- defaultVolume?: number;
279
-
280
- /** Loop mode */
281
- loop?: string;
282
-
283
- /** Whether to delete nowplaying messages */
284
- shouldDeleteMessage?: boolean;
285
-
286
- /** Whether to leave voice channel when queue ends */
287
- leaveOnEnd?: boolean;
288
-
289
- /** Voice region */
290
- region?: string;
291
- }
292
-
293
- /**
294
- * Options for resolving a track
295
- */
296
- export interface ResolveOptions {
297
- /** Search query */
298
- query: string;
299
-
300
- /** Source platform */
301
- source?: string;
302
-
303
- /** Requester data */
304
- requester?: any;
305
-
306
- /** Specific node(s) to use */
307
- nodes?: string | Node;
308
- }
309
-
310
- /**
311
- * Response from a track resolution
312
- */
313
- export interface ResolveResponse {
314
- /** Type of load (TRACK_LOADED, SEARCH_RESULT, etc.) */
315
- loadType: string;
316
-
317
- /** Exception details if any */
318
- exception: any;
319
-
320
- /** Playlist information if result is a playlist */
321
- playlistInfo: any;
322
-
323
- /** Plugin-specific information */
324
- pluginInfo: any;
325
-
326
- /** Resolved tracks */
327
- tracks: Track[];
328
- }
329
-
330
- /**
331
- * Discord voice state update data
332
- */
333
- export interface VoiceStateUpdate {
334
- /** Update data */
335
- d: any;
336
-
337
- /** Update type */
338
- t: string;
339
- }
340
-
341
- /**
342
- * Manages voice connection for a player
343
- */
344
- export class Connection {
345
- /**
346
- * Creates a new Connection
347
- * @param player Player instance
348
- */
349
- constructor(player: Player);
350
-
351
- /**
352
- * Sets server update data
353
- * @param data Server update data
354
- */
355
- setServerUpdate(data: { endpoint: string, token: string }): void;
356
-
357
- /**
358
- * Sets state update data
359
- * @param data State update data
360
- */
361
- setStateUpdate(data: { channel_id: string, session_id: string, self_deaf: boolean, self_mute: boolean }): void;
362
-
363
- /**
364
- * Updates player voice data
365
- */
366
- _updatePlayerVoiceData(): Promise<void>;
367
-
368
- /** Weak reference to player */
369
- playerRef: WeakRef<Player>;
370
-
371
- /** Voice connection data */
372
- voice: { sessionId: string | null, endpoint: string | null, token: string | null };
373
-
374
- /** Voice region */
375
- region: string | null;
376
-
377
- /** Whether the bot is self-deafened */
378
- selfDeaf: boolean;
379
-
380
- /** Whether the bot is self-muted */
381
- selfMute: boolean;
382
-
383
- /** Voice channel ID */
384
- voiceChannel: string;
385
-
386
- /** Guild ID */
387
- guildId: string;
388
-
389
- /** Aqua instance */
390
- aqua: Aqua;
391
-
392
- /** Available nodes */
393
- nodes: any;
394
- }
395
23
 
396
- /**
397
- * Manages audio filters for a player
398
- */
399
- export class Filters {
400
- /**
401
- * Creates a new Filters instance
402
- * @param player Player instance
403
- * @param options Filter options
404
- */
405
- constructor(player: Player, options?: FiltersOptions);
406
-
407
- /**
408
- * Sets equalizer bands
409
- * @param bands Array of frequency bands
410
- */
411
- setEqualizer(bands: Array<any>): Promise<void>;
412
-
413
- /**
414
- * Toggles karaoke filter
415
- * @param enabled Whether to enable the filter
416
- * @param options Filter options
417
- */
418
- setKaraoke(enabled: boolean, options?: FiltersOptions): Promise<void>;
419
-
420
- /**
421
- * Toggles timescale filter
422
- * @param enabled Whether to enable the filter
423
- * @param options Filter options
424
- */
425
- setTimescale(enabled: boolean, options?: FiltersOptions): Promise<void>;
426
-
427
- /**
428
- * Toggles tremolo filter
429
- * @param enabled Whether to enable the filter
430
- * @param options Filter options
431
- */
432
- setTremolo(enabled: boolean, options?: FiltersOptions): Promise<void>;
433
-
434
- /**
435
- * Toggles vibrato filter
436
- * @param enabled Whether to enable the filter
437
- * @param options Filter options
438
- */
439
- setVibrato(enabled: boolean, options?: FiltersOptions): Promise<void>;
440
-
441
- /**
442
- * Toggles rotation filter
443
- * @param enabled Whether to enable the filter
444
- * @param options Filter options
445
- */
446
- setRotation(enabled: boolean, options?: FiltersOptions): Promise<void>;
447
-
448
- /**
449
- * Toggles distortion filter
450
- * @param enabled Whether to enable the filter
451
- * @param options Filter options
452
- */
453
- setDistortion(enabled: boolean, options?: FiltersOptions): Promise<void>;
454
-
455
- /**
456
- * Toggles channel mix filter
457
- * @param enabled Whether to enable the filter
458
- * @param options Filter options
459
- */
460
- setChannelMix(enabled: boolean, options?: FiltersOptions): Promise<void>;
461
-
462
- /**
463
- * Toggles low pass filter
464
- * @param enabled Whether to enable the filter
465
- * @param options Filter options
466
- */
467
- setLowPass(enabled: boolean, options?: FiltersOptions): Promise<void>;
468
-
469
- /**
470
- * Toggles bass boost filter
471
- * @param enabled Whether to enable the filter
472
- * @param options Filter options
473
- */
474
- setBassboost(enabled: boolean, options?: FiltersOptions): Promise<void>;
475
-
476
- /**
477
- * Toggles slow mode filter
478
- * @param enabled Whether to enable the filter
479
- * @param options Filter options
480
- */
481
- setSlowmode(enabled: boolean, options?: FiltersOptions): Promise<void>;
482
-
483
- /**
484
- * Toggles nightcore filter
485
- * @param enabled Whether to enable the filter
486
- * @param options Filter options
487
- */
488
- setNightcore(enabled: boolean, options?: FiltersOptions): Promise<void>;
489
-
490
- /**
491
- * Toggles vaporwave filter
492
- * @param enabled Whether to enable the filter
493
- * @param options Filter options
494
- */
495
- setVaporwave(enabled: boolean, options?: FiltersOptions): Promise<void>;
496
-
497
- /**
498
- * Toggles 8D filter
499
- * @param enabled Whether to enable the filter
500
- * @param options Filter options
501
- */
502
- set8D(enabled: boolean, options?: FiltersOptions): Promise<void>;
503
-
504
- /**
505
- * Clears all active filters
506
- */
507
- clearFilters(): Promise<void>;
508
-
509
- /**
510
- * Updates all filters
511
- */
512
- updateFilters(): Promise<void>;
513
-
514
- /** Player instance */
515
- player: Player;
516
-
517
- /** Current volume */
518
- volume: number;
519
-
520
- /** Equalizer bands */
521
- equalizer: any[];
522
-
523
- /** Karaoke filter settings */
524
- karaoke: any;
525
-
526
- /** Timescale filter settings */
527
- timescale: any;
528
-
529
- /** Tremolo filter settings */
530
- tremolo: any;
531
-
532
- /** Vibrato filter settings */
533
- vibrato: any;
534
-
535
- /** Rotation filter settings */
536
- rotation: any;
537
-
538
- /** Distortion filter settings */
539
- distortion: any;
540
-
541
- /** Channel mix filter settings */
542
- channelMix: any;
543
-
544
- /** Low pass filter settings */
545
- lowPass: any;
546
-
547
- /** Bass boost filter settings */
548
- bassboost: any;
549
-
550
- /** Slow mode filter settings */
551
- slowmode: any;
552
-
553
- /** Nightcore filter settings */
554
- nightcore: any;
555
-
556
- /** Vaporwave filter settings */
557
- vaporwave: any;
558
-
559
- /** 8D filter settings */
560
- _8d: any;
561
- }
562
-
563
- /**
564
- * Options for audio filters
565
- */
566
- export interface FiltersOptions {
567
- /** Volume level */
568
- volume?: number;
569
-
570
- /** Equalizer bands */
571
- equalizer?: any[];
572
-
573
- /** Karaoke filter settings */
574
- karaoke?: any;
575
-
576
- /** Timescale filter settings */
577
- timescale?: any;
578
-
579
- /** Tremolo filter settings */
580
- tremolo?: any;
581
-
582
- /** Vibrato filter settings */
583
- vibrato?: any;
584
-
585
- /** Rotation filter settings */
586
- rotation?: any;
587
-
588
- /** Distortion filter settings */
589
- distortion?: any;
590
-
591
- /** Channel mix filter settings */
592
- channelMix?: any;
593
-
594
- /** Low pass filter settings */
595
- lowPass?: any;
596
-
597
- /** Bass boost filter settings */
598
- bassboost?: any;
599
-
600
- /** Slow mode filter settings */
601
- slowmode?: any;
602
-
603
- /** Nightcore filter settings */
604
- nightcore?: any;
605
-
606
- /** Vaporwave filter settings */
607
- vaporwave?: any;
608
-
609
- /** 8D filter settings */
610
- _8d?: any;
24
+ defaultSendFunction(payload: any): void;
25
+ get leastUsedNodes(): Node[];
26
+ init(clientId: string): Promise<Aqua>;
27
+ createNode(options: NodeOptions): Promise<Node>;
28
+ destroyNode(identifier: string): void;
29
+ updateVoiceState({ d, t }: { d: any, t: string }): void;
30
+ fetchRegion(region: string): Node[];
31
+ calculateLoad(node: Node): number;
32
+ createConnection(options: ConnectionOptions): Player;
33
+ createPlayer(node: Node, options: PlayerOptions): Player;
34
+ destroyPlayer(guildId: string): Promise<void>;
35
+ resolve({ query, source, requester, nodes }: ResolveOptions): Promise<ResolveResponse>;
36
+ getRequestNode(nodes: string | Node): Node;
37
+ ensureInitialized(): void;
38
+ formatQuery(query: string, source: string): string;
39
+ handleNoMatches(rest: Rest, query: string): Promise<any>;
40
+ constructResponse(response: any, requester: any, requestNode: Node): ResolveResponse;
41
+ get(guildId: string): Player;
42
+ search(query: string, requester: any, source?: string): Promise<Track[] | null>;
43
+ cleanupPlayer(player: Player): Promise<void>;
611
44
  }
612
45
 
613
- /**
614
- * Represents a Lavalink node
615
- */
616
46
  export class Node {
617
- /**
618
- * Creates a new Node instance
619
- * @param aqua Aqua instance
620
- * @param connOptions Node connection options
621
- * @param options Node behavior options
622
- */
623
- constructor(aqua: Aqua, connOptions: NodeConfig, options?: NodeOptions);
624
-
625
- /**
626
- * Connects to the Lavalink node
627
- */
628
- connect(): Promise<void>;
629
-
630
- /**
631
- * Gets node statistics
632
- */
633
- getStats(): Promise<any>;
634
-
635
- /**
636
- * Destroys the node connection
637
- * @param clean Whether to clean up gracefully
638
- */
639
- destroy(clean?: boolean): void;
640
-
641
- /** Aqua instance */
47
+ constructor(aqua: Aqua, connOptions: NodeOptions, options?: NodeAdditionalOptions);
642
48
  aqua: Aqua;
643
-
644
- /** Node name */
645
- name: string;
646
-
647
- /** Node host */
648
49
  host: string;
649
-
650
- /** Node port */
50
+ name: string;
651
51
  port: number;
652
-
653
- /** Node password */
654
52
  password: string;
655
-
656
- /** Whether to use secure connection */
657
53
  secure: boolean;
658
-
659
- /** Session ID for resuming */
660
54
  sessionId: string | null;
661
-
662
- /** Regions this node handles */
663
55
  regions: string[];
664
-
665
- /** WebSocket URL */
666
- wsUrl: URL;
667
-
668
- /** REST interface */
56
+ wsUrl: string;
669
57
  rest: Rest;
670
-
671
- /** Resume timeout in seconds */
672
58
  resumeTimeout: number;
673
-
674
- /** Whether to auto-resume */
675
59
  autoResume: boolean;
676
-
677
- /** Reconnection timeout in ms */
678
60
  reconnectTimeout: number;
679
-
680
- /** Max reconnection attempts */
681
61
  reconnectTries: number;
682
-
683
- /** Whether to reconnect indefinitely */
684
62
  infiniteReconnects: boolean;
685
-
686
- /** Whether connected to the node */
687
63
  connected: boolean;
688
-
689
- /** Node information */
690
64
  info: any;
691
-
692
- /** Default statistics */
693
- defaultStats: any;
694
-
695
- /** Current statistics */
696
- stats: any;
697
- }
65
+ ws: WebSocket | null;
66
+ reconnectAttempted: number;
67
+ reconnectTimeoutId: NodeJS.Timeout | null;
68
+ stats: NodeStats;
698
69
 
699
- /**
700
- * Node behavior options
701
- */
702
- export interface NodeOptions {
703
- /** Resume timeout in seconds */
704
- resumeTimeout?: number;
705
-
706
- /** Whether to auto-resume */
707
- autoResume?: boolean;
708
-
709
- /** Reconnection timeout in ms */
710
- reconnectTimeout?: number;
711
-
712
- /** Max reconnection attempts */
713
- reconnectTries?: number;
714
-
715
- /** Whether to reconnect indefinitely */
716
- infiniteReconnects?: boolean;
70
+ initializeStats(): void;
71
+ connect(): Promise<void>;
72
+ destroy(clean?: boolean): void;
73
+ getStats(): Promise<NodeStats>;
717
74
  }
718
75
 
719
- /**
720
- * Audio player for a guild
721
- * @extends EventEmitter
722
- */
723
76
  export class Player extends EventEmitter {
724
- /**
725
- * Creates a new Player instance
726
- * @param aqua Aqua instance
727
- * @param nodes Available nodes
728
- * @param options Player options
729
- */
730
- constructor(aqua: Aqua, nodes: any, options?: PlayerOptions);
731
-
732
- /**
733
- * Starts playback of the current track
734
- */
735
- play(): Promise<void>;
736
-
737
- /**
738
- * Toggles pause state
739
- * @param paused Whether to pause
740
- * @returns This player instance
741
- */
742
- pause(paused: boolean): this;
743
-
744
- /**
745
- * Skips the current track
746
- */
747
- skip(): Promise<void>;
748
-
749
- /**
750
- * Destroys the player
751
- */
752
- destroy(): void;
753
-
754
- /**
755
- * Connects to a voice channel
756
- * @param options Connection options
757
- * @returns This player instance
758
- */
759
- connect(options: PlayerOptions): this;
760
-
761
- /**
762
- * Disconnects from voice channel
763
- * @returns This player instance
764
- */
765
- disconnect(): this;
766
-
767
- /**
768
- * Sets player volume
769
- * @param volume Volume level (0-1000)
770
- * @returns This player instance
771
- */
772
- setVolume(volume: number): this;
773
-
774
- /**
775
- * Sets loop mode
776
- * @param mode Loop mode ("none", "track", "queue")
777
- * @returns This player instance
778
- */
779
- setLoop(mode: string): this;
780
-
781
- /**
782
- * Sets text channel
783
- * @param channel Text channel ID
784
- * @returns This player instance
785
- */
786
- setTextChannel(channel: string): this;
787
-
788
- /**
789
- * Sets voice channel
790
- * @param channel Voice channel ID
791
- * @returns This player instance
792
- */
793
- setVoiceChannel(channel: string): this;
794
-
795
- /**
796
- * Shuffles the queue
797
- * @returns This player instance
798
- */
799
- shuffle(): this;
800
-
801
- /**
802
- * Replays current track
803
- * @returns This player instance
804
- */
805
- replay(): this;
806
-
807
- /**
808
- * Stops playback
809
- * @returns This player instance
810
- */
811
- stop(): this;
812
-
813
- /**
814
- * Seeks to position
815
- * @param position Position in milliseconds
816
- * @returns This player instance
817
- */
818
- seek(position: number): this;
819
-
820
- /**
821
- * Searches for lyrics
822
- * @param query Search query
823
- * @returns Lyrics search result
824
- */
825
- searchLyrics(query: string): Promise<any>;
826
-
827
- /**
828
- * Gets lyrics for current track
829
- * @returns Lyrics result
830
- */
831
- lyrics(): Promise<any>;
832
-
833
- /**
834
- * Adds track to previous tracks
835
- * @param track Track to add
836
- */
837
- addToPreviousTrack(track: Track): void;
838
-
839
- /**
840
- * Updates player state
841
- * @param data Update data
842
- */
843
- updatePlayer(data: any): Promise<void>;
844
-
845
- /**
846
- * Cleans up player resources
847
- */
848
- cleanup(): Promise<void>;
849
-
850
- /**
851
- * Updates track state
852
- * @param playing Whether playing
853
- * @param paused Whether paused
854
- */
855
- updateTrackState(playing: boolean, paused: boolean): void;
856
-
857
- /**
858
- * Handles an event from node
859
- * @param payload Event payload
860
- */
861
- handleEvent(payload: any): Promise<void>;
862
-
863
- /**
864
- * Handles unknown event
865
- * @param payload Event payload
866
- */
867
- handleUnknownEvent(payload: any): void;
868
-
869
- /**
870
- * Handles track start event
871
- * @param player Player instance
872
- * @param track Current track
873
- */
874
- trackStart(player: Player, track: Track): Promise<void>;
875
-
876
- /**
877
- * Handles track end event
878
- * @param player Player instance
879
- * @param track Ended track
880
- * @param payload Event payload
881
- */
882
- trackEnd(player: Player, track: Track, payload: any): Promise<void>;
883
-
884
- /**
885
- * Handles track error event
886
- * @param player Player instance
887
- * @param track Errored track
888
- * @param payload Event payload
889
- */
890
- trackError(player: Player, track: Track, payload: any): Promise<void>;
891
-
892
- /**
893
- * Handles track stuck event
894
- * @param player Player instance
895
- * @param track Stuck track
896
- * @param payload Event payload
897
- */
898
- trackStuck(player: Player, track: Track, payload: any): Promise<void>;
899
-
900
- /**
901
- * Handles socket closed event
902
- * @param player Player instance
903
- * @param payload Event payload
904
- */
905
- socketClosed(player: Player, payload: any): Promise<void>;
906
-
907
- /**
908
- * Sends data to node
909
- * @param data Data to send
910
- */
911
- send(data: any): void;
912
-
913
- /** Available loop modes */
914
- static LOOP_MODES: { NONE: string, TRACK: string, QUEUE: string };
915
-
916
- /** Event handler mapping */
917
- static EVENT_HANDLERS: { [key: string]: string };
918
-
919
- /** Valid loop modes */
920
- static validModes: Set<string>;
921
-
922
- /** Aqua instance */
77
+ constructor(aqua: Aqua, nodes: Node, options: PlayerOptions);
923
78
  aqua: Aqua;
924
-
925
- /** Available nodes */
926
- nodes: any;
927
-
928
- /** Guild ID */
79
+ nodes: Node;
929
80
  guildId: string;
930
-
931
- /** Text channel ID */
932
81
  textChannel: string;
933
-
934
- /** Voice channel ID */
935
82
  voiceChannel: string;
936
-
937
- /** Voice connection */
938
83
  connection: Connection;
939
-
940
- /** Audio filters */
941
84
  filters: Filters;
942
-
943
- /** Volume level */
944
85
  volume: number;
945
-
946
- /** Loop mode */
947
86
  loop: string;
948
-
949
- /** Track queue */
950
87
  queue: Queue;
951
-
952
- /** Previously played tracks */
953
88
  previousTracks: Track[];
954
-
955
- /** Whether to delete nowplaying messages */
89
+ previousTracksIndex: number;
90
+ previousTracksCount: number;
956
91
  shouldDeleteMessage: boolean;
957
-
958
- /** Whether to leave on queue end */
959
92
  leaveOnEnd: boolean;
960
-
961
- /** Whether currently playing */
962
93
  playing: boolean;
963
-
964
- /** Whether currently paused */
965
94
  paused: boolean;
966
-
967
- /** Whether connected to voice */
968
95
  connected: boolean;
969
-
970
- /** Current track */
971
96
  current: Track | null;
972
-
973
- /** Timestamp of last update */
97
+ position: number;
974
98
  timestamp: number;
975
-
976
- /** Connection ping */
977
99
  ping: number;
978
-
979
- /** Now playing message */
980
100
  nowPlayingMessage: any;
981
-
982
- /** Player update handler */
983
- onPlayerUpdate: (state: any) => void;
101
+ isAutoplayEnabled: boolean;
102
+ isAutoplay: boolean;
103
+
104
+ play(): Promise<void>;
105
+ connect(options: ConnectionOptions): Player;
106
+ destroy(): Player;
107
+ pause(paused: boolean): Player;
108
+ seek(position: number): Player;
109
+ stop(): Player;
110
+ setVolume(volume: number): Player;
111
+ setLoop(mode: string): Player;
112
+ setTextChannel(channel: string): Player;
113
+ setVoiceChannel(channel: string): Player;
114
+ disconnect(): Player;
115
+ shuffle(): Player;
116
+ getQueue(): Queue;
117
+ replay(): Player;
118
+ skip(): Player;
119
+ searchLyrics(query: string): Promise<any>;
120
+ lyrics(): Promise<any>;
121
+ updatePlayer(data: any): Promise<void>;
984
122
  }
985
123
 
986
- /**
987
- * Plugin for extending Aqua functionality
988
- */
989
- export class Plugin {
990
- /**
991
- * Creates a new Plugin
992
- * @param name Plugin name
993
- */
994
- constructor(name: string);
124
+ export class Track {
125
+ constructor(data: any, requester: any, nodes: Node);
126
+ info: TrackInfo;
127
+ track: string | null;
128
+ playlist: any;
129
+ requester: any;
130
+ nodes: Node;
995
131
 
996
- /**
997
- * Loads the plugin
998
- * @param aqua Aqua instance
999
- */
1000
- load(aqua: Aqua): void;
132
+ resolveThumbnail(thumbnail: string): string | null;
133
+ resolve(aqua: Aqua): Promise<Track | null>;
134
+ }
1001
135
 
1002
- /**
1003
- * Unloads the plugin
1004
- * @param aqua Aqua instance
1005
- */
1006
- unload(aqua: Aqua): void;
136
+ export class Rest {
137
+ constructor(aqua: Aqua, options: RestOptions);
138
+ aqua: Aqua;
139
+ sessionId: string;
140
+ version: string;
141
+ baseUrl: string;
142
+ headers: any;
143
+ secure: boolean;
144
+ timeout: number;
145
+ client: any;
1007
146
 
1008
- /** Plugin name */
1009
- name: string;
147
+ setSessionId(sessionId: string): void;
148
+ makeRequest(method: string, endpoint: string, body?: any): Promise<any>;
149
+ updatePlayer(options: { guildId: string, data: any }): Promise<any>;
150
+ getPlayers(): Promise<any>;
151
+ destroyPlayer(guildId: string): Promise<any>;
152
+ getTracks(identifier: string): Promise<any>;
153
+ decodeTrack(track: string): Promise<any>;
154
+ decodeTracks(tracks: string[]): Promise<any>;
155
+ getStats(): Promise<any>;
156
+ getInfo(): Promise<any>;
157
+ getRoutePlannerStatus(): Promise<any>;
158
+ getRoutePlannerAddress(address: string): Promise<any>;
159
+ getLyrics(options: { track: Track }): Promise<any>;
1010
160
  }
1011
161
 
1012
- /**
1013
- * Track queue implementation
1014
- * @extends Array
1015
- */
1016
162
  export class Queue extends Array<any> {
1017
- /**
1018
- * Creates a new Queue
1019
- * @param elements Initial elements
1020
- */
1021
163
  constructor(...elements: any[]);
1022
-
1023
- /** Number of items in queue */
1024
164
  size: number;
1025
-
1026
- /** First item in queue */
1027
165
  first: any;
1028
-
1029
- /** Last item in queue */
1030
166
  last: any;
1031
167
 
1032
- /**
1033
- * Adds a track to the queue
1034
- * @param track Track to add
1035
- * @returns This queue instance
1036
- */
1037
- add(track: any): this;
1038
-
1039
- /**
1040
- * Removes a track from the queue
1041
- * @param track Track to remove
1042
- */
168
+ add(track: any): Queue;
1043
169
  remove(track: any): void;
1044
-
1045
- /**
1046
- * Clears the queue
1047
- */
1048
170
  clear(): void;
1049
-
1050
- /**
1051
- * Shuffles the queue
1052
- */
1053
171
  shuffle(): void;
1054
-
1055
- /**
1056
- * Gets the first item without removing
1057
- * @returns First item
1058
- */
1059
172
  peek(): any;
1060
-
1061
- /**
1062
- * Converts queue to array
1063
- * @returns Array of items
1064
- */
1065
173
  toArray(): any[];
1066
-
1067
- /**
1068
- * Gets item at index
1069
- * @param index Index
1070
- * @returns Item at index
1071
- */
1072
174
  at(index: number): any;
1073
-
1074
- /**
1075
- * Removes and returns first item
1076
- * @returns First item
1077
- */
1078
175
  dequeue(): any;
1079
-
1080
- /**
1081
- * Checks if queue is empty
1082
- * @returns Whether empty
1083
- */
1084
176
  isEmpty(): boolean;
1085
-
1086
- /**
1087
- * Adds item to end of queue
1088
- * @param track Item to add
1089
- * @returns This queue instance
1090
- */
1091
- enqueue(track: any): this;
177
+ enqueue(track: any): Queue;
1092
178
  }
1093
179
 
1094
- /**
1095
- * REST API wrapper for Lavalink
1096
- */
1097
- export class Rest {
1098
- /**
1099
- * Creates a new Rest instance
1100
- * @param aqua Aqua instance
1101
- * @param options REST options
1102
- */
1103
- constructor(aqua: Aqua, options: RestOptions);
1104
-
1105
- /**
1106
- * Makes an HTTP request
1107
- * @param method HTTP method
1108
- * @param endpoint API endpoint
1109
- * @param body Request body
1110
- * @returns Response data
1111
- */
1112
- makeRequest(method: string, endpoint: string, body?: any): Promise<any>;
1113
-
1114
- /**
1115
- * Gets all players on the node
1116
- */
1117
- getPlayers(): Promise<any>;
1118
-
1119
- /**
1120
- * Destroys a player on the node
1121
- * @param guildId Guild ID
1122
- */
1123
- destroyPlayer(guildId: string): Promise<void>;
1124
-
1125
- /**
1126
- * Gets tracks by identifier
1127
- * @param identifier Track identifier
1128
- */
1129
- getTracks(identifier: string): Promise<any>;
1130
-
1131
- /**
1132
- * Decodes a track
1133
- * @param track Encoded track
1134
- */
1135
- decodeTrack(track: string): Promise<any>;
180
+ export class Plugin {
181
+ constructor(name: string);
182
+ name: string;
1136
183
 
1137
- /**
1138
- * Decodes multiple tracks
1139
- * @param tracks Encoded tracks
1140
- */
1141
- decodeTracks(tracks: any[]): Promise<any>;
184
+ load(aqua: Aqua): void;
185
+ unload(aqua: Aqua): void;
186
+ }
1142
187
 
1143
- /**
1144
- * Gets node statistics
1145
- */
1146
- getStats(): Promise<any>;
188
+ export class Filters {
189
+ constructor(player: Player, options?: FilterOptions);
190
+ player: Player;
191
+ volume: number;
192
+ equalizer: any[];
193
+ karaoke: any | null;
194
+ timescale: any | null;
195
+ tremolo: any | null;
196
+ vibrato: any | null;
197
+ rotation: any | null;
198
+ distortion: any | null;
199
+ channelMix: any | null;
200
+ lowPass: any | null;
201
+ bassboost: any | null;
202
+ slowmode: any | null;
203
+ nightcore: any | null;
204
+ vaporwave: any | null;
205
+ _8d: any | null;
206
+
207
+ setEqualizer(bands: any[]): Filters;
208
+ setKaraoke(enabled: boolean, options?: any): Filters;
209
+ setTimescale(enabled: boolean, options?: any): Filters;
210
+ setTremolo(enabled: boolean, options?: any): Filters;
211
+ setVibrato(enabled: boolean, options?: any): Filters;
212
+ setRotation(enabled: boolean, options?: any): Filters;
213
+ setDistortion(enabled: boolean, options?: any): Filters;
214
+ setChannelMix(enabled: boolean, options?: any): Filters;
215
+ setLowPass(enabled: boolean, options?: any): Filters;
216
+ setBassboost(enabled: boolean, options?: any): Filters;
217
+ setSlowmode(enabled: boolean, options?: any): Filters;
218
+ setNightcore(enabled: boolean, options?: any): Filters;
219
+ setVaporwave(enabled: boolean, options?: any): Filters;
220
+ set8D(enabled: boolean, options?: any): Filters;
221
+ clearFilters(): Promise<Filters>;
222
+ updateFilters(): Promise<Filters>;
223
+ }
1147
224
 
1148
- /**
1149
- * Gets node information
1150
- */
1151
- getInfo(): Promise<any>;
225
+ export class Connection {
226
+ constructor(player: Player);
227
+ playerRef: WeakRef<Player>;
228
+ sessionId: string | null;
229
+ endpoint: string | null;
230
+ token: string | null;
231
+ region: string | null;
232
+ selfDeaf: boolean;
233
+ selfMute: boolean;
234
+ voiceChannel: string;
235
+ guildId: string;
236
+ aqua: Aqua;
237
+ nodes: Node;
1152
238
 
1153
- /**
1154
- * Gets route planner status
1155
- */
1156
- getRoutePlannerStatus(): Promise<any>;
239
+ setServerUpdate(data: any): void;
240
+ setStateUpdate(data: any): void;
241
+ }
1157
242
 
1158
- /**
1159
- * Gets route planner address
1160
- * @param address IP address
1161
- */
1162
- getRoutePlannerAddress(address: string): Promise<any>;
243
+ interface AquaOptions {
244
+ shouldDeleteMessage?: boolean;
245
+ defaultSearchPlatform?: string;
246
+ leaveOnEnd?: boolean;
247
+ restVersion?: string;
248
+ plugins?: Plugin[];
249
+ send?: (payload: any) => void;
250
+ autoResume?: boolean;
251
+ infiniteReconnects?: boolean;
252
+ }
1163
253
 
1164
- /**
1165
- * Gets lyrics for a track
1166
- * @param options Lyrics options
1167
- */
1168
- getLyrics(options: { track: any }): Promise<any>;
254
+ interface NodeOptions {
255
+ host: string;
256
+ name?: string;
257
+ port?: number;
258
+ password?: string;
259
+ secure?: boolean;
260
+ sessionId?: string;
261
+ regions?: string[];
262
+ }
1169
263
 
1170
- /**
1171
- * Sets the session ID
1172
- * @param sessionId Session ID
1173
- */
1174
- setSessionId(sessionId: string): void;
264
+ interface NodeAdditionalOptions {
265
+ resumeTimeout?: number;
266
+ autoResume?: boolean;
267
+ reconnectTimeout?: number;
268
+ reconnectTries?: number;
269
+ infiniteReconnects?: boolean;
270
+ }
1175
271
 
1176
- /**
1177
- * Builds an API endpoint path
1178
- * @param segments Path segments
1179
- */
1180
- buildEndpoint(...segments: string[]): string;
272
+ interface PlayerOptions {
273
+ guildId: string;
274
+ textChannel: string;
275
+ voiceChannel: string;
276
+ defaultVolume?: number;
277
+ loop?: string;
278
+ shouldDeleteMessage?: boolean;
279
+ leaveOnEnd?: boolean;
280
+ }
1181
281
 
1182
- /**
1183
- * Validates session ID exists
1184
- * @throws If no session ID
1185
- */
1186
- validateSessionId(): void;
282
+ interface ConnectionOptions {
283
+ guildId: string;
284
+ voiceChannel: string;
285
+ deaf?: boolean;
286
+ mute?: boolean;
287
+ }
1187
288
 
1188
- /**
1189
- * Updates player state
1190
- * @param options Update options
1191
- */
1192
- updatePlayer(options: { guildId: string, data: any }): Promise<void>;
289
+ interface ResolveOptions {
290
+ query: string;
291
+ source?: string;
292
+ requester: any;
293
+ nodes?: string | Node;
294
+ }
1193
295
 
1194
- /** Aqua instance */
1195
- aqua: Aqua;
1196
-
1197
- /** Session ID */
1198
- sessionId: string;
1199
-
1200
- /** API version */
1201
- version: string;
1202
-
1203
- /** Base URL */
1204
- baseUrl: string;
1205
-
1206
- /** Request headers */
1207
- headers: Record<string, string>;
1208
-
1209
- /** HTTP client */
1210
- client: any;
296
+ interface ResolveResponse {
297
+ loadType: string;
298
+ exception: any | null;
299
+ playlistInfo: any | null;
300
+ pluginInfo: any;
301
+ tracks: Track[];
1211
302
  }
1212
303
 
1213
- /**
1214
- * REST API options
1215
- */
1216
- export interface RestOptions {
1217
- /** Whether to use HTTPS */
304
+ interface RestOptions {
1218
305
  secure: boolean;
1219
-
1220
- /** Host address */
1221
306
  host: string;
1222
-
1223
- /** Port number */
1224
307
  port: number;
1225
-
1226
- /** Session ID */
1227
308
  sessionId: string;
1228
-
1229
- /** Authentication password */
1230
309
  password: string;
310
+ timeout?: number;
1231
311
  }
1232
312
 
1233
- /**
1234
- * Represents an audio track
1235
- */
1236
- export class Track {
1237
- /**
1238
- * Creates a new Track
1239
- * @param data Track data
1240
- * @param requester Requester
1241
- * @param nodes Node
1242
- */
1243
- constructor(data: TrackData, requester: Player, nodes: Node);
1244
-
1245
- /**
1246
- * Resolves a track
1247
- * @param aqua Aqua instance
1248
- * @returns Resolved track or null
1249
- */
1250
- resolve(aqua: Aqua): Promise<Track | null>;
1251
-
1252
- /**
1253
- * Resolves track thumbnail
1254
- * @param thumbnail Thumbnail URL
1255
- * @returns Processed thumbnail URL or null
1256
- */
1257
- resolveThumbnail(thumbnail: string): string | null;
1258
-
1259
- /**
1260
- * Finds matching track in collection
1261
- * @param tracks Tracks to search
1262
- * @returns Matching track or null
1263
- */
1264
- _findMatchingTrack(tracks: Track[]): Track | null;
1265
-
1266
- /** Track information */
1267
- info: TrackInfo;
1268
-
1269
- /** Encoded track string */
1270
- track: string | null;
1271
-
1272
- /** Playlist information if part of playlist */
1273
- playlist: any;
1274
-
1275
- /** Track requester */
1276
- requester: Player;
1277
-
1278
- /** Node for this track */
1279
- nodes: Node;
1280
- }
1281
-
1282
- /**
1283
- * Track data structure
1284
- */
1285
- export interface TrackData {
1286
- /** Track information */
1287
- info?: TrackInfo;
1288
-
1289
- /** Encoded track string */
1290
- encoded?: string;
1291
-
1292
- /** Playlist information */
1293
- playlist?: any;
313
+ interface NodeStats {
314
+ players: number;
315
+ playingPlayers: number;
316
+ uptime: number;
317
+ memory: {
318
+ free: number;
319
+ used: number;
320
+ allocated: number;
321
+ reservable: number;
322
+ freePercentage: number;
323
+ usedPercentage: number;
324
+ };
325
+ cpu: {
326
+ cores: number;
327
+ systemLoad: number;
328
+ lavalinkLoad: number;
329
+ lavalinkLoadPercentage: number;
330
+ };
331
+ frameStats: {
332
+ sent: number;
333
+ nulled: number;
334
+ deficit: number;
335
+ };
336
+ ping: number;
1294
337
  }
1295
338
 
1296
- /**
1297
- * Track information
1298
- */
1299
- export interface TrackInfo {
1300
- /** Track identifier */
339
+ interface TrackInfo {
1301
340
  identifier: string;
1302
-
1303
- /** Whether track is seekable */
1304
341
  isSeekable: boolean;
1305
-
1306
- /** Track author/artist */
1307
342
  author: string;
1308
-
1309
- /** Track length in ms */
1310
343
  length: number;
1311
-
1312
- /** Whether track is a stream */
1313
344
  isStream: boolean;
1314
-
1315
- /** Track title */
1316
345
  title: string;
1317
-
1318
- /** Track URI */
1319
346
  uri: string;
347
+ sourceName: string;
348
+ artworkUrl: string;
349
+ }
1320
350
 
1321
- /** Track thumbnail URL */
1322
- thumbnail?: string;
351
+ interface FilterOptions {
352
+ volume?: number;
353
+ equalizer?: any[];
354
+ karaoke?: any;
355
+ timescale?: any;
356
+ tremolo?: any;
357
+ vibrato?: any;
358
+ rotation?: any;
359
+ distortion?: any;
360
+ channelMix?: any;
361
+ lowPass?: any;
362
+ bassboost?: any;
363
+ slowmode?: any;
364
+ nightcore?: any;
365
+ vaporwave?: any;
366
+ _8d?: any;
1323
367
  }
1324
- }
368
+ }