amberlink-client 0.0.0-stage → 1.0.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.
@@ -0,0 +1,4498 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { ReadableStream } from "node:stream/web";
3
+ /** Sourcenames provided by AmberLink server */
4
+ export type AudioNodeSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
5
+ /** Source Names provided by lava src plugin */
6
+ export type ProviderSourceNames = "deezer" | "spotify" | "applemusic" | "yandexmusic" | "flowery-tts" | "vkmusic" | "tidal" | "qobuz" | "pandora";
7
+ /** Source Names provided by jiosaavan plugin */
8
+ export type JioSaavnSourceName = "jiosaavn";
9
+ /** The SourceNames provided by AmberLink server */
10
+ export type SourceNames = AudioNodeSourceNames | ProviderSourceNames | JioSaavnSourceName;
11
+ export interface AudioTrackInfo {
12
+ /** The Identifier of the Track */
13
+ identifier: string;
14
+ /** The Track Title / Name */
15
+ title: string;
16
+ /** The Name of the Author */
17
+ author: string;
18
+ /** The duration of the Track */
19
+ length: number;
20
+ /** The URL of the artwork if available */
21
+ artworkUrl: string | null;
22
+ /** The URL (aka Link) of the Track called URI */
23
+ uri: string;
24
+ /** The Source name of the Track, e.g. soundcloud, youtube, spotify */
25
+ sourceName: SourceNames;
26
+ /** Whether the audio is seekable */
27
+ isSeekable: boolean;
28
+ /** Whether the audio is of a live stream */
29
+ isStream: boolean;
30
+ /** If isrc code is available, it's provided */
31
+ isrc: string | null;
32
+ }
33
+ export interface TrackInfo {
34
+ /** The Identifier of the Track */
35
+ identifier: string;
36
+ /** The Track Title / Name */
37
+ title: string;
38
+ /** The Name of the Author */
39
+ author: string;
40
+ /** The duration of the Track */
41
+ duration: number;
42
+ /** The URL of the artwork if available */
43
+ artworkUrl: string | null;
44
+ /** The URL (aka Link) of the Track called URI */
45
+ uri: string;
46
+ /** The Source name of the Track, e.g. soundcloud, youtube, spotify */
47
+ sourceName: SourceNames;
48
+ /** Whether the audio is seekable */
49
+ isSeekable: boolean;
50
+ /** Whether the audio is of a live stream */
51
+ isStream: boolean;
52
+ /** If isrc code is available, it's provided */
53
+ isrc: string | null;
54
+ }
55
+ export interface PluginInfo {
56
+ /** The Type provided by a plugin */
57
+ type?: "album" | "playlist" | "artist" | "recommendations" | string;
58
+ /** The Identifier provided by a plugin */
59
+ albumName?: string;
60
+ /** The url of the album */
61
+ albumUrl?: string;
62
+ /** The url of the album art */
63
+ albumArtUrl?: string;
64
+ /** The url of the artist */
65
+ artistUrl?: string;
66
+ /** The url of the artist artwork */
67
+ artistArtworkUrl?: string;
68
+ /** The url of the preview */
69
+ previewUrl?: string;
70
+ /** Whether the track is a preview */
71
+ isPreview?: boolean;
72
+ /** The total number of tracks in the playlist */
73
+ totalTracks?: number;
74
+ /** The Identifier provided by a plugin */
75
+ identifier?: string;
76
+ /** The ArtworkUrl provided by a plugin */
77
+ artworkUrl?: string;
78
+ /** The Author Information provided by a plugin */
79
+ author?: string;
80
+ /** The Url provided by a Plugin */
81
+ url?: string;
82
+ /** The Url provided by a Plugin */
83
+ uri?: string;
84
+ /** You can put specific track information here, to transform the tracks... */
85
+ clientData?: {
86
+ previousTrack?: boolean;
87
+ [key: string]: any;
88
+ };
89
+ }
90
+ export interface AudioNodeTrack {
91
+ /** The Base 64 encoded String */
92
+ encoded?: Base64;
93
+ /** Track Information */
94
+ info: AudioTrackInfo;
95
+ /** Plugin Information from AmberLink server */
96
+ pluginInfo: Partial<PluginInfo>;
97
+ /** The userData Object from when you provide to the AmberLink server request */
98
+ userData?: anyObject;
99
+ }
100
+ export interface TrackRequester {}
101
+ export interface Track {
102
+ /** The Base 64 encoded String */
103
+ encoded?: Base64;
104
+ /** Track Information */
105
+ info: TrackInfo;
106
+ /** Plugin Information from AmberLink server */
107
+ pluginInfo: Partial<PluginInfo>;
108
+ /** The Track's Requester */
109
+ requester?: TrackRequester;
110
+ /** The userData Object from when you provide to the AmberLink server request */
111
+ userData?: anyObject;
112
+ }
113
+ export interface UnresolvedTrackInfo extends Partial<TrackInfo> {
114
+ /** Required */
115
+ title: string;
116
+ }
117
+ export interface UnresolvedQuery extends UnresolvedTrackInfo {
118
+ /** The base64 of the unresolved track to "encode" */
119
+ encoded?: Base64;
120
+ }
121
+ export interface UnresolvedTrack {
122
+ /** Required */
123
+ resolve: (player: AmberLinkPlayer) => Promise<void>;
124
+ /** The Base 64 encoded String */
125
+ encoded?: Base64;
126
+ /** Track Information */
127
+ info: UnresolvedTrackInfo;
128
+ /** Plugin Information from AmberLink server */
129
+ pluginInfo: Partial<PluginInfo>;
130
+ /** The userData Object from when you provide to the AmberLink server request */
131
+ userData?: anyObject;
132
+ /** The Track's Requester */
133
+ requester?: TrackRequester;
134
+ }
135
+ export interface StoredQueue {
136
+ current: Track | null;
137
+ previous: Track[];
138
+ tracks: (Track | UnresolvedTrack)[];
139
+ }
140
+ export interface QueueStoreManager {
141
+ /** @async get a Value (MUST RETURN UNPARSED!) */
142
+ get: (guildId: string) => Awaitable<StoredQueue | string | undefined>;
143
+ /** @async Set a value inside a guildId (MUST BE UNPARSED) */
144
+ set: (guildId: string, value: StoredQueue | string) => Awaitable<void | boolean>;
145
+ /** @async Delete a Database Value based of it's guildId */
146
+ delete: (guildId: string) => Awaitable<void | boolean>;
147
+ /** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
148
+ stringify: (value: StoredQueue | string) => Awaitable<StoredQueue | string>;
149
+ /** @async Parse the saved value back to the AmberLinkQueue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
150
+ parse: (value: StoredQueue | string) => Awaitable<Partial<StoredQueue>>;
151
+ }
152
+ export interface ManagerQueueOptions {
153
+ /** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
154
+ maxPreviousTracks?: number;
155
+ /** Custom AmberLinkQueue Store option */
156
+ queueStore?: QueueStoreManager;
157
+ /** Custom AmberLinkQueue Watcher class */
158
+ queueChangesWatcher?: QueueChangesWatcher;
159
+ }
160
+ export interface QueueChangesWatcher {
161
+ /** get a Value (MUST RETURN UNPARSED!) */
162
+ tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
163
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
164
+ tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number | number[], oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
165
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
166
+ shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
167
+ }
168
+ export type DestroyReasonsType = keyof typeof DestroyReasons | string;
169
+ export type DisconnectReasonsType = keyof typeof DisconnectReasons | string;
170
+ export interface PlayerJson {
171
+ /** Guild Id where the player was playing in */
172
+ guildId: string;
173
+ /** Options provided to the player */
174
+ options: PlayerOptions;
175
+ /** Voice Channel Id the player was playing in */
176
+ voiceChannelId: string;
177
+ /** Text Channel Id the player was synced to */
178
+ textChannelId?: string;
179
+ /** Position the player was at */
180
+ position: number;
181
+ /** AmberLink server's position the player was at */
182
+ lastPosition: number;
183
+ /** Last time the position was sent from AmberLink server */
184
+ lastPositionChange: number | null;
185
+ /** Volume in % from the player (without volumeDecrementer) */
186
+ volume: number;
187
+ /** Real Volume used in AmberLink server (with the volumeDecrementer) */
188
+ nodeVolume: number;
189
+ /** The repeatmode from the player */
190
+ repeatMode: RepeatMode;
191
+ /** Pause state */
192
+ paused: boolean;
193
+ /** Whether the player was playing or not */
194
+ playing: boolean;
195
+ /** When the player was created */
196
+ createdTimeStamp?: number;
197
+ /** All current used fitlers Data */
198
+ filters: FilterData;
199
+ /** The player's ping object */
200
+ ping: {
201
+ /** Ping to the voice websocket server */
202
+ ws: number;
203
+ /** Avg. calc. Ping to the AmberLink server */
204
+ node: number;
205
+ };
206
+ /** Equalizer Bands used in AmberLink server */
207
+ equalizer: EQBand[];
208
+ /** The Id of the last used node */
209
+ nodeId?: string;
210
+ /** The SessionId of the node */
211
+ nodeSessionId?: string;
212
+ /** The stored queue */
213
+ queue?: StoredQueue;
214
+ }
215
+ export type RepeatMode = "queue" | "track" | "off";
216
+ export interface PlayerOptions {
217
+ /** Guild id of the player */
218
+ guildId: string;
219
+ /** The Voice Channel Id */
220
+ voiceChannelId: string;
221
+ /** The Text Channel Id of the AmberLinkPlayer */
222
+ textChannelId?: string;
223
+ /** instantly change volume with the one play request */
224
+ volume?: number;
225
+ /** VC Region for node selections */
226
+ vcRegion?: string;
227
+ /** if it should join deafened */
228
+ selfDeaf?: boolean;
229
+ /** If it should join muted */
230
+ selfMute?: boolean;
231
+ /** If it should use a specific server node */
232
+ node?: AmberLinkNode | string;
233
+ /** If when applying filters, it should use the insta apply filters fix */
234
+ instaUpdateFiltersFix?: boolean;
235
+ /** If a volume should be applied via filters instead of AmberLink server-volume */
236
+ applyVolumeAsFilter?: boolean;
237
+ /** Custom Data for the player get/set datastorage */
238
+ customData?: anyObject;
239
+ }
240
+ export type anyObject = {
241
+ [key: string | number]: string | number | null | anyObject;
242
+ };
243
+ export interface BasePlayOptions {
244
+ /** The position to start the track. */
245
+ position?: number;
246
+ /** The position to end the track. */
247
+ endTime?: number;
248
+ /** If to start "paused" */
249
+ paused?: boolean;
250
+ /** The Volume to start with */
251
+ volume?: number;
252
+ /** The AmberLink server Filters to use | only with the new REST API */
253
+ filters?: Partial<AudioFilterData>;
254
+ /** Voice Update for AmberLink server */
255
+ voice?: NodePlayerVoiceOptions;
256
+ }
257
+ export interface NodePlayOptions extends BasePlayOptions {
258
+ /** Which Track to play | don't provide, if it should pick from the AmberLinkQueue */
259
+ track?: {
260
+ /** The track encoded base64 string to use instead of the one from the queue system */
261
+ encoded?: Base64 | null;
262
+ /** The identifier of the track to use */
263
+ identifier?: string;
264
+ /** Custom User Data for the track to provide, will then be on the userData object from the track */
265
+ userData?: anyObject;
266
+ /** The Track requester for when u provide encodedTrack / identifer */
267
+ requester?: unknown;
268
+ /** NodeLink Specific audioTrackId option */
269
+ audioTrackId?: string;
270
+ };
271
+ }
272
+ export interface PlayOptions extends NodePlayOptions {
273
+ /** Whether to not replace the track if a play payload is sent. */
274
+ noReplace?: boolean;
275
+ /** Adds track on queue and skips to it */
276
+ clientTrack?: (Track | UnresolvedTrack) & {
277
+ audioTrackId?: string;
278
+ };
279
+ }
280
+ /** Ability to manipulate fetch requests */
281
+ export type ModifyRequest = (options: RequestInit & {
282
+ path: string;
283
+ extraQueryUrlParams?: URLSearchParams;
284
+ }) => void;
285
+ export type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
286
+ /**
287
+ * Options for creating an AmberLink server.
288
+ */
289
+ export interface AmberLinkNodeOptions {
290
+ /** Specify the node type. Default: AmberLink. */
291
+ nodeType?: NodeType;
292
+ /** The AmberLink server host name or IP address */
293
+ host: string;
294
+ /** The AmberLink server connection port */
295
+ port: number;
296
+ /** The AmberLink server authentication secret */
297
+ authorization: string;
298
+ /** Does the Server use ssl (https) */
299
+ secure?: boolean;
300
+ /** RESUME THE PLAYER? by providing a sessionid on the node-creation */
301
+ sessionId?: string;
302
+ /** Add a Custom ID to the node, for later use */
303
+ id?: string;
304
+ /** Voice Regions of this Node */
305
+ regions?: string[];
306
+ /** The max amount of retries for this node. */
307
+ retryAmount?: number;
308
+ /** The delay of how often to retry a reconnection. */
309
+ retryDelay?: number;
310
+ /** How long a retry is a valid retry, it should be at least retryAmount*retryDelay. if <= 0 (default) then this won't be accounted. */
311
+ retryTimespan?: number;
312
+ /** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
313
+ requestSignalTimeoutMS?: number;
314
+ /** Close on error */
315
+ closeOnError?: boolean;
316
+ /** Heartbeat interval , set to <= 0 to disable heartbeat system */
317
+ heartBeatInterval?: number;
318
+ /** Recommended, to check whether the client is still connected or not on the stats endpoint */
319
+ enablePingOnStatsCheck?: boolean;
320
+ /** Per Node Options */
321
+ autoChecks?: {
322
+ /** Whether to validate optional modules on third-party server nodes (ignored for NodeLink) */
323
+ pluginValidations?: boolean;
324
+ /** Wether to check for every node to check for source validations or not. */
325
+ sourcesValidations?: boolean;
326
+ };
327
+ }
328
+ /**
329
+ * Memory statistics reported by an AmberLink server
330
+ */
331
+ export interface MemoryStats {
332
+ /** The free memory of the allocated amount. */
333
+ free: number;
334
+ /** The used memory of the allocated amount. */
335
+ used: number;
336
+ /** The total allocated memory. */
337
+ allocated: number;
338
+ /** The reservable memory. */
339
+ reservable: number;
340
+ }
341
+ /**
342
+ * CPU statistics reported by an AmberLink server
343
+ */
344
+ export interface CPUStats {
345
+ /** The core amount the host machine has. */
346
+ cores: number;
347
+ /** The system load. */
348
+ systemLoad: number;
349
+ /** The audio engine process load. */
350
+ nodeLoad: number;
351
+ }
352
+ /**
353
+ * FrameStats Object from AmberLink server
354
+ */
355
+ export interface FrameStats {
356
+ /** The amount of sent frames. */
357
+ sent?: number;
358
+ /** The amount of nulled frames. */
359
+ nulled?: number;
360
+ /** The amount of deficit frames. */
361
+ deficit?: number;
362
+ }
363
+ /**
364
+ * Base statistics shared by compatible server nodes
365
+ */
366
+ export interface BaseNodeStats {
367
+ /** The amount of players on the node. */
368
+ players: number;
369
+ /** The amount of playing players on the node. */
370
+ playingPlayers: number;
371
+ /** The uptime for the node. */
372
+ uptime: number;
373
+ /** The memory stats for the node. */
374
+ memory: MemoryStats;
375
+ /** The cpu stats for the node. */
376
+ cpu: CPUStats;
377
+ /** The frame stats for the node. */
378
+ frameStats: FrameStats;
379
+ }
380
+ export interface NodeLinkConnectionMetrics {
381
+ status: string;
382
+ metrics: {
383
+ speed: {
384
+ bps: number;
385
+ kbps: number;
386
+ mbps: number;
387
+ };
388
+ downloadedBytes: number;
389
+ durationSeconds: number;
390
+ timestamp: number;
391
+ };
392
+ }
393
+ /**
394
+ * Interface for nodeStats from AmberLink server
395
+ */
396
+ export interface NodeStats extends BaseNodeStats {
397
+ /** The frame stats for the node. */
398
+ frameStats: FrameStats;
399
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
400
+ detailedStats?: {
401
+ api: {
402
+ /** e.g. { "/loadtracks": 150, "/info": 5 } */
403
+ requests: Record<string, number>;
404
+ errors: unknown;
405
+ };
406
+ /** e.g. { "youtube": 150, "soundcloud": 5 } */
407
+ sources: Record<string, number>;
408
+ playback: {
409
+ /** e.g. { "TrackStartEvent": 150, "TrackEndEvent": 5 } */
410
+ events: Record<string, number>;
411
+ };
412
+ /** and potential others */
413
+ [key: string]: unknown;
414
+ };
415
+ }
416
+ /**
417
+ * Entire AmberLink server information object from AmberLink server
418
+ */
419
+ /** First-party AmberLink feature discovery, independent of external module names. */
420
+ export interface AmberLinkInfo {
421
+ name: "AmberLink";
422
+ engine: string;
423
+ version: string;
424
+ features: Record<string, boolean | Record<string, boolean>>;
425
+ }
426
+ export interface AudioNodeInfo {
427
+ /** The version of this AmberLink server */
428
+ version: VersionObject;
429
+ /** The millisecond unix timestamp when this AmberLink server jar was built */
430
+ buildTime: number;
431
+ /** The git information of this AmberLink server */
432
+ git: GitObject;
433
+ /** The JVM version this AmberLink server runs on */
434
+ jvm: string;
435
+ /** The Lavaplayer version being used by this server */
436
+ lavaplayer: string;
437
+ /** The enabled source managers for this server */
438
+ sourceManagers: string[];
439
+ /** The enabled filters for this server */
440
+ filters: string[];
441
+ /** The enabled plugins for this server */
442
+ plugins: PluginObject[];
443
+ /** Something from NodeLink: https://nodelink.js.org/docs/differences#server-info */
444
+ isNodelink?: boolean;
445
+ }
446
+ /**
447
+ * AmberLink server's version object from AmberLink server
448
+ */
449
+ export interface VersionObject {
450
+ /** The full version string of this AmberLink server */
451
+ semver: string;
452
+ /** The major version of this AmberLink server */
453
+ major: number;
454
+ /** The minor version of this AmberLink server */
455
+ minor: number;
456
+ /** The patch version of this AmberLink server */
457
+ patch: number;
458
+ /** The pre-release version according to semver as a . separated list of identifiers */
459
+ preRelease?: string;
460
+ /** The build metadata according to semver as a . separated list of identifiers */
461
+ build?: string;
462
+ }
463
+ /**
464
+ * Git information object from AmberLink server
465
+ */
466
+ export interface GitObject {
467
+ /** The branch this AmberLink server was built on */
468
+ branch: string;
469
+ /** The commit this AmberLink server was built on */
470
+ commit: string;
471
+ /** The millisecond unix timestamp for when the commit was created */
472
+ commitTime: string;
473
+ }
474
+ /**
475
+ * AmberLink server's plugins object from AmberLink server's plugin
476
+ */
477
+ export interface PluginObject {
478
+ /** The name of the plugin */
479
+ name: string;
480
+ /** The version of the plugin */
481
+ version: string;
482
+ }
483
+ export interface LyricsResult {
484
+ /**The name of the source */
485
+ sourceName: string;
486
+ /**The name of the provider */
487
+ provider: string;
488
+ /**The result text */
489
+ text: string | null;
490
+ /**The lyrics lines */
491
+ lines: LyricsLine[];
492
+ /**Information about the plugin */
493
+ plugin: PluginInfo;
494
+ }
495
+ export interface LyricsLine {
496
+ /**The millisecond timestamp */
497
+ timestamp: number;
498
+ /**The line duration in milliseconds */
499
+ duration: number | null;
500
+ /**The line text */
501
+ line: string;
502
+ /**Information about the plugin */
503
+ plugin: PluginInfo;
504
+ }
505
+ export type NodeIdentifier = string;
506
+ export interface NodeManagerEvents {
507
+ /**
508
+ * Emitted when a Node is created.
509
+ * @event Manager.nodeManager#create
510
+ */
511
+ create: (node: AmberLinkNode) => void;
512
+ /**
513
+ * Emitted when a Node is destroyed.
514
+ * @event Manager.nodeManager#destroy
515
+ */
516
+ destroy: (node: AmberLinkNode, destroyReason?: DestroyReasonsType) => void;
517
+ /**
518
+ * Emitted when a Node is connected.
519
+ * @event Manager.nodeManager#connect
520
+ */
521
+ connect: (node: AmberLinkNode) => void;
522
+ /**
523
+ * Emitted when a Node is reconnecting.
524
+ * @event Manager.nodeManager#reconnecting
525
+ */
526
+ reconnecting: (node: AmberLinkNode) => void;
527
+ /**
528
+ * Emitted When a node starts to reconnect (if you have a reconnection delay, the reconnecting event will be emitted after the retryDelay.)
529
+ * Useful to check whether the internal node reconnect system works or not
530
+ * @event Manager.nodeManager#reconnectinprogress
531
+ */
532
+ reconnectinprogress: (node: AmberLinkNode) => void;
533
+ /**
534
+ * Emitted when a Node is disconnects.
535
+ * @event Manager.nodeManager#disconnect
536
+ */
537
+ disconnect: (node: AmberLinkNode, reason: {
538
+ code?: number;
539
+ reason?: string;
540
+ }) => void;
541
+ /**
542
+ * Emitted when a Node is error.
543
+ * @event Manager.nodeManager#error
544
+ */
545
+ error: (node: AmberLinkNode, error: Error, payload?: unknown) => void;
546
+ /**
547
+ * Emits every single Node event.
548
+ * @event Manager.nodeManager#raw
549
+ */
550
+ raw: (node: AmberLinkNode, payload: unknown) => void;
551
+ /**
552
+ * Emits when the node connects resumed. You then need to create all players within this event for your usecase.
553
+ * Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
554
+ * @event Manager.nodeManager#nodeResumed
555
+ */
556
+ resumed: (node: AmberLinkNode, payload: {
557
+ resumed: true;
558
+ sessionId: string;
559
+ op: "ready";
560
+ }, players: NodePlayerData[] | InvalidNodeRestRequest) => void;
561
+ /**
562
+ * Event Handler for Nodelink specific events https://nodelink.js.org/docs/api/websocket Fully typed and generic based on the eventName.
563
+ * @event Manager.nodeManager#nodeLinkEvent
564
+ * @example
565
+ *
566
+ * ```ts
567
+ * this.nodeManager.on("nodeLinkEvent", (node, event, player, track, payload) => {
568
+ * if (event === "SeekEvent") {
569
+ * console.log("new position:", payload.position);
570
+ * }
571
+ * if (event === "FiltersChangedEvent") {
572
+ * console.log("new filters state", payload.filters);
573
+ * }
574
+ * });
575
+ * ```
576
+ */
577
+ nodeLinkEvent: (...args: { [K in NodeLinkEventTypes]: [node: AmberLinkNode, event: K, player: AmberLinkPlayer, track: Track | null, payload: NodeLinkEventPayload<K>]; }[NodeLinkEventTypes]) => void;
578
+ }
579
+ export declare enum ReconnectionState {
580
+ IDLE = "IDLE",
581
+ RECONNECTING = "RECONNECTING",
582
+ PENDING = "PENDING",
583
+ DESTROYING = "DESTROYING"
584
+ }
585
+ export declare enum NodeType {
586
+ /** First-party AmberLink engine. This is the default node type. */
587
+ AmberLink = "AmberLink",
588
+ /** A separately operated, third-party AmberLink server. */
589
+ ThirdPartyNode = "ThirdPartyNode",
590
+ /** A NodeLink server using its distinct protocol and capabilities. */
591
+ NodeLink = "NodeLink"
592
+ }
593
+ export declare const TrackSymbol: unique symbol;
594
+ export declare const UnresolvedTrackSymbol: unique symbol;
595
+ export declare const QueueSymbol: unique symbol;
596
+ export declare const NodeSymbol: unique symbol;
597
+ /**
598
+ * Parses a node connection URL.
599
+ * Supported schemes: amberlink://, thirdparty:// (third-party), and nodelink://.
600
+ */
601
+ export declare function parseAmberLinkConnUrl(connectionUrl: string): {
602
+ authorization: string;
603
+ nodeType: NodeType;
604
+ id: string;
605
+ host: string;
606
+ port: number;
607
+ };
608
+ export declare class ManagerUtils {
609
+ AmberLinkManager: AmberLinkManager | undefined;
610
+ /** Override this with your custom sources record if you want to use custom sources for your node */
611
+ SourcesRecord: Record<SearchPlatform, AudioSearchPlatform | ClientCustomSearchPlatformUtils>;
612
+ constructor(AmberLinkManager?: AmberLinkManager);
613
+ /**
614
+ * Builds a pluginInfo object based on the provided data, extracting relevant information from the data and clientData parameters. This function is used to construct the pluginInfo property for tracks, allowing for consistent handling of plugin-related information across different track sources and formats.
615
+ * @param data
616
+ * @param clientData
617
+ * @returns
618
+ */
619
+ buildPluginInfo(data: any, clientData?: any): any;
620
+ /**
621
+ * Builds a Track object from the provided data and requester information. It validates the presence of required properties in the data, transforms the requester using a custom transformer function if provided, and constructs a Track object with the appropriate properties and plugin information. The function also includes error handling to ensure that the input data is valid and provides debug information if track building fails.
622
+ * @param data
623
+ * @param requester
624
+ * @returns
625
+ */
626
+ buildTrack(data: AudioNodeTrack | Track, requester: unknown): Track;
627
+ /**
628
+ * Builds a UnresolvedTrack to be resolved before being played .
629
+ * @param query
630
+ * @param requester
631
+ */
632
+ buildUnresolvedTrack(query: UnresolvedQuery | UnresolvedTrack, requester: unknown): UnresolvedTrack;
633
+ /**
634
+ * Validate if a data is equal to a node
635
+ * @param data
636
+ */
637
+ isNode(data: AmberLinkNode): boolean;
638
+ /**
639
+ * Gets the transformed requester based on the AmberLinkManager options. If a custom requester transformer function is provided in the player options, it applies that function to the requester; otherwise, it returns the requester as is. The function also includes error handling to catch any exceptions that may occur during the transformation process and emits a debug event if the transformation fails.
640
+ * @param requester
641
+ * @returns
642
+ */
643
+ getTransformedRequester(requester: unknown): unknown;
644
+ /**
645
+ * Validate if a data is equal to node options
646
+ * @param data
647
+ */
648
+ isNodeOptions(data: AmberLinkNodeOptions): boolean;
649
+ /**
650
+ * Validate tracks based on duration whether they are playble or broken tracks.
651
+ * most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
652
+ * This check is not done automatically, you need to check it yourself by doing:
653
+ * @example
654
+ * ```ts
655
+ * const res = await player.search("Adele");
656
+ *
657
+ * // short hand:
658
+ * const validTracks = res.tracks.filter(client.amberlink.utils.isNotBrokenTrack)
659
+ * // or with options:
660
+ * const validTracks = res.tracks.filter(t => client.amberlink.utils.isNotBrokenTrack(t, 29e3));
661
+ *
662
+ * // then you can add it to the queue.
663
+ * await player.queue.add(validTracks);
664
+ * ```
665
+ */
666
+ isNotBrokenTrack(data: Track | UnresolvedTrack, minDuration?: number): data is Track;
667
+ /**
668
+ * Validate if a data is equal to a track
669
+ * @param data the Track to validate
670
+ * @returns
671
+ */
672
+ isTrack(data?: Track | UnresolvedTrack | null): data is Track;
673
+ /**
674
+ * Checks if the provided argument is a valid UnresolvedTrack.
675
+ * @param track
676
+ */
677
+ isUnresolvedTrack(data: UnresolvedTrack | Track): data is UnresolvedTrack;
678
+ /**
679
+ * Checks if the provided argument is a valid UnresolvedTrack.
680
+ * @param track
681
+ */
682
+ isUnresolvedTrackQuery(data: UnresolvedQuery): boolean;
683
+ /**
684
+ * Gets the closest track by resolving the provided UnresolvedTrack using the getClosestTrack function. It includes error handling to catch any exceptions that may occur during the resolution process and emits a debug event if the resolution fails. The function returns a Promise that resolves to a Track object if successful, or undefined if no closest track is found.
685
+ * @param data
686
+ * @param player
687
+ * @returns
688
+ */
689
+ getClosestTrack(data: UnresolvedTrack, player: AmberLinkPlayer): Promise<Track | undefined>;
690
+ /**
691
+ * Validates the query string against various criteria, including checking for empty strings, length limits for specific sources, blacklisted links or words, and ensuring that the server node has the necessary source managers enabled for the provided query. The function also includes debug event emissions to assist with troubleshooting and understanding the validation process.
692
+ * @param node
693
+ * @param queryString
694
+ * @param sourceString
695
+ * @returns
696
+ */
697
+ validateQueryString(node: AmberLinkNode, queryString: string, sourceString?: SearchPlatform): void;
698
+ /**
699
+ * Finds the source of a query string by checking if it starts with a valid source prefix defined in the Default Sources object. If a valid source prefix is found, it returns the corresponding SearchPlatform; otherwise, it returns null. This function is useful for determining the intended search platform for a given query string, allowing for more accurate search results when the user specifies a source (e.g., "ytsearch:Never Gonna Give You Up" would indicate that the search should be performed on YouTube).
700
+ * @param queryString
701
+ * @returns
702
+ */
703
+ findSourceOfQuery(queryString: string): SearchPlatform;
704
+ /**
705
+ * Extracts the source from the query if it starts with a valid source prefix (e.g., "ytsearch:") and updates the searchQuery object accordingly.
706
+ * @param searchQuery
707
+ * @returns The updated searchQuery object with the extracted source and modified query string.
708
+ */
709
+ extractSourceOfQuery<T extends {
710
+ query: string;
711
+ source?: string;
712
+ }>(searchQuery: T): T;
713
+ /**
714
+ * Converts a string to lowercase if the input is a string, otherwise returns the input as is. This is useful for ensuring that search platform identifiers are case-insensitive while allowing other types of input to pass through unchanged.
715
+ * @param input
716
+ * @returns
717
+ */
718
+ typedLowerCase<T extends unknown>(input: T): T;
719
+ /**
720
+ * Transforms a search query by determining the appropriate search platform based on the query string and the default search platform specified in the AmberLinkManager options. It checks if the query string starts with a valid source prefix and extracts it if present. The function returns an object containing the modified query string, any extra URL parameters, and the determined search platform to be used for the search operation.
721
+ * @param query
722
+ * @returns
723
+ */
724
+ transformQuery(query: SearchQuery): {
725
+ query: string;
726
+ extraQueryUrlParams: any;
727
+ source: SearchPlatform;
728
+ };
729
+ /**
730
+ * Transforms a ExtendedSearchQuery by determining the appropriate search platform based on the query string and the default search platform specified in the AmberLinkManager options. It checks if the query string starts with a valid source prefix and extracts it if present. The function returns an object containing the modified query string, any extra URL parameters, the determined search platform to be used for the search operation, and the types of search (track, playlist, artist, album, text) to be performed.
731
+ * @param query
732
+ * @returns
733
+ */
734
+ transformExtendedSearchQuery(query: ExtendedSearchQuery): {
735
+ query: never;
736
+ types: any[];
737
+ extraQueryUrlParams: any;
738
+ source: SearchPlatform;
739
+ } | {
740
+ query: string;
741
+ types: string[];
742
+ source: "admsearch" | "am" | "amsearch" | "amzsearch" | "apple" | "apple music" | "applemusic" | "bandcamp" | "bc" | "bcsearch" | "deezer" | "dz" | "dzisrc" | "dzrec" | "dzsearch" | "flowery" | "flowery.tts" | "flowerytts" | "ftts" | "gnsearch" | "http" | "https" | "jiosaavn" | "js" | "jsrec" | "jssearch" | "link" | "local" | "music apple" | "music youtube" | "musicapple" | "musicyoutube" | "pandora" | "pandora music" | "pandoramusic" | "pd" | "pdsearch" | "phsearch" | "porn" | "pornhub" | "qbisrc" | "qbrec" | "qbsearch" | "qobuz" | "sc" | "scsearch" | "soundcloud" | "sp" | "speak" | "spotify" | "spotify.com" | "spotifycom" | "sprec" | "spsearch" | "spsuggestion" | "szsearch" | "td" | "tdrec" | "tdsearch" | "tidal" | "tidal music" | "tts" | "uri" | "vk" | "vk music" | "vkmusic" | "vkrec" | "vksearch" | "yandex" | "yandex music" | "yandexmusic" | "ymrec" | "ymsearch" | "youtube" | "youtube music" | "youtubemusic" | "yt" | "ytm" | "ytmsearch" | "ytsearch";
743
+ };
744
+ /**
745
+ * Validates the provided source string against the capabilities of the server node. It checks if the source string is supported by the node's enabled source managers and plugins, throwing errors if any required sources or plugins are missing for the specified search platform. This ensures that search queries are only executed with compatible sources based on the node's configuration.
746
+ * @param node
747
+ * @param sourceString
748
+ * @returns
749
+ */
750
+ validateSourceString(node: AmberLinkNode, sourceString: SearchPlatform): void;
751
+ }
752
+ /**
753
+ * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
754
+ *
755
+ * @internal
756
+ */
757
+ export interface MiniMap<K, V> extends Map<K, V> {
758
+ constructor: MiniMapConstructor;
759
+ }
760
+ export declare class MiniMap<K, V> extends Map<K, V> {
761
+ constructor(data?: [K, V][]);
762
+ /**
763
+ * Identical to
764
+ * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
765
+ * but returns a MiniMap instead of an Array.
766
+ *
767
+ * @param fn The function to test with (should return boolean)
768
+ * @param thisArg Value to use as `this` when executing function
769
+ *
770
+ * @example
771
+ * miniMap.filter(user => user.username === 'Bob');
772
+ */
773
+ filter<K2 extends K>(fn: (value: V, key: K, miniMap: this) => key is K2): MiniMap<K2, V>;
774
+ filter<V2 extends V>(fn: (value: V, key: K, miniMap: this) => value is V2): MiniMap<K, V2>;
775
+ filter(fn: (value: V, key: K, miniMap: this) => boolean): MiniMap<K, V>;
776
+ filter<This, K2 extends K>(fn: (this: This, value: V, key: K, miniMap: this) => key is K2, thisArg: This): MiniMap<K2, V>;
777
+ filter<This, V2 extends V>(fn: (this: This, value: V, key: K, miniMap: this) => value is V2, thisArg: This): MiniMap<K, V2>;
778
+ filter<This>(fn: (this: This, value: V, key: K, miniMap: this) => boolean, thisArg: This): MiniMap<K, V>;
779
+ toJSON(): [K, V][];
780
+ /**
781
+ * Maps each item to another value into an array. Identical in behavior to
782
+ * [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
783
+ *
784
+ * @param fn Function that produces an element of the new array, taking three arguments
785
+ * @param thisArg Value to use as `this` when executing function
786
+ *
787
+ * @example
788
+ * miniMap.map(user => user.tag);
789
+ */
790
+ map<T>(fn: (value: V, key: K, miniMap: this) => T): T[];
791
+ map<This, T>(fn: (this: This, value: V, key: K, miniMap: this) => T, thisArg: This): T[];
792
+ }
793
+ export declare function queueTrackEnd(player: AmberLinkPlayer, dontShiftQueue?: boolean): Promise<Track>;
794
+ export declare function safeStringify(obj: any, padding?: number): string;
795
+ /** Helper for generating Opaque types. */
796
+ export type Opaque<T, K> = T & {
797
+ __opaque__: K;
798
+ };
799
+ /** Opqaue tyep for integernumber */
800
+ export type IntegerNumber = Opaque<number, "Int">;
801
+ /** Opqaue tyep for floatnumber */
802
+ export type FloatNumber = Opaque<number, "Float">;
803
+ export type SourcePluginSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "dzrec" | "ymsearch" | "ymrec" | "vksearch" | "vkrec" | "tdsearch" | "tdrec" | "qbsearch" | "qbisrc" | "qbrec" | "ytsearch" | "jssearch" | "jsrec";
804
+ export type SourcePluginSearchPlatform = SourcePluginSearchPlatformBase | "ftts";
805
+ export type JioSaavnSearchPlatform = "jssearch" | "jsrec";
806
+ export type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
807
+ export type PulseLinkSearchPlatform = "spsearch" | "amzsearch" | "amsearch" | "dzsearch" | "ymsearch" | "vksearch" | "tdsearch" | "qbsearch" | "jssearch" | "admsearch" | "gnsearch" | "szsearch" | "pdsearch" | "ytsearch" | "ytmsearch";
808
+ export type ClientSearchPlatformNode = "bcsearch";
809
+ export type ClientSearchPlatformResolve = "bandcamp" | "bc";
810
+ export type AudioSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | SourcePluginSearchPlatform | DuncteSearchPlatform | PulseLinkSearchPlatform | JioSaavnSearchPlatform | ClientSearchPlatformNode;
811
+ export type NodeLinkSearchPlatformBase = "ytsearch" | "ytmsearch" | "scsearch" | "search" | "spsearch" | "amsearch" | "dzsearch" | "tdsearch" | "bcsearch" | "admsearch" | "audiomack" | "gaanasearch" | "jssearch" | "lfsearch" | "pdsearch" | "vksearch" | "mcsearch" | "ncsearch" | "nicovideo" | "bilibili" | "shsearch" | "szsearch" | "ebox" | "jukebox" | "slsearch" | "qbsearch" | "ymsearch" | "ausearch" | "azsearch" | "agsearch" | "bksearch" | "lmsearch" | "pipertts" | "gtts" | "speak" | "ftts" | "flowery" | "gdsearch";
812
+ export type NodeLinkRecommendationPlatform = "ytrec" | "sprec" | "dzrec" | "tdrec" | "jsrec" | "vkrec";
813
+ export type NodeLinkSearchPlatform = NodeLinkSearchPlatformBase | NodeLinkRecommendationPlatform;
814
+ export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
815
+ export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "vk" | "vk music" | "vkmusic" | "tidal" | "tidal music" | "qobuz" | "pandora" | "pd" | "pandora music" | "pandoramusic" | "flowerytts" | "flowery" | "flowery.tts" | ClientSearchPlatformResolve | ClientSearchPlatformNode | "js" | "jiosaavn" | "td" | "tidal" | "tdrec";
816
+ export type SearchPlatform = AudioSearchPlatform | ClientSearchPlatform;
817
+ export type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "jiosaavn" | "appleMusic" | "tidal" | "PandoraTrackRegex" | "PandoraAlbumRegex" | "PandoraArtistRegex" | "PandoraPlaylistRegex" | "AllPandoraRegex" | "TwitchTv" | "vimeo";
818
+ export interface PlaylistInfo {
819
+ /** The playlist name */
820
+ name: string;
821
+ /** The playlist title (same as name) */
822
+ title: string;
823
+ /** The playlist Author */
824
+ author?: string;
825
+ /** The playlist Thumbnail */
826
+ thumbnail?: string;
827
+ /** A Uri to the playlist */
828
+ uri?: string;
829
+ /** The playlist selected track. */
830
+ selectedTrack: Track | null;
831
+ /** The duration of the entire playlist. (calcualted) */
832
+ duration: number;
833
+ }
834
+ export interface SearchResult {
835
+ loadType: LoadTypes;
836
+ exception: Exception | null;
837
+ pluginInfo: PluginInfo;
838
+ playlist: PlaylistInfo | null;
839
+ tracks: Track[];
840
+ }
841
+ export interface UnresolvedSearchResult {
842
+ loadType: LoadTypes;
843
+ exception: Exception | null;
844
+ pluginInfo: PluginInfo;
845
+ playlist: PlaylistInfo | null;
846
+ tracks: UnresolvedTrack[];
847
+ }
848
+ /**
849
+ * @internal
850
+ */
851
+ export interface MiniMapConstructor {
852
+ new (): MiniMap<unknown, unknown>;
853
+ new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): MiniMap<K, V>;
854
+ new <K, V>(iterable: Iterable<readonly [K, V]>): MiniMap<K, V>;
855
+ readonly prototype: MiniMap<unknown, unknown>;
856
+ readonly [Symbol.species]: MiniMapConstructor;
857
+ }
858
+ export type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents | LyricsEvent;
859
+ export type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
860
+ export interface Exception {
861
+ /** Severity of the error */
862
+ severity: Severity;
863
+ /** Nodejs Error */
864
+ error?: Error;
865
+ /** Message by AmberLink server */
866
+ message: string;
867
+ /** Cause by AmberLink server */
868
+ cause: string;
869
+ /** causeStackTrace by AmberLink server */
870
+ causeStackTrace: string;
871
+ }
872
+ export interface PlayerEvent {
873
+ op: "event";
874
+ type: PlayerEventType;
875
+ guildId: string;
876
+ }
877
+ export interface TrackStartEvent extends PlayerEvent {
878
+ type: "TrackStartEvent";
879
+ track: AudioNodeTrack;
880
+ }
881
+ export interface TrackEndEvent extends PlayerEvent {
882
+ type: "TrackEndEvent";
883
+ track: AudioNodeTrack;
884
+ reason: TrackEndReason;
885
+ }
886
+ export interface TrackExceptionEvent extends PlayerEvent {
887
+ type: "TrackExceptionEvent";
888
+ exception?: Exception;
889
+ track: AudioNodeTrack;
890
+ error: string;
891
+ }
892
+ export interface TrackStuckEvent extends PlayerEvent {
893
+ type: "TrackStuckEvent";
894
+ thresholdMs: number;
895
+ track: AudioNodeTrack;
896
+ }
897
+ export interface WebSocketClosedEvent extends PlayerEvent {
898
+ type: "WebSocketClosedEvent";
899
+ code: number;
900
+ byRemote: boolean;
901
+ reason: string;
902
+ }
903
+ /**
904
+ * Types & Events for Sponsorblock-plugin from AmberLink server: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
905
+ */
906
+ export type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
907
+ export type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
908
+ export interface SponsorBlockSegmentsLoaded extends PlayerEvent {
909
+ type: "SegmentsLoaded";
910
+ segments: {
911
+ category: string;
912
+ start: number;
913
+ end: number;
914
+ }[];
915
+ }
916
+ export interface SponsorBlockSegmentSkipped extends PlayerEvent {
917
+ type: "SegmentSkipped";
918
+ segment: {
919
+ category: string;
920
+ start: number;
921
+ end: number;
922
+ };
923
+ }
924
+ export interface SponsorBlockChapterStarted extends PlayerEvent {
925
+ type: "ChapterStarted";
926
+ /** The Chapter which started */
927
+ chapter: {
928
+ /** The Name of the Chapter */
929
+ name: string;
930
+ start: number;
931
+ end: number;
932
+ duration: number;
933
+ };
934
+ }
935
+ export interface SponsorBlockChaptersLoaded extends PlayerEvent {
936
+ type: "ChaptersLoaded";
937
+ /** All Chapters loaded */
938
+ chapters: {
939
+ /** The Name of the Chapter */
940
+ name: string;
941
+ start: number;
942
+ end: number;
943
+ duration: number;
944
+ }[];
945
+ }
946
+ /**
947
+ * Types & Events for Lyrics plugin from AmberLink server: https://github.com/topi314/LavaLyrics
948
+ */
949
+ export type LyricsEvent = LyricsFoundEvent | LyricsNotFoundEvent | LyricsLineEvent;
950
+ export type LyricsEventType = "LyricsFoundEvent" | "LyricsNotFoundEvent" | "LyricsLineEvent";
951
+ export interface LyricsFoundEvent extends PlayerEvent {
952
+ /** The lyricsfound event */
953
+ type: "LyricsFoundEvent";
954
+ /** The guildId */
955
+ guildId: string;
956
+ /** The lyrics */
957
+ lyrics: LyricsResult;
958
+ }
959
+ export interface LyricsNotFoundEvent extends PlayerEvent {
960
+ /**The lyricsnotfound event*/
961
+ type: "LyricsNotFoundEvent";
962
+ /**The guildId*/
963
+ guildId: string;
964
+ }
965
+ export interface LyricsLineEvent extends PlayerEvent {
966
+ /**The lyricsline event*/
967
+ type: "LyricsLineEvent";
968
+ /** The guildId */
969
+ guildId: string;
970
+ /** The line number */
971
+ lineIndex: number;
972
+ /** The line */
973
+ line: LyricsLine;
974
+ /**skipped is true if the line was skipped */
975
+ skipped: boolean;
976
+ }
977
+ export type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
978
+ export type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
979
+ export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType | LyricsEventType;
980
+ export type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
981
+ export interface InvalidNodeRestRequest {
982
+ /** Rest Request Data for when it was made */
983
+ timestamp: number;
984
+ /** Status of the request */
985
+ status: number;
986
+ /** Specific Errro which was sent */
987
+ error: string;
988
+ /** Specific Message which was created */
989
+ message?: string;
990
+ /** The specific error trace from the request */
991
+ trace?: unknown;
992
+ /** Path of where it's from */
993
+ path: string;
994
+ }
995
+ export interface NodePlayerVoice {
996
+ /** The Voice Token */
997
+ token: string;
998
+ /** The Voice Server Endpoint */
999
+ endpoint: string;
1000
+ /** The Voice SessionId */
1001
+ sessionId: string;
1002
+ /** The Voice Channel Id */
1003
+ channelId?: string;
1004
+ /** Whether or not the player is connected */
1005
+ connected?: boolean;
1006
+ /** The Ping to the voice server */
1007
+ ping?: number;
1008
+ }
1009
+ export type NodePlayerVoiceOptions = Omit<NodePlayerVoice, "connected" | "ping">;
1010
+ export interface FailingAddress {
1011
+ /** The failing address */
1012
+ failingAddress: string;
1013
+ /** The timestamp when the address failed */
1014
+ failingTimestamp: number;
1015
+ /** The timestamp when the address failed as a pretty string */
1016
+ failingTime: string;
1017
+ }
1018
+ export type RoutePlannerTypes = "RotatingIpRoutePlanner" | "NanoIpRoutePlanner" | "RotatingNanoIpRoutePlanner" | "BalancingIpRoutePlanner";
1019
+ export interface RoutePlanner {
1020
+ class?: RoutePlannerTypes;
1021
+ details?: {
1022
+ /** The ip block being used */
1023
+ ipBlock: {
1024
+ /** The type of the ip block */
1025
+ type: "Inet4Address" | "Inet6Address";
1026
+ /** The size of the ip block */
1027
+ size: string;
1028
+ };
1029
+ /** The failing addresses */
1030
+ failingAddresses: FailingAddress[];
1031
+ /** The number of rotations */
1032
+ rotateIndex?: string;
1033
+ /** The current offset in the block */
1034
+ ipIndex?: string;
1035
+ /** The current address being used */
1036
+ currentAddress?: string;
1037
+ /** The current offset in the ip block */
1038
+ currentAddressIndex?: string;
1039
+ /** The information in which /64 block ips are chosen. This number increases on each ban. */
1040
+ blockIndex?: string;
1041
+ };
1042
+ }
1043
+ export interface Session {
1044
+ /** Whether or not session is resuming or not */
1045
+ resuming: boolean;
1046
+ /** For how long a session is lasting while not connected */
1047
+ timeout: number;
1048
+ }
1049
+ export interface GuildShardPayload {
1050
+ /** The OP code */
1051
+ op: number;
1052
+ /** Data to send */
1053
+ d: {
1054
+ /** Guild id to apply voice settings */
1055
+ guild_id: string;
1056
+ /** channel to move/connect to, or null to leave it */
1057
+ channel_id: string | null;
1058
+ /** whether or not mute yourself */
1059
+ self_mute: boolean;
1060
+ /** whether or not deafen yourself */
1061
+ self_deaf: boolean;
1062
+ };
1063
+ }
1064
+ export interface PlayerUpdateInfo {
1065
+ /** guild id of the player */
1066
+ guildId: string;
1067
+ /** AmberLinkPlayer options to provide to AmberLink server */
1068
+ playerOptions: NodePlayOptions;
1069
+ /** Whether or not replace the current track with the new one (true is recommended) */
1070
+ noReplace?: boolean;
1071
+ }
1072
+ export interface NodePlayerData {
1073
+ /** Guild Id of the player */
1074
+ guildId: string;
1075
+ /** IF playing a track, all of the track information */
1076
+ track?: AudioNodeTrack;
1077
+ /** Audio-node volume (mind volumeDecrementer) */
1078
+ volume: number;
1079
+ /** Whether it's paused or not */
1080
+ paused: boolean;
1081
+ /** Voice Endpoint data */
1082
+ voice: NodePlayerVoice;
1083
+ /** All Audio Filters */
1084
+ filters: Partial<AudioFilterData>;
1085
+ /** AmberLink server-Voice-State Variables */
1086
+ state: {
1087
+ /** Time since connection established */
1088
+ time: number;
1089
+ /** Position of the track */
1090
+ position: number;
1091
+ /** COnnected or not */
1092
+ connected: boolean;
1093
+ /** Ping to voice server */
1094
+ ping: number;
1095
+ };
1096
+ }
1097
+ export interface ChannelDeletePacket {
1098
+ /** Packet key for channel delete */
1099
+ t: "CHANNEL_DELETE";
1100
+ /** data which is sent and relevant */
1101
+ d: {
1102
+ /** guild id */
1103
+ guild_id: string;
1104
+ /** Channel id */
1105
+ id: string;
1106
+ };
1107
+ }
1108
+ export interface VoiceState {
1109
+ /** OP key from AmberLink server */
1110
+ op: "voiceUpdate";
1111
+ /** GuildId provided by AmberLink server */
1112
+ guildId: string;
1113
+ /** Event data */
1114
+ event: VoiceServer;
1115
+ /** Session Id of the voice connection */
1116
+ sessionId?: string;
1117
+ /** guild id of the voice channel */
1118
+ guild_id: string;
1119
+ /** user id from the voice connection */
1120
+ user_id: string;
1121
+ /** Session Id of the voice connection */
1122
+ session_id: string;
1123
+ /** Voice Channel Id */
1124
+ channel_id: string;
1125
+ /** Server Mute status */
1126
+ mute: boolean;
1127
+ /** Server Deaf status */
1128
+ deaf: boolean;
1129
+ /** Self Deaf status */
1130
+ self_deaf: boolean;
1131
+ /** Self Mute status */
1132
+ self_mute: boolean;
1133
+ /** Self Video (Camera) status */
1134
+ self_video: boolean;
1135
+ /** Self Stream status */
1136
+ self_stream: boolean;
1137
+ /** Whether the user requests to speak (stage channel) */
1138
+ request_to_speak_timestamp: boolean;
1139
+ /** Self suppressed status (stage channel) */
1140
+ suppress: boolean;
1141
+ }
1142
+ /** The Base64 decodes tring by AmberLink server */
1143
+ export type Base64 = string;
1144
+ export interface VoiceServer {
1145
+ /** Voice Token */
1146
+ token: string;
1147
+ /** Guild Id of the voice server connection */
1148
+ guild_id: string;
1149
+ /** Server Endpoint */
1150
+ endpoint: string;
1151
+ /** Voice Channel Id used by DAVE-capable servers */
1152
+ channel_id?: string;
1153
+ }
1154
+ export interface VoicePacket {
1155
+ /** Voice Packet Keys to send */
1156
+ t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
1157
+ /** Voice Packets to send */
1158
+ d: VoiceState | VoiceServer;
1159
+ }
1160
+ export interface NodeMessage extends NodeStats {
1161
+ /** The type of the event */
1162
+ type: PlayerEventType;
1163
+ /** what ops are applying to that event */
1164
+ op: "stats" | "playerUpdate" | "event";
1165
+ /** The specific guild id for that message */
1166
+ guildId: string;
1167
+ }
1168
+ /** Specific types to filter for lavasearch, will be filtered to correct types */
1169
+ export type ExtendedSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
1170
+ export interface ExtendedSearchFilteredResponse {
1171
+ /** The Information of a playlist provided by lavasearch */
1172
+ info: PlaylistInfo;
1173
+ /** additional plugin information */
1174
+ pluginInfo: PluginInfo;
1175
+ /** List of tracks */
1176
+ tracks: Track[];
1177
+ }
1178
+ export interface ExtendedSearchResponse {
1179
+ /** An array of tracks, only present if track is in types */
1180
+ tracks: Track[];
1181
+ /** An array of albums, only present if album is in types */
1182
+ albums: ExtendedSearchFilteredResponse[];
1183
+ /** An array of artists, only present if artist is in types */
1184
+ artists: ExtendedSearchFilteredResponse[];
1185
+ /** An array of playlists, only present if playlist is in types */
1186
+ playlists: ExtendedSearchFilteredResponse[];
1187
+ /** An array of text results, only present if text is in types */
1188
+ texts: {
1189
+ text: string;
1190
+ pluginInfo: PluginInfo;
1191
+ }[];
1192
+ /** Addition result data provided by plugins */
1193
+ pluginInfo: PluginInfo;
1194
+ }
1195
+ /** SearchQuery Object for raw AmberLink server requests */
1196
+ export type SearchQuery = {
1197
+ /** AmberLink server search Query / identifier string */
1198
+ query: string;
1199
+ /** Extra url query params to use, e.g. for flowertts */
1200
+ extraQueryUrlParams?: URLSearchParams;
1201
+ /** Source to append to the search query string */
1202
+ source?: SearchPlatform;
1203
+ } | /** Our just the search query / identifier string */ string;
1204
+ /** SearchQuery Object for AmberLink server LavaSearch Plugin requests */
1205
+ export type ExtendedSearchQuery = {
1206
+ /** AmberLink server search Query / identifier string */
1207
+ query: string;
1208
+ /** Source to append to the search query string */
1209
+ source: SourcePluginSearchPlatformBase;
1210
+ /** The Types to filter the search to */
1211
+ types?: ExtendedSearchType[];
1212
+ };
1213
+ export type Awaitable<T> = Promise<T> | T;
1214
+ /** The Audio Outputs type */
1215
+ export type AudioOutputs = "mono" | "stereo" | "left" | "right";
1216
+ /** The "active" / "disabled" AmberLinkPlayer Filters */
1217
+ export interface PlayerFilters {
1218
+ /** Sets nightcore to false, and vaporwave to false */
1219
+ custom: boolean;
1220
+ /** Sets custom to false, and vaporwave to false */
1221
+ nightcore: boolean;
1222
+ /** Sets custom to false, and nightcore to false */
1223
+ vaporwave: boolean;
1224
+ /** If rotation filter is enabled / not */
1225
+ rotation: boolean;
1226
+ /** if karaoke filter is enabled / not */
1227
+ karaoke: boolean;
1228
+ /** if tremolo filter is enabled / not */
1229
+ tremolo: boolean;
1230
+ /** if vibrato filter is enabled / not */
1231
+ vibrato: boolean;
1232
+ lowPass: boolean;
1233
+ /** audio Output (default stereo, mono sounds the fullest and best for not-stereo tracks) */
1234
+ audioOutput: AudioOutputs;
1235
+ /** if NodeLink echo filter is enabled / not */
1236
+ nodeLinkEcho: boolean;
1237
+ /** if NodeLink chorus filter is enabled / not */
1238
+ nodeLinkChorus: boolean;
1239
+ /** if NodeLink compressor filter is enabled / not */
1240
+ nodeLinkCompressor: boolean;
1241
+ /** if NodeLink highpass filter is enabled / not */
1242
+ nodeLinkHighPass: boolean;
1243
+ /** if NodeLink phaser filter is enabled / not */
1244
+ nodeLinkPhaser: boolean;
1245
+ /** if NodeLink spatial filter is enabled / not */
1246
+ nodeLinkSpatial: boolean;
1247
+ /** Audio-node volume filter (not player Volume, think of it as a gain booster) */
1248
+ volume: boolean;
1249
+ /** Filters for the AmberLink server Filter Plugin */
1250
+ thirdPartyFilterEffects: {
1251
+ /** if echo filter is enabled / not */
1252
+ echo: boolean;
1253
+ /** if reverb filter is enabled / not */
1254
+ reverb: boolean;
1255
+ };
1256
+ thirdPartyDspxEffects: {
1257
+ /** if lowPass filter is enabled / not */
1258
+ lowPass: boolean;
1259
+ /** if highPass filter is enabled / not */
1260
+ highPass: boolean;
1261
+ /** if normalization filter is enabled / not */
1262
+ normalization: boolean;
1263
+ /** if echo filter is enabled / not */
1264
+ echo: boolean;
1265
+ };
1266
+ }
1267
+ /**
1268
+ * There are 15 bands (0-14) that can be changed.
1269
+ * "gain" is the multiplier for the given band.
1270
+ * The default value is 0.
1271
+ * Valid values range from -0.25 to 1.0, where -0.25 means the given band is completely muted, and 0.25 means it is doubled.
1272
+ * Modifying the gain could also change the volume of the output.
1273
+ */
1274
+ export interface EQBand {
1275
+ /** On what band position (0-14) it should work */
1276
+ band: IntegerNumber | number;
1277
+ /** The gain (-0.25 to 1.0) */
1278
+ gain: FloatNumber | number;
1279
+ }
1280
+ /**
1281
+ * Uses equalization to eliminate part of a band, usually targeting vocals.
1282
+ */
1283
+ export interface KaraokeFilter {
1284
+ /** The level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
1285
+ level?: number;
1286
+ /** The mono level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
1287
+ monoLevel?: number;
1288
+ /** The filter band (in Hz) */
1289
+ filterBand?: number;
1290
+ /** The filter width */
1291
+ filterWidth?: number;
1292
+ }
1293
+ /**
1294
+ * Changes the speed, pitch, and rate
1295
+ */
1296
+ export interface TimescaleFilter {
1297
+ /** The playback speed 0.0 ≤ x */
1298
+ speed?: number;
1299
+ /** The pitch 0.0 ≤ x */
1300
+ pitch?: number;
1301
+ /** The rate 0.0 ≤ x */
1302
+ rate?: number;
1303
+ }
1304
+ /**
1305
+ * Uses amplification to create a shuddering effect, where the volume quickly oscillates.
1306
+ * Demo: https://en.wikipedia.org/wiki/File:Fuse_Electronics_Tremolo_MK-III_Quick_Demo.ogv
1307
+ */
1308
+ export interface TremoloFilter {
1309
+ /** The frequency 0.0 < x */
1310
+ frequency?: number;
1311
+ /** The tremolo depth 0.0 < x ≤ 1.0 */
1312
+ depth?: number;
1313
+ }
1314
+ /**
1315
+ * Similar to tremolo. While tremolo oscillates the volume, vibrato oscillates the pitch.
1316
+ */
1317
+ export interface VibratoFilter {
1318
+ /** The frequency 0.0 < x ≤ 14.0 */
1319
+ frequency?: number;
1320
+ /** The vibrato depth 0.0 < x ≤ 1.0 */
1321
+ depth?: number;
1322
+ }
1323
+ /**
1324
+ * Rotates the sound around the stereo channels/user headphones (aka Audio Panning).
1325
+ * It can produce an effect similar to https://youtu.be/QB9EB8mTKcc (without the reverb).
1326
+ */
1327
+ export interface RotationFilter {
1328
+ /** The frequency of the audio rotating around the listener in Hz. 0.2 is similar to the example video above */
1329
+ rotationHz?: number;
1330
+ }
1331
+ /**
1332
+ * Distortion effect. It can generate some pretty unique audio effects.
1333
+ */
1334
+ export interface DistortionFilter {
1335
+ sinOffset?: number;
1336
+ sinScale?: number;
1337
+ cosOffset?: number;
1338
+ cosScale?: number;
1339
+ tanOffset?: number;
1340
+ tanScale?: number;
1341
+ offset?: number;
1342
+ scale?: number;
1343
+ }
1344
+ /**
1345
+ * Mixes both channels (left and right), with a configurable factor on how much each channel affects the other.
1346
+ * With the defaults, both channels are kept independent of each other.
1347
+ * Setting all factors to 0.5 means both channels get the same audio.
1348
+ */
1349
+ export interface ChannelMixFilter {
1350
+ /** The left to left channel mix factor (0.0 ≤ x ≤ 1.0) */
1351
+ leftToLeft?: number;
1352
+ /** The left to right channel mix factor (0.0 ≤ x ≤ 1.0) */
1353
+ leftToRight?: number;
1354
+ /** The right to left channel mix factor (0.0 ≤ x ≤ 1.0) */
1355
+ rightToLeft?: number;
1356
+ /** The right to right channel mix factor (0.0 ≤ x ≤ 1.0) */
1357
+ rightToRight?: number;
1358
+ }
1359
+ /**
1360
+ * Creates delay-based echo with feedback control
1361
+ */
1362
+ export interface NodeLink_EchoFilter {
1363
+ /** Delay time in milliseconds (0 to 5000ms) */
1364
+ delay?: number;
1365
+ /** Amount of signal fed back into the delay (0.0 to 1.0) */
1366
+ feedback?: number;
1367
+ /** Dry/wet mix ratio (0.0 = dry only, 1.0 = wet only) */
1368
+ mix?: number;
1369
+ }
1370
+ /**
1371
+ * Simulates multiple voices playing together with modulated delays
1372
+ */
1373
+ export interface NodeLink_ChorusFilter {
1374
+ /** LFO modulation rate in Hz */
1375
+ rate?: number;
1376
+ /** Modulation depth (0.0 to 1.0) */
1377
+ depth?: number;
1378
+ /** Base delay time in milliseconds (1 to 45ms) */
1379
+ delay?: number;
1380
+ /** Dry/wet mix ratio (0.0 to 1.0) */
1381
+ mix?: number;
1382
+ /** Feedback amount (0.0 to 0.95) */
1383
+ feedback?: number;
1384
+ }
1385
+ /**
1386
+ * Dynamic range compression for balanced audio levels
1387
+ */
1388
+ export interface NodeLink_CompressorFilter {
1389
+ /** Threshold level in dB (when compression starts) */
1390
+ threshold?: number;
1391
+ /** Compression ratio (1.0 = no compression, higher = more compression) */
1392
+ ratio?: number;
1393
+ /** Attack time in milliseconds (how fast compression engages) */
1394
+ attack?: number;
1395
+ /** Release time in milliseconds (how fast compression disengages) */
1396
+ release?: number;
1397
+ /** Makeup gain in dB (compensates for volume reduction) */
1398
+ gain?: number;
1399
+ }
1400
+ /**
1401
+ * Filters out low frequencies, letting high frequencies pass through
1402
+ */
1403
+ export interface NodeLink_HighPassFilter {
1404
+ /** Smoothing factor (must be > 1.0 to enable) */
1405
+ smoothing?: number;
1406
+ }
1407
+ /**
1408
+ * Sweeps all-pass filters across the frequency spectrum for a swooshing effect
1409
+ */
1410
+ export interface NodeLink_PhaserFilter {
1411
+ /** Number of filter stages (2 to 12, more = stronger effect) */
1412
+ stages?: number;
1413
+ /** LFO sweep rate in Hz */
1414
+ rate?: number;
1415
+ /** Modulation depth (0.0 to 1.0) */
1416
+ depth?: number;
1417
+ /** Feedback amount (0.0 to 0.9) */
1418
+ feedback?: number;
1419
+ /** Dry/wet mix ratio (0.0 to 1.0) */
1420
+ mix?: number;
1421
+ /** Minimum sweep frequency in Hz */
1422
+ minFrequency?: number;
1423
+ /** Maximum sweep frequency in Hz */
1424
+ maxFrequency?: number;
1425
+ }
1426
+ /**
1427
+ * Creates spatial audio using cross-channel delays and modulation
1428
+ */
1429
+ export interface NodeLink_SpatialFilter {
1430
+ /** Effect depth (0.0 to 1.0) */
1431
+ depth?: number;
1432
+ /** Modulation rate in Hz */
1433
+ rate?: number;
1434
+ }
1435
+ /**
1436
+ * Higher frequencies get suppressed, while lower frequencies pass through this filter, thus the name low pass.
1437
+ * Any smoothing values equal to or less than 1.0 will disable the filter.
1438
+ */
1439
+ export interface LowPassFilter {
1440
+ /** The smoothing factor (1.0 < x) */
1441
+ smoothing?: number;
1442
+ }
1443
+ /** Typed filter payloads for optional third-party extensions. */
1444
+ export interface ThirdPartyExtensionFilterData {
1445
+ echo?: {
1446
+ delay?: number;
1447
+ decay?: number;
1448
+ echoLength?: number;
1449
+ };
1450
+ delay?: number;
1451
+ decay?: number;
1452
+ echoLength?: number;
1453
+ reverb?: {
1454
+ delays?: number[];
1455
+ gains?: number[];
1456
+ };
1457
+ cutoffFrequency?: number;
1458
+ boostFactor?: number;
1459
+ maxAmplitude?: number;
1460
+ adaptive?: boolean;
1461
+ [key: string]: unknown;
1462
+ }
1463
+ /**
1464
+ * Filter Data stored in the Client and partially sent to AmberLink server
1465
+ */
1466
+ export interface FilterData {
1467
+ volume?: number;
1468
+ karaoke?: KaraokeFilter;
1469
+ timescale?: TimescaleFilter;
1470
+ tremolo?: TremoloFilter;
1471
+ vibrato?: VibratoFilter;
1472
+ rotation?: RotationFilter;
1473
+ distortion?: DistortionFilter;
1474
+ channelMix?: ChannelMixFilter;
1475
+ lowPass?: LowPassFilter;
1476
+ echo?: NodeLink_EchoFilter;
1477
+ chorus?: NodeLink_ChorusFilter;
1478
+ compressor?: NodeLink_CompressorFilter;
1479
+ highPass?: NodeLink_HighPassFilter;
1480
+ phaser?: NodeLink_PhaserFilter;
1481
+ spatial?: NodeLink_SpatialFilter;
1482
+ pluginFilters?: Record<string, ThirdPartyExtensionFilterData>;
1483
+ }
1484
+ /**
1485
+ * Actual Filter Data sent to AmberLink server
1486
+ */
1487
+ export interface AudioFilterData extends FilterData {
1488
+ equalizer?: EQBand[];
1489
+ }
1490
+ export type NodeLinkEventTypes = "PlayerCreatedEvent" | "PlayerDestroyedEvent" | "PlayerConnectedEvent" | "PlayerReconnectingEvent" | "VolumeChangedEvent" | "FiltersChangedEvent" | "SeekEvent" | "PauseEvent" | "ConnectionStatusEvent" | "MixStartedEvent" | "MixEndedEvent" | "LyricsFoundEvent" | "LyricsLineEvent" | "LyricsNotFoundEvent";
1491
+ export interface NodeLinkBaseEvent {
1492
+ op: "event";
1493
+ type: NodeLinkEventTypes;
1494
+ guildId: string;
1495
+ }
1496
+ export interface PlayerCreatedEvent extends NodeLinkBaseEvent {
1497
+ type: "PlayerCreatedEvent";
1498
+ }
1499
+ export interface PlayerDestroyedEvent extends NodeLinkBaseEvent {
1500
+ type: "PlayerDestroyedEvent";
1501
+ }
1502
+ export interface PlayerConnectedEvent extends NodeLinkBaseEvent {
1503
+ type: "PlayerConnectedEvent";
1504
+ }
1505
+ export interface PlayerReconnectingEvent extends NodeLinkBaseEvent {
1506
+ type: "PlayerReconnectingEvent";
1507
+ }
1508
+ export interface VolumeChangedEvent extends NodeLinkBaseEvent {
1509
+ type: "VolumeChangedEvent";
1510
+ /** New volume level (0-1000) */
1511
+ volume: number;
1512
+ }
1513
+ export interface FiltersChangedEvent extends NodeLinkBaseEvent {
1514
+ type: "FiltersChangedEvent";
1515
+ filters: AudioFilterData;
1516
+ }
1517
+ export interface SeekEvent extends NodeLinkBaseEvent {
1518
+ type: "SeekEvent";
1519
+ /** New position in milliseconds */
1520
+ position: number;
1521
+ }
1522
+ export interface PauseEvent extends NodeLinkBaseEvent {
1523
+ type: "PauseEvent";
1524
+ /** Whether playback is now paused (true) or resumed (false) */
1525
+ paused: boolean;
1526
+ }
1527
+ export interface ConnectionStatusEvent extends NodeLinkBaseEvent {
1528
+ type: "ConnectionStatusEvent";
1529
+ /** Current connection status */
1530
+ connected: boolean;
1531
+ }
1532
+ export interface MixStartedEvent extends NodeLinkBaseEvent {
1533
+ type: "MixStartedEvent";
1534
+ /** Unique identifier for the mix layer */
1535
+ mixId: string;
1536
+ /** Full track information of the mixed layer */
1537
+ track: AudioNodeTrack;
1538
+ /** Volume of the mixed layer (0.0 to 1.0) */
1539
+ volume: number;
1540
+ }
1541
+ export interface MixEndedEvent extends NodeLinkBaseEvent {
1542
+ type: "MixEndedEvent";
1543
+ /** Unique identifier for the mix layer */
1544
+ mixId: string;
1545
+ /** Reason the mix layer ended (FINISHED, REMOVED, ERROR, MAIN_ENDED) */
1546
+ reason: "FINISHED" | "REMOVED" | "ERROR" | "MAIN_ENDED" | string;
1547
+ }
1548
+ export type NodeLinkEventPayload<T extends NodeLinkEventTypes> = T extends "PlayerCreatedEvent" ? PlayerCreatedEvent : T extends "PlayerDestroyedEvent" ? PlayerDestroyedEvent : T extends "PlayerConnectedEvent" ? PlayerConnectedEvent : T extends "PlayerReconnectingEvent" ? PlayerReconnectingEvent : T extends "VolumeChangedEvent" ? VolumeChangedEvent : T extends "FiltersChangedEvent" ? FiltersChangedEvent : T extends "SeekEvent" ? SeekEvent : T extends "PauseEvent" ? PauseEvent : T extends "ConnectionStatusEvent" ? ConnectionStatusEvent : T extends "MixStartedEvent" ? MixStartedEvent : T extends "MixEndedEvent" ? MixEndedEvent : never;
1549
+ export type HealthStatusThreshold = {
1550
+ excellent: number;
1551
+ good: number;
1552
+ fair: number;
1553
+ poor: number;
1554
+ };
1555
+ export type HealthStatusThresholdOptions = {
1556
+ cpu: Partial<HealthStatusThreshold>;
1557
+ memory: Partial<HealthStatusThreshold>;
1558
+ ping: Partial<HealthStatusThreshold>;
1559
+ };
1560
+ export type NodeMetricSummary = {
1561
+ cpuLoad: number;
1562
+ systemLoad: number;
1563
+ memoryUsage: number;
1564
+ players: number;
1565
+ playingPlayers: number;
1566
+ uptime: number;
1567
+ ping: number;
1568
+ frameDeficit: number;
1569
+ };
1570
+ export type HealthStatusObject = {
1571
+ status: HealthStatusKeys;
1572
+ performance: HealthPerformanceKeys;
1573
+ isOverloaded: boolean;
1574
+ needsRestart: boolean;
1575
+ penaltyScore: number;
1576
+ estimatedRemainingCapacity: number;
1577
+ recommendations: string[];
1578
+ metrics: {
1579
+ cpuLoad: number;
1580
+ memoryUsage: number;
1581
+ players: number;
1582
+ playingPlayers: number;
1583
+ uptime: number;
1584
+ ping: number;
1585
+ frameDeficit: number;
1586
+ };
1587
+ };
1588
+ export type HealthPerformanceKeys = "excellent" | "good" | "fair" | "poor";
1589
+ export type HealthStatusKeys = "healthy" | "degraded" | "critical" | "offline";
1590
+ export type AddMixerLayerResponse = {
1591
+ id: string;
1592
+ track: AudioNodeTrack;
1593
+ volume: number;
1594
+ };
1595
+ export type ListMixerLayersResponse = {
1596
+ mixes: {
1597
+ id: string;
1598
+ track: AudioNodeTrack;
1599
+ volume: number;
1600
+ position: number;
1601
+ startTime: number;
1602
+ }[];
1603
+ };
1604
+ export type ConnectionMetricsResponse = {
1605
+ status: string;
1606
+ metrics: {
1607
+ speed: {
1608
+ bps: number;
1609
+ kbps: number;
1610
+ mbps: number;
1611
+ };
1612
+ downloadedBytes: number;
1613
+ durationSeconds: number;
1614
+ timestamp: number;
1615
+ };
1616
+ };
1617
+ export type NodeLinkLyricsSynced = {
1618
+ loadType: string;
1619
+ data: {
1620
+ synced: true;
1621
+ lang: string;
1622
+ source: string;
1623
+ lines: [{
1624
+ text: string;
1625
+ time: number;
1626
+ duration: number;
1627
+ }, {
1628
+ text: string;
1629
+ time: number;
1630
+ duration: number;
1631
+ }, {
1632
+ text: string;
1633
+ time: number;
1634
+ duration: number;
1635
+ }];
1636
+ };
1637
+ };
1638
+ export type NodeLinkLyricsPlain = {
1639
+ loadType: string;
1640
+ data: {
1641
+ synced: false;
1642
+ lang: string;
1643
+ source: string;
1644
+ lines: [{
1645
+ text: string;
1646
+ time: null;
1647
+ duration: null;
1648
+ }, {
1649
+ text: string;
1650
+ time: null;
1651
+ duration: null;
1652
+ }, {
1653
+ text: string;
1654
+ time: null;
1655
+ duration: null;
1656
+ }];
1657
+ };
1658
+ };
1659
+ export type NodeLinkLyrics = NodeLinkLyricsSynced | NodeLinkLyricsPlain;
1660
+ export type NodeLinkNoLyrics = {
1661
+ loadType: string;
1662
+ data: {};
1663
+ };
1664
+ export type NodeLinkChapter = {
1665
+ title: string;
1666
+ startTime: number;
1667
+ thumbnails: [{
1668
+ url: string;
1669
+ width: number;
1670
+ height: number;
1671
+ }];
1672
+ duration: number;
1673
+ endTime: number;
1674
+ };
1675
+ export type DirectStreamResponse = {
1676
+ url: string;
1677
+ protocol: string;
1678
+ format: string;
1679
+ hlsUrl: string | null;
1680
+ formats: {
1681
+ itag: number;
1682
+ mimeType: string;
1683
+ qualityLabel: string;
1684
+ bitrate: number;
1685
+ }[];
1686
+ };
1687
+ export type YoutubeOAuthResponse = {
1688
+ access_token: string;
1689
+ expires_in: number;
1690
+ scope: string;
1691
+ token_type: string;
1692
+ };
1693
+ export type MeaningResponse = {
1694
+ loadType: "meaning";
1695
+ data: {
1696
+ title: string;
1697
+ description: string;
1698
+ paragraphs: string[];
1699
+ url: string;
1700
+ provider: string;
1701
+ type: string;
1702
+ };
1703
+ };
1704
+ /**
1705
+ * Debug events for more detailed logging
1706
+ */
1707
+ export declare enum DebugEvents {
1708
+ SetSponsorBlock = "SetSponsorBlock",
1709
+ DeleteSponsorBlock = "DeleteSponsorBlock",
1710
+ TrackEndReplaced = "TrackEndReplaced",
1711
+ AutoplayExecution = "AutoplayExecution",
1712
+ AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
1713
+ AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
1714
+ TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
1715
+ QueueEnded = "QueueEnded",
1716
+ TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
1717
+ TrackStartNoTrack = "TrackStartNoTrack",
1718
+ ResumingFetchingError = "ResumingFetchingError",
1719
+ PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
1720
+ PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
1721
+ PlayerUpdateSuccess = "PlayerUpdateSuccess",
1722
+ HeartBeatTriggered = "HeartBeatTriggered",
1723
+ NoSocketOnDestroy = "NoSocketOnDestroy",
1724
+ SocketCleanupError = "SocketCleanupError",
1725
+ SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
1726
+ TryingConnectWhileConnected = "TryingConnectWhileConnected",
1727
+ ExtendedSearchNothingFound = "ExtendedSearchNothingFound",
1728
+ SearchNothingFound = "SearchNothingFound",
1729
+ ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
1730
+ ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
1731
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
1732
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
1733
+ PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
1734
+ PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
1735
+ PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
1736
+ PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
1737
+ PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
1738
+ PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
1739
+ PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
1740
+ BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
1741
+ PlayerChangeNode = "PlayerChangeNode",
1742
+ BuildTrackError = "BuildTrackError",
1743
+ TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
1744
+ GetClosestTrackFailed = "GetClosestTrackFailed",
1745
+ PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
1746
+ FailedToConnectToNodes = "FailedToConnectToNodes",
1747
+ NoAudioDebug = "NoAudioDebug",
1748
+ PlayerAutoReconnect = "PlayerAutoReconnect",
1749
+ PlayerDestroyFail = "PlayerDestroyFail",
1750
+ PlayerChangeNodeFailNoEligibleNode = "PlayerChangeNodeFailNoEligibleNode",
1751
+ PlayerChangeNodeFail = "PlayerChangeNodeFail"
1752
+ }
1753
+ /**
1754
+ * Reasons why a player got destroyed
1755
+ */
1756
+ export declare enum DestroyReasons {
1757
+ QueueEmpty = "QueueEmpty",
1758
+ NodeDestroy = "NodeDestroy",
1759
+ NodeDeleted = "NodeDeleted",
1760
+ NodeNoVoice = "NodeNoVoice",
1761
+ NodeReconnectFail = "NodeReconnectFail",
1762
+ Disconnected = "Disconnected",
1763
+ PlayerReconnectFail = "PlayerReconnectFail",
1764
+ PlayerChangeNodeFail = "PlayerChangeNodeFail",
1765
+ PlayerChangeNodeFailNoEligibleNode = "PlayerChangeNodeFailNoEligibleNode",
1766
+ ChannelDeleted = "ChannelDeleted",
1767
+ DisconnectAllNodes = "DisconnectAllNodes",
1768
+ ReconnectAllNodes = "ReconnectAllNodes",
1769
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
1770
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
1771
+ }
1772
+ /**
1773
+ * Reasons why a player got disconnected
1774
+ */
1775
+ export declare enum DisconnectReasons {
1776
+ Disconnected = "Disconnected",
1777
+ DisconnectAllNodes = "DisconnectAllNodes"
1778
+ }
1779
+ /** The valid SponsorBlock categories */
1780
+ export declare const validSponsorBlocks: string[];
1781
+ /** The audio Outputs Data map declaration */
1782
+ export declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
1783
+ /** Equalizer Presets */
1784
+ export declare const EQList: {
1785
+ /** A Bassboost Equalizer, so high it distorts the audio */
1786
+ BassboostEarrape: EQBand[];
1787
+ /** A High and decent Bassboost Equalizer */
1788
+ BassboostHigh: EQBand[];
1789
+ /** A decent Bassboost Equalizer */
1790
+ BassboostMedium: EQBand[];
1791
+ /** A slight Bassboost Equalizer */
1792
+ BassboostLow: EQBand[];
1793
+ /** Makes the Music slightly "better" */
1794
+ BetterMusic: EQBand[];
1795
+ /** Makes the Music sound like rock music / sound rock music better */
1796
+ Rock: EQBand[];
1797
+ /** Makes the Music sound like Classic music / sound Classic music better */
1798
+ Classic: EQBand[];
1799
+ /** Makes the Music sound like Pop music / sound Pop music better */
1800
+ Pop: EQBand[];
1801
+ /** Makes the Music sound like Electronic music / sound Electronic music better */
1802
+ Electronic: EQBand[];
1803
+ /** Boosts all Bands slightly for louder and fuller sound */
1804
+ FullSound: EQBand[];
1805
+ /** Boosts basses + lower highs for a pro gaming sound */
1806
+ Gaming: EQBand[];
1807
+ };
1808
+ export declare const RecommendationsStrings: {
1809
+ highCPULoad: (cpuLoad: number) => string;
1810
+ highSystemLoad: (systemLoad: number) => string;
1811
+ highMemoryUsage: (memoryUsagePercent: number) => string;
1812
+ frameDeficit: (frameDeficit: number) => string;
1813
+ highLatency: (ping: number) => string;
1814
+ nodeRestart: string;
1815
+ highPlayercount: (players: number) => string;
1816
+ nodeOffline: string;
1817
+ checkConnectivity: string;
1818
+ };
1819
+ export declare const NodeLinkExclusiveEvents: NodeLinkEventTypes[];
1820
+ export declare class AmberLinkFilterManager {
1821
+ static EQList: {
1822
+ BassboostEarrape: EQBand[];
1823
+ BassboostHigh: EQBand[];
1824
+ BassboostMedium: EQBand[];
1825
+ BassboostLow: EQBand[];
1826
+ BetterMusic: EQBand[];
1827
+ Rock: EQBand[];
1828
+ Classic: EQBand[];
1829
+ Pop: EQBand[];
1830
+ Electronic: EQBand[];
1831
+ FullSound: EQBand[];
1832
+ Gaming: EQBand[];
1833
+ };
1834
+ /** The Equalizer bands currently applied to the AmberLink server */
1835
+ equalizerBands: EQBand[];
1836
+ /** Private Util for the instaFix Filters option */
1837
+ filterUpdatedState: boolean;
1838
+ /** All "Active" / "disabled" AmberLinkPlayer Filters */
1839
+ filters: PlayerFilters;
1840
+ /** The Filter Data sent to AmberLink server, only if the filter is enabled (ofc.) */
1841
+ data: FilterData;
1842
+ /** The AmberLinkPlayer assigned to this Filter Manager */
1843
+ player: AmberLinkPlayer;
1844
+ /** The Constructor for the AmberLinkFilterManager */
1845
+ constructor(player: AmberLinkPlayer);
1846
+ /**
1847
+ * Apply AmberLinkPlayer filters for AmberLink server filter sending data, if the filter is enabled / not
1848
+ *
1849
+ * @returns {Promise<void>}
1850
+ *
1851
+ * @example
1852
+ * ```ts
1853
+ * // Apply the filters after changing them manually:
1854
+ * player.filterManager.data.volume = 0.5;
1855
+ * // maybe you wanna manually set a distorition filter? then do it like this...
1856
+ * player.filterManager.data.distortion = { sinOffset: 0.5, sinScale: 2, cosOffset: 0.5, cosScale: 2, tanOffset: 0.5, tanScale: 2, offset: 0.5, scale: 2 };
1857
+ * await player.filterManager.applyPlayerFilters();
1858
+ * ```
1859
+ */
1860
+ applyPlayerFilters(): Promise<void>;
1861
+ private privateNot0;
1862
+ private getThirdPartyFilterData;
1863
+ /**
1864
+ * Checks if the filters are correctly stated (active / not-active) - mostly used internally.
1865
+ * @param oldFilterTimescale
1866
+ * @returns {boolean} True, if the check was successfull
1867
+ *
1868
+ * @example
1869
+ * ```ts
1870
+ * // Check the filter states
1871
+ * player.filterManager.checkFiltersState();
1872
+ * // Apply the filters after checking
1873
+ * await player.filterManager.applyPlayerFilters();
1874
+ * ```
1875
+ */
1876
+ checkFiltersState(oldFilterTimescale?: Partial<TimescaleFilter>): boolean;
1877
+ /**
1878
+ * Reset all Filters
1879
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1880
+ *
1881
+ * @example
1882
+ * ```ts
1883
+ * // Reset all filters
1884
+ * await player.filterManager.resetFilters();
1885
+ * ```
1886
+ */
1887
+ resetFilters(): Promise<AmberLinkFilterManager>;
1888
+ /**
1889
+ * Set the Filter Volume
1890
+ * @param volume the volume (0.0 - 5.0)
1891
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1892
+ *
1893
+ * @example
1894
+ * ```ts
1895
+ * // Set Volume to 50%
1896
+ * await player.filterManager.setVolume(0.5);
1897
+ * // note this is a filter, so it will "jump" to the volume, i think it's like a "volume boost effect" so i marketed it as a filter
1898
+ * ```
1899
+ */
1900
+ setVolume(volume: number): Promise<this>;
1901
+ /**
1902
+ * Set the AudioOutput Filter
1903
+ * @param {AudioOutputs} type the audio output type
1904
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1905
+ *
1906
+ * @example
1907
+ * ```ts
1908
+ * // Set Audio Output to Mono
1909
+ * await player.filterManager.setAudioOutput("mono");
1910
+ *
1911
+ * // Set Audio Output to Stereo
1912
+ * await player.filterManager.setAudioOutput("stereo");
1913
+ *
1914
+ * // Set Audio Output to Left
1915
+ * await player.filterManager.setAudioOutput("left");
1916
+ *
1917
+ * // Set Audio Output to Right
1918
+ * await player.filterManager.setAudioOutput("right");
1919
+ * ```
1920
+ */
1921
+ setAudioOutput(type: AudioOutputs): Promise<AmberLinkFilterManager>;
1922
+ /**
1923
+ * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
1924
+ * @param {number} speed set the speed of the filter
1925
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1926
+ *
1927
+ * @example
1928
+ * ```ts
1929
+ * // Set Speed to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
1930
+ * await player.filterManager.setSpeed(1.25);
1931
+ * ```
1932
+ */
1933
+ setSpeed(speed?: number): Promise<AmberLinkFilterManager>;
1934
+ /**
1935
+ * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
1936
+ * @param {number} pitch set the pitch of the filter
1937
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1938
+ *
1939
+ * @example
1940
+ * ```ts
1941
+ * // Set Pitch to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
1942
+ * await player.filterManager.setPitch(1.25);
1943
+ * ```
1944
+ */
1945
+ setPitch(pitch?: number): Promise<AmberLinkFilterManager>;
1946
+ /**
1947
+ * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
1948
+ * @param {number} rate set the rate of the filter
1949
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1950
+ *
1951
+ * @example
1952
+ * ```ts
1953
+ * // Set Rate to 1.25 (disableds nightcore and vaporwave effect which are pre-made timescale settings of rate,pitch and speed)
1954
+ * await player.filterManager.setRate(1.25);
1955
+ * ```
1956
+ */
1957
+ setRate(rate?: number): Promise<AmberLinkFilterManager>;
1958
+ /**
1959
+ * Enables / Disables the rotation effect, (Optional: provide your Own Data)
1960
+ * @param {number} rotationHz set the rotationHz of the filter
1961
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1962
+ *
1963
+ * @example
1964
+ * ```ts
1965
+ * // Toggle Rotation filter with custom settings
1966
+ * await player.filterManager.toggleRotation(0.4);
1967
+ * // or use the defaults
1968
+ * await player.filterManager.toggleRotation();
1969
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
1970
+ * ```
1971
+ */
1972
+ toggleRotation(rotationHz?: number): Promise<AmberLinkFilterManager>;
1973
+ /**
1974
+ * Enables / Disables the Vibrato effect, (Optional: provide your Own Data)
1975
+ * @param {number} frequency set the frequency of the filter
1976
+ * @param {number} depth set the depth of the filter
1977
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1978
+ *
1979
+ * @example
1980
+ * ```ts
1981
+ * // Toggle Vibrato filter with custom settings
1982
+ * await player.filterManager.toggleVibrato(8, 0.5);
1983
+ * // or use the defaults
1984
+ * await player.filterManager.toggleVibrato();
1985
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
1986
+ * ```
1987
+ */
1988
+ toggleVibrato(frequency?: number, depth?: number): Promise<AmberLinkFilterManager>;
1989
+ /**
1990
+ * Enables / Disables the Tremolo effect, (Optional: provide your Own Data)
1991
+ * @param {number} frequency set the frequency of the filter
1992
+ * @param {number} depth set the depth of the filter
1993
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
1994
+ *
1995
+ * @example
1996
+ * ```ts
1997
+ * // Toggle Tremolo filter with custom settings
1998
+ * await player.filterManager.toggleTremolo(5, 0.7);
1999
+ * // or use the defaults
2000
+ * await player.filterManager.toggleTremolo();
2001
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2002
+ * ```
2003
+ */
2004
+ toggleTremolo(frequency?: number, depth?: number): Promise<AmberLinkFilterManager>;
2005
+ /**
2006
+ * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
2007
+ * @param {number} smoothing set the smoothing of the filter
2008
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2009
+ *
2010
+ * @example
2011
+ * ```ts
2012
+ * // Toggle LowPass filter with custom settings
2013
+ * await player.filterManager.toggleLowPass(30);
2014
+ * // or use the defaults
2015
+ * await player.filterManager.toggleLowPass();
2016
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2017
+ * ```
2018
+ */
2019
+ toggleLowPass(smoothing?: number): Promise<AmberLinkFilterManager>;
2020
+ /**
2021
+ * AmberLink server LavaDspx Plugin Filters
2022
+ */
2023
+ thirdPartyDspxEffects: {
2024
+ /**
2025
+ * Enables / Disables the LowPass effect, (Optional: provide your Own Data)
2026
+ * @param {number} boostFactor set the boost factor of the filter
2027
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
2028
+ * @returns {Promise<boolean>} the state of the filter after execution.
2029
+ *
2030
+ * @example
2031
+ * ```ts
2032
+ * // Toggle LowPass filter with custom settings
2033
+ * await player.filterManager.thirdPartyDspxEffects.toggleLowPass(1.2, 300);
2034
+ * // or use the defaults
2035
+ * await player.filterManager.thirdPartyDspxEffects.toggleLowPass();
2036
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2037
+ * ```
2038
+ */
2039
+ toggleLowPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<AmberLinkFilterManager>;
2040
+ /**
2041
+ * Enables / Disables the HighPass effect, (Optional: provide your Own Data)
2042
+ * @param {number} boostFactor [] set the boost factor of the filter
2043
+ * @param {number} cutoffFrequency set the cutoff frequency of the filter
2044
+ * @returns {Promise<boolean>} the state of the filter after execution.
2045
+ *
2046
+ * @example
2047
+ * ```ts
2048
+ * // Toggle HighPass filter with custom settings
2049
+ * await player.filterManager.thirdPartyDspxEffects.toggleHighPass(1.2, 150); // custom values
2050
+ * // or use the defaults
2051
+ * await player.filterManager.thirdPartyDspxEffects.toggleHighPass();
2052
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2053
+ * ```
2054
+ */
2055
+ toggleHighPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<AmberLinkFilterManager>;
2056
+ /**
2057
+ * Enables / Disables the Normalization effect.
2058
+ * @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
2059
+ * @param {boolean} [adaptive=true] Whether to use adaptive normalization or not.
2060
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2061
+ *
2062
+ * @example
2063
+ * ```ts
2064
+ * // Toggle Normalization filter with custom settings
2065
+ * await player.filterManager.thirdPartyDspxEffects.toggleNormalization(0.9, false); // custom values
2066
+ * // or use the defaults
2067
+ * await player.filterManager.thirdPartyDspxEffects.toggleNormalization();
2068
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2069
+ * ```
2070
+ */
2071
+ toggleNormalization: (maxAmplitude?: number, adaptive?: boolean) => Promise<AmberLinkFilterManager>;
2072
+ /**
2073
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct AmberLink server Plugin installed. (Optional: provide your Own Data)
2074
+ * @param {number} [decay=0.5] The decay of the echo effect.
2075
+ * @param {number} [echoLength=0.5] The length of the echo effect.
2076
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2077
+ *
2078
+ * @example
2079
+ * ```ts
2080
+ * // Toggle Echo filter with custom settings
2081
+ * await player.filterManager.thirdPartyDspxEffects.toggleEcho(0.7, 0.6); // custom values
2082
+ * // or use the defaults
2083
+ * await player.filterManager.thirdPartyDspxEffects.toggleEcho();
2084
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2085
+ * ```
2086
+ */
2087
+ toggleEcho: (decay?: number, echoLength?: number) => Promise<AmberLinkFilterManager>;
2088
+ };
2089
+ /**
2090
+ * ThirdPartyFilter Plugin specific Filters
2091
+ */
2092
+ thirdPartyFilterEffects: {
2093
+ /**
2094
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct AmberLink server Plugin installed. (Optional: provide your Own Data)
2095
+ * @param {number} delay set the delay of the echo
2096
+ * @param {number} decay set the decay of the echo
2097
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2098
+ *
2099
+ * @example
2100
+ * ```ts
2101
+ * // Toggle Echo filter with custom settings
2102
+ * await player.filterManager.thirdPartyFilterEffects.toggleEcho(3, 0.7); // custom values
2103
+ * // or use the defaults
2104
+ * await player.filterManager.thirdPartyFilterEffects.toggleEcho();
2105
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2106
+ * ```
2107
+ */
2108
+ toggleEcho: (delay?: number, decay?: number) => Promise<AmberLinkFilterManager>;
2109
+ /**
2110
+ * Enables / Disables the Echo effect, IMPORTANT! Only works with the correct AmberLink server Plugin installed. (Optional: provide your Own Data)
2111
+ * @param {number} delays set the delays of the reverb
2112
+ * @param {number} gains set the gains of the reverb
2113
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2114
+ *
2115
+ * @example
2116
+ * ```ts
2117
+ * // Toggle Reverb filter with custom settings
2118
+ * await player.filterManager.thirdPartyFilterEffects.toggleReverb([0.04, 0.045, 0.05, 0.055], [0.85, 0.84, 0.83, 0.82]);
2119
+ * // or use the defaults
2120
+ * await player.filterManager.thirdPartyFilterEffects.toggleReverb();
2121
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2122
+ * ```
2123
+ */
2124
+ toggleReverb: (delays?: number[], gains?: number[]) => Promise<AmberLinkFilterManager>;
2125
+ };
2126
+ /**
2127
+ * Enables / Disables a Nightcore-like filter Effect. Disables/Overrides both: custom and Vaporwave Filter
2128
+ * @param {number} speed set the speed of the filter
2129
+ * @param {number} pitch set the pitch of the filter
2130
+ * @param {number} rate set the rate of the filter
2131
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2132
+ *
2133
+ * @example
2134
+ * ```ts
2135
+ * // Toggle Nightcore filter with custom settings
2136
+ * await player.filterManager.toggleNightcore(1.3, 1.3, 0.9);
2137
+ * // or use the defaults
2138
+ * await player.filterManager.toggleNightcore();
2139
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2140
+ * ```
2141
+ */
2142
+ toggleNightcore(speed?: number, pitch?: number, rate?: number): Promise<AmberLinkFilterManager>;
2143
+ /**
2144
+ * Enables / Disables a Vaporwave-like filter Effect. Disables/Overrides both: custom and nightcore Filter
2145
+ * @param {number} speed set the speed of the filterq
2146
+ * @param {number} pitch set the pitch of the filter
2147
+ * @param {number} rate set the rate of the filter
2148
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2149
+ *
2150
+ * @example
2151
+ * ```ts
2152
+ * // Toggle Vaporwave filter with custom settings
2153
+ * await player.filterManager.toggleVaporwave(0.9, 0.7, 1);
2154
+ * // or use the defaults
2155
+ * await player.filterManager.toggleVaporwave();
2156
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2157
+ * ```
2158
+ */
2159
+ toggleVaporwave(speed?: number, pitch?: number, rate?: number): Promise<AmberLinkFilterManager>;
2160
+ /**
2161
+ * Enable / Disables a Karaoke like Filter Effect
2162
+ * @param {number} level set the level of the filter
2163
+ * @param {number} monoLevel set the mono level of the filter
2164
+ * @param {number} filterBand set the filter band of the filter
2165
+ * @param {number} filterWidth set the filter width of the filter
2166
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2167
+ *
2168
+ * @example
2169
+ * ```ts
2170
+ * // Toggle Karaoke filter with custom settings
2171
+ * await player.filterManager.toggleKaraoke(1.5, 1.0, 220, 100);
2172
+ * // or use the defaults
2173
+ * await player.filterManager.toggleKaraoke();
2174
+ * // when it's enabled before calling the toggle function, it disables it, so you might need to do some if/else logic.
2175
+ * ```
2176
+ */
2177
+ toggleKaraoke(level?: number, monoLevel?: number, filterBand?: number, filterWidth?: number): Promise<AmberLinkFilterManager>;
2178
+ /**
2179
+ * Function to find out if currently there is a custom timescamle etc. filter applied
2180
+ * @returns {boolean} whether a custom filter is active
2181
+ *
2182
+ * @example
2183
+ * ```ts
2184
+ * // Check if a custom filter is active
2185
+ * const isCustom = player.filterManager.isCustomFilterActive();
2186
+ * console.log(`Is custom filter active? ${isCustom}`);
2187
+ * ```
2188
+ */
2189
+ isCustomFilterActive(): boolean;
2190
+ /**
2191
+ * Sets the players equalizer bands using one of the predefined presets.
2192
+ * @param {keyof typeof EQList} preset The preset to use.
2193
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2194
+ *
2195
+ * @example
2196
+ * ```ts
2197
+ * // Set EQ preset
2198
+ * await player.filterManager.setEQPreset('BassboostMedium');
2199
+ * ```
2200
+ */
2201
+ setEQPreset(preset: keyof typeof EQList): Promise<this>;
2202
+ /**
2203
+ * Sets the players equalizer band on-top of the existing ones.
2204
+ * @param {number} bands
2205
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2206
+ *
2207
+ * @example
2208
+ * ```ts
2209
+ * // Set EQ bands
2210
+ * await player.filterManager.setEQ([
2211
+ * { band: 0, gain: 0.3 },
2212
+ * { band: 1, gain: -0.2 },
2213
+ * { band: 2, gain: 0.1 }
2214
+ * ]);
2215
+ *
2216
+ * // or use one of the templates:
2217
+ * await player.filterManager.setEQ(player.filterManager.EQList.BassboostMedium); // you can also import EQList from somewhere package if wanted.
2218
+ * ```
2219
+ */
2220
+ setEQ(bands: EQBand | EQBand[]): Promise<this>;
2221
+ /**
2222
+ * Clears the equalizer bands.
2223
+ * @returns {Promise<AmberLinkFilterManager>} The Filter Manager, for chaining.
2224
+ *
2225
+ * @example
2226
+ * ```ts
2227
+ * // Clear all EQ bands
2228
+ * await player.filterManager.clearEQ();
2229
+ * ```
2230
+ */
2231
+ clearEQ(): Promise<this>;
2232
+ }
2233
+ export declare class QueueSaver {
2234
+ /**
2235
+ * The queue store manager
2236
+ */
2237
+ private _;
2238
+ /**
2239
+ * The options for the queue saver
2240
+ */
2241
+ options: {
2242
+ maxPreviousTracks: number;
2243
+ };
2244
+ constructor(options: ManagerQueueOptions);
2245
+ /**
2246
+ * Get the queue for a guild
2247
+ * @param guildId The guild ID
2248
+ * @returns The queue for the guild
2249
+ */
2250
+ get(guildId: string): Promise<Partial<StoredQueue>>;
2251
+ /**
2252
+ * Delete the queue for a guild
2253
+ * @param guildId The guild ID
2254
+ * @returns The queue for the guild
2255
+ */
2256
+ delete(guildId: string): Promise<void | boolean>;
2257
+ /**
2258
+ * Set the queue for a guild
2259
+ * @param guildId The guild ID
2260
+ * @param valueToStringify The queue to set
2261
+ * @returns The queue for the guild
2262
+ */
2263
+ set(guildId: string, valueToStringify: StoredQueue): Promise<void | boolean>;
2264
+ /**
2265
+ * Sync the queue for a guild
2266
+ * @param guildId The guild ID
2267
+ * @returns The queue for the guild
2268
+ */
2269
+ sync(guildId: string): Promise<Partial<StoredQueue>>;
2270
+ }
2271
+ export declare class DefaultQueueStore implements QueueStoreManager {
2272
+ private data;
2273
+ constructor();
2274
+ /**
2275
+ * Get the queue for a guild
2276
+ * @param guildId The guild ID
2277
+ * @returns The queue for the guild
2278
+ */
2279
+ get(guildId: string): StoredQueue | undefined;
2280
+ /**
2281
+ * Set the queue for a guild
2282
+ * @param guildId The guild ID
2283
+ * @param valueToStringify The queue to set
2284
+ * @returns The queue for the guild
2285
+ */
2286
+ set(guildId: string, valueToStringify: any): boolean;
2287
+ /**
2288
+ * Delete the queue for a guild
2289
+ * @param guildId The guild ID
2290
+ * @returns The queue for the guild
2291
+ */
2292
+ delete(guildId: string): boolean;
2293
+ /**
2294
+ * Stringify the queue for a guild
2295
+ * @param value The queue to stringify
2296
+ * @returns The stringified queue
2297
+ */
2298
+ stringify(value: StoredQueue | string): StoredQueue | string;
2299
+ /**
2300
+ * Parse the queue for a guild
2301
+ * @param value The queue to parse
2302
+ * @returns The parsed queue
2303
+ */
2304
+ parse(value: StoredQueue | string): Partial<StoredQueue>;
2305
+ }
2306
+ export declare class AmberLinkQueue {
2307
+ readonly tracks: (Track | UnresolvedTrack)[];
2308
+ readonly previous: Track[];
2309
+ current: Track | null;
2310
+ options: {
2311
+ maxPreviousTracks: number;
2312
+ };
2313
+ private readonly guildId;
2314
+ private readonly QueueSaver;
2315
+ private managerUtils;
2316
+ private queueChanges;
2317
+ /**
2318
+ * Create a new AmberLinkQueue
2319
+ * @param guildId The guild ID
2320
+ * @param data The data to initialize the queue with
2321
+ * @param QueueSaver The queue saver to use
2322
+ * @param queueOptions
2323
+ */
2324
+ constructor(guildId: string, data?: Partial<StoredQueue>, QueueSaver?: QueueSaver, queueOptions?: ManagerQueueOptions);
2325
+ /**
2326
+ * Utils for a AmberLinkQueue
2327
+ */
2328
+ utils: {
2329
+ /**
2330
+ * Save the current cached AmberLinkQueue on the database/server (overides the server)
2331
+ */
2332
+ save: () => Promise<void | boolean>;
2333
+ /**
2334
+ * Sync the current queue database/server with the cached one
2335
+ * @returns {void}
2336
+ */
2337
+ sync: (override?: boolean, dontSyncCurrent?: boolean) => Promise<void>;
2338
+ destroy: () => Promise<void | boolean>;
2339
+ /**
2340
+ * @returns {{current:Track|null, previous:Track[], tracks:Track[]}}The AmberLinkQueue, but in a raw State, which allows easier handling for the QueueStoreManager
2341
+ */
2342
+ toJSON: () => StoredQueue;
2343
+ /**
2344
+ * Get the Total Duration of the AmberLinkQueue-Songs summed up
2345
+ * @returns {number}
2346
+ */
2347
+ totalDuration: () => number;
2348
+ /**
2349
+ * Find tracks in the queue matching specific criteria.
2350
+ * **This method DOES NOT MUTATE the queue** - it returns a new array without modifying the original queue.
2351
+ * @param predicate Function to test each track, or an object with criteria to match
2352
+ * @returns Array of matching tracks with their indexes
2353
+ *
2354
+ * @example
2355
+ * ```ts
2356
+ * // Find by author
2357
+ * const artistTracks = player.queue.utils.filterTracks({ author: "Artist Name" });
2358
+ *
2359
+ * // Find by duration range (5-10 minutes)
2360
+ * const longTracks = player.queue.utils.filterTracks({ duration: { min: 300000, max: 600000 } });
2361
+ *
2362
+ * // Find by title (partial match)
2363
+ * const titleMatches = player.queue.utils.filterTracks({ title: "Never Gonna" });
2364
+ *
2365
+ * // Custom predicate
2366
+ * const customFilter = player.queue.utils.filterTracks(track => track.info.isStream);
2367
+ * ```
2368
+ */
2369
+ filterTracks: (predicate: ((track: Track | UnresolvedTrack, index: number) => boolean) | {
2370
+ title?: string;
2371
+ author?: string;
2372
+ duration?: number | {
2373
+ min?: number;
2374
+ max?: number;
2375
+ };
2376
+ uri?: string;
2377
+ identifier?: string;
2378
+ sourceName?: string;
2379
+ isStream?: boolean;
2380
+ isSeekable?: boolean;
2381
+ }) => Array<{
2382
+ track: Track | UnresolvedTrack;
2383
+ index: number;
2384
+ }>;
2385
+ /**
2386
+ * Find a single track in the queue matching specific criteria.
2387
+ * **This method DOES NOT MUTATE the queue** - it searches without modifying the original queue.
2388
+ * @param predicate Function to test each track, or an object with criteria to match
2389
+ * @returns First matching track with its index, or null if not found
2390
+ *
2391
+ * @example
2392
+ * ```ts
2393
+ * // Find first track by author
2394
+ * const track = player.queue.utils.findTrack({ author: "Artist Name" });
2395
+ * if (track) {
2396
+ * console.log(`Found at index ${track.index}: ${track.track.info.title}`);
2397
+ * }
2398
+ *
2399
+ * // Find with custom predicate
2400
+ * const liveStream = player.queue.utils.findTrack(track => track.info.isStream);
2401
+ * ```
2402
+ */
2403
+ findTrack: (predicate: ((track: Track | UnresolvedTrack, index: number) => boolean) | {
2404
+ title?: string;
2405
+ author?: string;
2406
+ duration?: number | {
2407
+ min?: number;
2408
+ max?: number;
2409
+ };
2410
+ uri?: string;
2411
+ identifier?: string;
2412
+ sourceName?: string;
2413
+ isStream?: boolean;
2414
+ isSeekable?: boolean;
2415
+ }) => {
2416
+ track: Track | UnresolvedTrack;
2417
+ index: number;
2418
+ } | null;
2419
+ };
2420
+ /**
2421
+ * Shuffles the current AmberLinkQueue, then saves it
2422
+ * @returns Amount of Tracks in the AmberLinkQueue
2423
+ */
2424
+ shuffle(): Promise<number>;
2425
+ /**
2426
+ * Add a Track to the AmberLinkQueue, and after saved in the "db" it returns the amount of the Tracks
2427
+ * @param {Track | Track[]} TrackOrTracks
2428
+ * @param {number} index At what position to add the Track
2429
+ * @returns {number} AmberLinkQueue-Size (for the next Tracks)
2430
+ */
2431
+ add(TrackOrTracks: Track | UnresolvedTrack | (Track | UnresolvedTrack)[], index?: number): Promise<number | (Track | UnresolvedTrack)[] | Track | UnresolvedTrack>;
2432
+ /**
2433
+ * Splice the tracks in the AmberLinkQueue
2434
+ * @param {number} index Where to remove the Track
2435
+ * @param {number} amount How many Tracks to remove?
2436
+ * @param {Track | Track[]} TrackOrTracks Want to Add more Tracks?
2437
+ * @returns {Track} Spliced (aka Removed) Track
2438
+ */
2439
+ splice(index: number, amount: number, TrackOrTracks?: Track | UnresolvedTrack | (Track | UnresolvedTrack)[]): Promise<Track | UnresolvedTrack | (Track | UnresolvedTrack)[] | null>;
2440
+ /**
2441
+ * Remove stuff from the queue.tracks array
2442
+ * - single Track | UnresolvedTrack
2443
+ * - multiple Track | UnresovedTrack
2444
+ * - at the index or multiple indexes
2445
+ * - Since v2.7 the removed tracks get unshifted into the previous queue state instead of pushed (indexed at the start instead of end - as it should)
2446
+ * @param removeQueryTrack
2447
+ * @returns null (if nothing was removed) / { removed } where removed is an array with all removed elements
2448
+ *
2449
+ * @example
2450
+ * ```js
2451
+ * // remove single track
2452
+ *
2453
+ * const track = player.queue.tracks[4];
2454
+ * await player.queue.remove(track);
2455
+ *
2456
+ * // if you already have the index you can straight up pass it too
2457
+ * await player.queue.remove(4);
2458
+ *
2459
+ *
2460
+ * // if you want to remove multiple tracks, e.g. from position 4 to position 10 you can do smt like this
2461
+ * await player.queue.remove(player.queue.tracks.slice(4, 10)) // get's the tracks from 4 - 10, which then get's found in the remove function to be removed
2462
+ *
2463
+ * // I still highly suggest to use .splice!
2464
+ *
2465
+ * await player.queue.splice(4, 10); // removes at index 4, 10 tracks
2466
+ *
2467
+ * await player.queue.splice(1, 1); // removes at index 1, 1 track
2468
+ *
2469
+ * await player.queue.splice(4, 0, ...tracks) // removes 0 tracks at position 4, and then inserts all tracks after position 4.
2470
+ * ```
2471
+ */
2472
+ remove<T extends Track | UnresolvedTrack | number | Track[] | UnresolvedTrack[] | number[] | (number | Track | UnresolvedTrack)[]>(removeQueryTrack: T): Promise<{
2473
+ removed: (Track | UnresolvedTrack)[];
2474
+ } | null>;
2475
+ /**
2476
+ * Shifts the previous array, to return the last previous track & thus remove it from the previous queue
2477
+ * @returns
2478
+ *
2479
+ * @example
2480
+ * ```js
2481
+ * // example on how to play the previous track again
2482
+ * const previous = await player.queue.shiftPrevious(); // get the previous track and remove it from the previous queue array!!
2483
+ * if(!previous) return console.error("No previous track found");
2484
+ * await player.play({ clientTrack: previous }); // play it again
2485
+ * ```
2486
+ */
2487
+ shiftPrevious(): Promise<Track>;
2488
+ /**
2489
+ * Find tracks in the queue matching specific criteria.
2490
+ * **This method DOES NOT MUTATE the queue** - it returns a new array without modifying the original queue.
2491
+ * @deprecated Use `player.queue.utils.filterTracks()` instead.
2492
+ * @param predicate Function to test each track, or an object with criteria to match
2493
+ * @returns Array of matching tracks with their indexes
2494
+ *
2495
+ * @example
2496
+ * ```ts
2497
+ * // Use the new method instead:
2498
+ * const artistTracks = player.queue.utils.filterTracks({ author: "Artist Name" });
2499
+ * ```
2500
+ */
2501
+ filter(predicate: ((track: Track | UnresolvedTrack, index: number) => boolean) | {
2502
+ title?: string;
2503
+ author?: string;
2504
+ duration?: number | {
2505
+ min?: number;
2506
+ max?: number;
2507
+ };
2508
+ uri?: string;
2509
+ identifier?: string;
2510
+ sourceName?: string;
2511
+ isStream?: boolean;
2512
+ isSeekable?: boolean;
2513
+ }): Array<{
2514
+ track: Track | UnresolvedTrack;
2515
+ index: number;
2516
+ }>;
2517
+ /**
2518
+ * Find a single track in the queue matching specific criteria.
2519
+ * **This method DOES NOT MUTATE the queue** - it searches without modifying the original queue.
2520
+ * @deprecated Use `player.queue.utils.findTrack()` instead.
2521
+ * @param predicate Function to test each track, or an object with criteria to match
2522
+ * @returns First matching track with its index, or null if not found
2523
+ *
2524
+ * @example
2525
+ * ```ts
2526
+ * // Use the new method instead:
2527
+ * const track = player.queue.utils.findTrack({ author: "Artist Name" });
2528
+ * ```
2529
+ */
2530
+ find(predicate: ((track: Track | UnresolvedTrack, index: number) => boolean) | {
2531
+ title?: string;
2532
+ author?: string;
2533
+ duration?: number | {
2534
+ min?: number;
2535
+ max?: number;
2536
+ };
2537
+ uri?: string;
2538
+ identifier?: string;
2539
+ sourceName?: string;
2540
+ isStream?: boolean;
2541
+ isSeekable?: boolean;
2542
+ }): {
2543
+ track: Track | UnresolvedTrack;
2544
+ index: number;
2545
+ } | null;
2546
+ /**
2547
+ * Sort the queue tracks by a specific property.
2548
+ * **⚠️ This method MUTATES the queue** - it modifies the original queue in place.
2549
+ * @param sortBy Property to sort by or custom comparator function
2550
+ * @param order Sort order: 'asc' or 'desc' (default: 'asc')
2551
+ * @returns The queue instance for chaining
2552
+ *
2553
+ * @example
2554
+ * ```ts
2555
+ * // Sort by duration (shortest first)
2556
+ * await player.queue.sortBy("duration", "asc");
2557
+ *
2558
+ * // Sort by title alphabetically (Z-A)
2559
+ * await player.queue.sortBy("title", "desc");
2560
+ *
2561
+ * // Custom sorting
2562
+ * await player.queue.sortBy((a, b) => {
2563
+ * return a.info.title.localeCompare(b.info.title);
2564
+ * });
2565
+ * ```
2566
+ */
2567
+ sortBy(sortBy: "duration" | "title" | "author" | ((a: Track | UnresolvedTrack, b: Track | UnresolvedTrack) => number), order?: "asc" | "desc"): Promise<this>;
2568
+ /**
2569
+ * Get a sorted copy of the queue tracks without modifying the original queue.
2570
+ * **This method DOES NOT MUTATE the queue** - it returns a new sorted array, similar to `Array.toSorted()`.
2571
+ * @param sortBy Property to sort by or custom comparator function
2572
+ * @param order Sort order: 'asc' or 'desc' (default: 'asc')
2573
+ * @returns A new sorted array of tracks (does not modify the queue)
2574
+ *
2575
+ * @example
2576
+ * ```ts
2577
+ * // Get sorted copy by duration (shortest first)
2578
+ * const sortedTracks = player.queue.toSortedBy("duration", "asc");
2579
+ * // Original queue remains unchanged
2580
+ *
2581
+ * // Get sorted copy by title alphabetically (Z-A)
2582
+ * const sortedByTitle = player.queue.toSortedBy("title", "desc");
2583
+ *
2584
+ * // Custom sorting
2585
+ * const customSorted = player.queue.toSortedBy((a, b) => {
2586
+ * return a.info.title.localeCompare(b.info.title);
2587
+ * });
2588
+ * ```
2589
+ */
2590
+ toSortedBy(sortBy: "duration" | "title" | "author" | ((a: Track | UnresolvedTrack, b: Track | UnresolvedTrack) => number), order?: "asc" | "desc"): (Track | UnresolvedTrack)[];
2591
+ /**
2592
+ * Get a range of tracks from the queue.
2593
+ * **This method DOES NOT MUTATE the queue** - it returns a new array slice, similar to `Array.slice()`.
2594
+ * @param start Start index (inclusive)
2595
+ * @param end End index (exclusive)
2596
+ * @returns Array of tracks in the specified range
2597
+ *
2598
+ * @example
2599
+ * ```ts
2600
+ * // Get tracks 5-15
2601
+ * const tracks = player.queue.getTracks(5, 15);
2602
+ *
2603
+ * // Get first 10 tracks
2604
+ * const firstTen = player.queue.getTracks(0, 10);
2605
+ * ```
2606
+ */
2607
+ getTracks(start: number, end?: number): (Track | UnresolvedTrack)[];
2608
+ }
2609
+ export type LyricsSyncMode = "word" | "line" | "plain" | "instrumental";
2610
+ export interface AmberLinkLyricsWord {
2611
+ text: string;
2612
+ startMs: number;
2613
+ endMs: number | null;
2614
+ }
2615
+ export interface AmberLinkLyricsLine {
2616
+ text: string;
2617
+ startMs: number | null;
2618
+ endMs: number | null;
2619
+ words: AmberLinkLyricsWord[];
2620
+ }
2621
+ export interface AmberLinkLyricsTrack {
2622
+ id: number | null;
2623
+ title: string | null;
2624
+ artist: string | null;
2625
+ album: string | null;
2626
+ durationMs: number;
2627
+ }
2628
+ export interface AmberLinkLyricsPayload {
2629
+ engine?: "AmberLink" | string;
2630
+ provider?: string;
2631
+ track: AmberLinkLyricsTrack;
2632
+ instrumental: boolean;
2633
+ syncMode: LyricsSyncMode;
2634
+ hasWordSync: boolean;
2635
+ plainLyrics: string | null;
2636
+ lines: AmberLinkLyricsLine[];
2637
+ }
2638
+ export interface ActiveLyricsLine {
2639
+ index: number;
2640
+ text: string;
2641
+ currentWordIndex: number | null;
2642
+ completedWordIndexes: number[];
2643
+ }
2644
+ export interface ActiveLyricsState {
2645
+ positionMs: number;
2646
+ syncMode: LyricsSyncMode;
2647
+ activeLines: ActiveLyricsLine[];
2648
+ }
2649
+ export interface LyricsLookupOptions {
2650
+ /** Use the provider's word timestamps when the record has them. Defaults to true. */
2651
+ wordSync?: boolean;
2652
+ /** Fall back to an installed third-party lyrics endpoint when the provider has no result. Defaults to true. */
2653
+ legacyFallback?: boolean;
2654
+ /** Override metadata when the track's source metadata is incomplete. */
2655
+ artist?: string;
2656
+ album?: string;
2657
+ /** Identify your bot/application to the lyrics provider (include a real project URL or contact). */
2658
+ userAgent?: string;
2659
+ }
2660
+ export type LyricsUpdateListener = (state: ActiveLyricsState) => void;
2661
+ export type StopLyricsFollow = () => void;
2662
+ interface ProviderRecord {
2663
+ id?: number;
2664
+ trackName?: string;
2665
+ artistName?: string;
2666
+ albumName?: string;
2667
+ duration?: number;
2668
+ instrumental?: boolean;
2669
+ plainLyrics?: string | null;
2670
+ syncedLyrics?: string | null;
2671
+ lyricsfile?: string | null;
2672
+ hasWordSync?: boolean;
2673
+ }
2674
+ export declare class AmberLinkLyricsTimeline implements AmberLinkLyricsPayload {
2675
+ engine?: string;
2676
+ provider?: string;
2677
+ track: AmberLinkLyricsPayload["track"];
2678
+ instrumental: boolean;
2679
+ syncMode: LyricsSyncMode;
2680
+ hasWordSync: boolean;
2681
+ plainLyrics: string | null;
2682
+ lines: AmberLinkLyricsLine[];
2683
+ constructor(payload: AmberLinkLyricsPayload);
2684
+ /** Returns the lines and word indexes active at an audio position, in milliseconds. */
2685
+ getActiveAt(positionMs: number): ActiveLyricsState;
2686
+ /** Gets the next exact lyric boundary after a position, including word starts/ends. */
2687
+ getNextBoundaryAfter(positionMs: number): number | null;
2688
+ private effectiveEnd;
2689
+ private effectiveWordEnd;
2690
+ }
2691
+ /** Resolve synchronized lyrics independently of the node implementation. */
2692
+ export declare class AmberLinkLyricsProvider {
2693
+ private readonly cache;
2694
+ private readonly inFlight;
2695
+ private nextRequestAt;
2696
+ private requestQueue;
2697
+ get(track: Track, options?: LyricsLookupOptions): Promise<AmberLinkLyricsTimeline | null>;
2698
+ private lookup;
2699
+ private requestJson;
2700
+ private store;
2701
+ }
2702
+ /** One shared provider keeps the cache and request throttle global across every node in this process. */
2703
+ export declare const sharedAmberLinkLyricsProvider: AmberLinkLyricsProvider;
2704
+ export declare function timelineFromLegacyLyrics(value: unknown): AmberLinkLyricsTimeline | null;
2705
+ export declare function followLyricsTimeline(player: AmberLinkPlayer, timeline: AmberLinkLyricsTimeline, listener: LyricsUpdateListener): StopLyricsFollow;
2706
+ export declare function normalizeProviderRecord(record: ProviderRecord, wordSync?: boolean): AmberLinkLyricsTimeline;
2707
+ export declare class AmberLinkPlayer {
2708
+ /** Filter Manager per player */
2709
+ filterManager: AmberLinkFilterManager;
2710
+ /** circular reference to the AmberLink manager from the AmberLinkPlayer for easier use */
2711
+ AmberLinkManager: AmberLinkManager;
2712
+ /** AmberLinkPlayer options currently used, mutation doesn't affect player's state */
2713
+ options: PlayerOptions;
2714
+ /** The server node assigned the player, don't change it manually */
2715
+ node: AmberLinkNode | NodeLinkNode;
2716
+ /** The queue from the player */
2717
+ queue: AmberLinkQueue;
2718
+ /** The Guild Id of the AmberLinkPlayer */
2719
+ guildId: string;
2720
+ /** The Voice Channel Id of the AmberLinkPlayer */
2721
+ voiceChannelId: string | null;
2722
+ /** The Text Channel Id of the AmberLinkPlayer */
2723
+ textChannelId: string | null;
2724
+ /** States if the Bot is supposed to be outputting audio */
2725
+ playing: boolean;
2726
+ /** States if the Bot is paused or not */
2727
+ paused: boolean;
2728
+ /** Repeat Mode of the AmberLinkPlayer */
2729
+ repeatMode: RepeatMode;
2730
+ /** AmberLinkPlayer's ping */
2731
+ ping: {
2732
+ node: number;
2733
+ ws: number;
2734
+ };
2735
+ /** The Display Volume */
2736
+ volume: number;
2737
+ /** The Volume AmberLink server actually is outputting */
2738
+ nodeVolume: number;
2739
+ /** The current Positin of the player (Calculated) */
2740
+ get position(): number;
2741
+ /** The timestamp when the last position change update happened */
2742
+ lastPositionChange: number | null;
2743
+ /** The current Positin of the player (from AmberLink server) */
2744
+ lastPosition: number;
2745
+ lastSavedPosition: number;
2746
+ /** When the player was created [Timestamp in Ms] (from AmberLink server) */
2747
+ createdTimeStamp: number;
2748
+ /** The AmberLinkPlayer Connection's State (from AmberLink server) */
2749
+ connected: boolean | undefined;
2750
+ /** Voice Server Data (from AmberLink server) */
2751
+ voice: NodePlayerVoiceOptions;
2752
+ voiceState: {
2753
+ selfDeaf: boolean;
2754
+ selfMute: boolean;
2755
+ serverDeaf: boolean;
2756
+ serverMute: boolean;
2757
+ suppress: boolean;
2758
+ };
2759
+ /** Custom data for the player */
2760
+ private readonly data;
2761
+ /**
2762
+ * Emits a debug event to the AmberLinkManager
2763
+ * @param name name of the event
2764
+ * @param eventData event data
2765
+ */
2766
+ private _emitDebugEvent;
2767
+ /**
2768
+ * Create a new AmberLinkPlayer
2769
+ * @param options
2770
+ * @param AmberLinkManager
2771
+ */
2772
+ constructor(options: PlayerOptions, AmberLinkManager: AmberLinkManager, dontEmitPlayerCreateEvent?: boolean);
2773
+ /**
2774
+ * Set custom data. (Deprecated - Use AmberLinkPlayer#setData instead.)
2775
+ * @param key
2776
+ * @param value
2777
+ * @deprecated Use AmberLinkPlayer#setData instead.
2778
+ */
2779
+ set(key: string, value: unknown): this;
2780
+ /**
2781
+ * Get custom data. (Deprecated - Use AmberLinkPlayer#getData instead.)
2782
+ * @param key
2783
+ * @deprecated Use AmberLinkPlayer#getData instead.
2784
+ */
2785
+ get<T>(key: string): T;
2786
+ /**
2787
+ * Set custom data.
2788
+ * @param key
2789
+ * @param value
2790
+ */
2791
+ setData(key: string, value: unknown): this;
2792
+ /**
2793
+ * Get custom data.
2794
+ * @param key
2795
+ */
2796
+ getData<T>(key: string): T;
2797
+ /**
2798
+ * Delete specific custom data.
2799
+ * @param key
2800
+ */
2801
+ deleteData(key: string): this;
2802
+ /**
2803
+ * CLears all the custom data.
2804
+ */
2805
+ clearData(): this;
2806
+ /**
2807
+ * Get all custom Data
2808
+ */
2809
+ getAllData(): Record<string, unknown>;
2810
+ /**
2811
+ * Play the next track from the queue / a specific track, with playoptions for AmberLink server
2812
+ * @param options
2813
+ */
2814
+ play(options?: Partial<PlayOptions>): any;
2815
+ /**
2816
+ * The old JSON of the player, used for the "playerClientUpdate" event, which is emitted on every update of the player via a function call, so that you can compare the old data with the new data and do something with it if you want to.
2817
+ */
2818
+ oldJSON: PlayerJson;
2819
+ /**
2820
+ * Emits the "playerClientUpdate" event, which is emitted on every update of the player via a function call, so that you can compare the old data with the new data and do something with it if you want to.
2821
+ */
2822
+ triggerPlayerClientUpdate(): void;
2823
+ /**
2824
+ * Set the Volume for the AmberLinkPlayer
2825
+ * @param volume The Volume in percent
2826
+ * @param ignoreVolumeDecrementer If it should ignore the volumedecrementer option
2827
+ */
2828
+ setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
2829
+ /**
2830
+ * Search for a track
2831
+ * @param query The query to search for
2832
+ * @param requestUser The user that requested the track
2833
+ * @param throwOnEmpty If an error should be thrown if no track is found
2834
+ * @returns The search result
2835
+ */
2836
+ extendedSearch(query: ExtendedSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<ExtendedSearchResponse | SearchResult>;
2837
+ /**
2838
+ * Set the SponsorBlock
2839
+ * @param segments The segments to set
2840
+ */
2841
+ setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
2842
+ /**
2843
+ * Get the SponsorBlock
2844
+ */
2845
+ getSponsorBlock(): Promise<SponsorBlockSegment[]>;
2846
+ /**
2847
+ * Delete the SponsorBlock
2848
+ */
2849
+ deleteSponsorBlock(): Promise<void>;
2850
+ /**
2851
+ *
2852
+ * @param query Query for your data
2853
+ * @param requestUser
2854
+ */
2855
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult | UnresolvedSearchResult>;
2856
+ /**
2857
+ * Pause the player
2858
+ */
2859
+ pause(): Promise<this>;
2860
+ /**
2861
+ * Resume the AmberLinkPlayer
2862
+ */
2863
+ resume(): Promise<this>;
2864
+ /**
2865
+ * Seek to a specific Position
2866
+ * @param position
2867
+ */
2868
+ seek(position: number): Promise<this>;
2869
+ /**
2870
+ * Set the Repeatmode of the AmberLinkPlayer
2871
+ * @param repeatMode
2872
+ */
2873
+ setRepeatMode(repeatMode: RepeatMode): Promise<this>;
2874
+ /**
2875
+ * Skip the current song, or a specific amount of songs
2876
+ * @param amount provide the index of the next track to skip to
2877
+ */
2878
+ skip(skipTo?: number, throwError?: boolean): Promise<this>;
2879
+ /**
2880
+ * Clears the queue and stops playing. Does not destroy the AmberLinkPlayer and not leave the channel
2881
+ * @returns
2882
+ */
2883
+ stopPlaying(clearQueue?: boolean, executeAutoplay?: boolean): Promise<this>;
2884
+ /**
2885
+ * Connects the AmberLinkPlayer to the Voice Channel
2886
+ * @returns
2887
+ */
2888
+ connect(): Promise<this>;
2889
+ changeVoiceState(data: {
2890
+ voiceChannelId?: string;
2891
+ selfDeaf?: boolean;
2892
+ selfMute?: boolean;
2893
+ }): Promise<this>;
2894
+ /**
2895
+ * Disconnects the AmberLinkPlayer from the Voice Channel, but keeps the player in the cache
2896
+ * @param force If false it throws an error, if player thinks it's already disconnected
2897
+ * @returns
2898
+ */
2899
+ disconnect(force?: boolean): Promise<this>;
2900
+ /**
2901
+ * Destroy the player and disconnect from the voice channel
2902
+ */
2903
+ destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
2904
+ /** Fetch the normalized lyric timeline for a track, including per-word timestamps when available. */
2905
+ getLyricsTimeline(track?: Track, options?: LyricsLookupOptions): Promise<AmberLinkLyricsTimeline | null>;
2906
+ /** Fetch the normalized lyric timeline for the currently playing track. */
2907
+ getCurrentLyricsTimeline(options?: LyricsLookupOptions): Promise<AmberLinkLyricsTimeline | null>;
2908
+ /**
2909
+ * Follow the timeline against the player's live position. The callback is driven by the next word/line boundary
2910
+ * and re-synchronizes after seeks, pauses, resumes, track changes, and server position updates.
2911
+ * Returns a cleanup function; call it when the lyrics UI is closed or the player is destroyed.
2912
+ */
2913
+ followLyrics(timeline: AmberLinkLyricsTimeline, listener: LyricsUpdateListener): StopLyricsFollow;
2914
+ /**
2915
+ * Get the current lyrics of the track currently playing on the guild
2916
+ * @param guildId The guild id to get the current lyrics for
2917
+ * @param skipTrackSource If true, it will not try to get the lyrics from the track source
2918
+ * @returns The current lyrics
2919
+ * @example
2920
+ * ```ts
2921
+ * const lyrics = await player.getCurrentLyrics();
2922
+ * ```
2923
+ */
2924
+ getCurrentLyrics(skipTrackSource?: boolean): Promise<LyricsResult>;
2925
+ /**
2926
+ * Get the lyrics of a specific track
2927
+ * @param track The track to get the lyrics for
2928
+ * @param skipTrackSource If true, it will not try to get the lyrics from the track source
2929
+ * @returns The lyrics of the track
2930
+ * @example
2931
+ * ```ts
2932
+ * const lyrics = await player.getLyrics(player.queue.tracks[0], true);
2933
+ * ```
2934
+ */
2935
+ getLyrics(track: Track, skipTrackSource?: boolean): Promise<LyricsResult>;
2936
+ /**
2937
+ * Subscribe to the lyrics event on a specific guild to active live lyrics events}
2938
+ * @param skipTrackSource If true, it will not try to get the lyrics from the track source
2939
+ * @returns The unsubscribe function
2940
+ * @example
2941
+ * ```ts
2942
+ * const lyrics = await player.subscribeLyrics();
2943
+ * ```
2944
+ */
2945
+ subscribeLyrics(skipTrackSource?: boolean): Promise<unknown>;
2946
+ /**
2947
+ * Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
2948
+ * @returns The unsubscribe function
2949
+ * @example
2950
+ * ```ts
2951
+ * const lyrics = await player.unsubscribeLyrics();
2952
+ * ```
2953
+ */
2954
+ unsubscribeLyrics(): Promise<void>;
2955
+ /**
2956
+ * Move the player on a different Audio-Node
2957
+ * @param newNode New Node / New Node Id
2958
+ * @param checkSources If it should check if the sources are supported by the new node @default true
2959
+ * @return The new Node Id
2960
+ * @example
2961
+ * ```ts
2962
+ * const changeNode = await player.changeNode(newNode, true);
2963
+ * ```
2964
+ */
2965
+ changeNode(newNode: AmberLinkNode | string, checkSources?: boolean): Promise<string>;
2966
+ /**
2967
+ * (Wrapper-FN for changeNode) Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
2968
+ * @param node the id of the node to move to
2969
+ * @returns the player
2970
+ * @throws RangeError if there is no available nodes.
2971
+ * @throws Error if the node to move to is the same as the current node.
2972
+ * @example
2973
+ * ```ts
2974
+ * const newNodeMovedTo = await player.moveNode(); // no need to specify the new node, it will find a least used node automatically, but you can ofc. use a custom node id.
2975
+ * ```
2976
+ */
2977
+ moveNode(node?: string): Promise<string | this>;
2978
+ /** Converts the AmberLinkPlayer including AmberLinkQueue to a Json state */
2979
+ toJSON(): PlayerJson;
2980
+ }
2981
+ /** Default Sources Record for NodeLink, to allow source parsing with multiple inputs. */
2982
+ export declare const NodeLinkDefaultSources: Record<SearchPlatform, NodeLinkSearchPlatform | ClientCustomSearchPlatformUtils>;
2983
+ export declare class NodeLinkNode extends AmberLinkNode {
2984
+ nodeType: NodeType;
2985
+ constructor(options: AmberLinkNodeOptions, manager: AmberLinkNodeManager);
2986
+ /**
2987
+ * Uses the gapless feature to set the next track to be played.
2988
+ * @param player current player
2989
+ * @param track if no track provided, it will use the next track from queue
2990
+ */
2991
+ setNextTrackGapLess(player: AmberLinkPlayer, track?: Track | UnresolvedTrack): Promise<boolean>;
2992
+ /**
2993
+ * Removes the nextTrackGapLess configuration
2994
+ * @param player current player
2995
+ * @param track if no track provided, it will use the next track from queue
2996
+ */
2997
+ removeNextTrackGapLess(player: AmberLinkPlayer): Promise<boolean>;
2998
+ /**
2999
+ * Retrieves the meaning of a track.
3000
+ * @param track
3001
+ * @returns {MeaningResponse}
3002
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
3003
+ */
3004
+ getMeaning(track?: Track | UnresolvedTrack): Promise<MeaningResponse>;
3005
+ /**
3006
+ * Adds a new audio track to be mixed over the current playback.
3007
+ * @param player The player to add the mixer layer to.
3008
+ * @param trackToAdd The track to add to the mixer layer.
3009
+ * @param volume The volume of the track to add to the mixer layer. (0 - 100)
3010
+ * @link {https://nodelink.js.org/docs/api/rest#add-mix-layer} documentiation
3011
+ */
3012
+ addMixerLayer(player: AmberLinkPlayer, trackToAdd: Track, volume: number): Promise<AddMixerLayerResponse>;
3013
+ /**
3014
+ * Retrieves a list of currently active mix layers.
3015
+ * @param player The player to list the mixer layers for.
3016
+ * @link {https://nodelink.js.org/docs/api/rest#get-active-mixes} documentiation
3017
+ */
3018
+ listMixerLayers(player: AmberLinkPlayer): Promise<ListMixerLayersResponse>;
3019
+ /**
3020
+ * Updates the volume of a specific mix layer.
3021
+ * @param player The player to update the mixer layer volume for.
3022
+ * @param mixId The ID of the mix layer to update.
3023
+ * @param volume The volume of the mix layer to update. (0 - 100)
3024
+ * @link {https://nodelink.js.org/docs/api/rest#update-mix-volume} documentiation
3025
+ */
3026
+ updateMixerLayerVolume(player: AmberLinkPlayer, mixId: string, volume: number): Promise<boolean>;
3027
+ /**
3028
+ * Removes a specific mix layer.
3029
+ * @param player The player to remove the mix layer from.
3030
+ * @param mixId The ID of the mix layer to remove.
3031
+ * @link {https://nodelink.js.org/docs/api/rest#remove-mix-layer} documentiation
3032
+ */
3033
+ removeMixerLayer(player: AmberLinkPlayer, mixId: string): Promise<boolean>;
3034
+ /**
3035
+ * @description
3036
+ * NodeLink has a lot of filters SPECIFICALLY for NodeLink, check the documentation for more information.
3037
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#additional-filters} documentiation
3038
+ */
3039
+ specificFilters: {
3040
+ /**
3041
+ * Creates delay-based echo with feedback control
3042
+ * @param player The player to apply the filter to
3043
+ * @param options The echo filter options
3044
+ */
3045
+ echo: (player: AmberLinkPlayer, options: NodeLink_EchoFilter, disableFilter?: boolean) => Promise<boolean>;
3046
+ /**
3047
+ * Simulates multiple voices playing together with modulated delays
3048
+ * @param player The player to apply the filter to
3049
+ * @param options The chorus filter options
3050
+ */
3051
+ chorus: (player: AmberLinkPlayer, options: NodeLink_ChorusFilter, disableFilter?: boolean) => Promise<boolean>;
3052
+ /**
3053
+ * Dynamic range compression for balanced audio levels
3054
+ * @param player The player to apply the filter to
3055
+ * @param options The compressor filter options
3056
+ */
3057
+ compressor: (player: AmberLinkPlayer, options: NodeLink_CompressorFilter, disableFilter?: boolean) => Promise<boolean>;
3058
+ /**
3059
+ * Filters out low frequencies, letting high frequencies pass through
3060
+ * @param player The player to apply the filter to
3061
+ * @param options The highpass filter options
3062
+ */
3063
+ highPass: (player: AmberLinkPlayer, options: NodeLink_HighPassFilter, disableFilter?: boolean) => Promise<boolean>;
3064
+ /**
3065
+ * Sweeps all-pass filters across the frequency spectrum for a swooshing effect
3066
+ * @param player The player to apply the filter to
3067
+ * @param options The phaser filter options
3068
+ */
3069
+ phaser: (player: AmberLinkPlayer, options: NodeLink_PhaserFilter, disableFilter?: boolean) => Promise<boolean>;
3070
+ /**
3071
+ * Creates spatial audio using cross-channel delays and modulation
3072
+ * @param player The player to apply the filter to
3073
+ * @param options The spatial filter options
3074
+ */
3075
+ spatial: (player: AmberLinkPlayer, options: NodeLink_SpatialFilter, disableFilter?: boolean) => Promise<boolean>;
3076
+ /**
3077
+ * Resets all NodeLink filters
3078
+ * @param player The player to reset the filters for
3079
+ */
3080
+ resetNodeLinkFilters: (player: AmberLinkPlayer) => Promise<boolean>;
3081
+ };
3082
+ /**
3083
+ * Retrieve Lyrics of Youtube Videos.
3084
+ * @param player The AmberLinkPlayer you use with that node.
3085
+ * @param track if not provided, it will use the current track
3086
+ * @param language if not provided, it will use the default language (en)
3087
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#lyrics--chapters}
3088
+ * @returns NodeLinkLyrics either synced/unsynced or NodeLinkNoLyrics
3089
+ */
3090
+ nodeLinkLyrics(player: AmberLinkPlayer, track?: Track | UnresolvedTrack, language?: string): Promise<NodeLinkLyrics | NodeLinkNoLyrics>;
3091
+ /**
3092
+ * Retrieve Chapters of Youtube Videos.
3093
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#loadchapters}
3094
+ * @param player The AmberLinkPlayer you use with that node.
3095
+ * @param track if not provided, it will use the current track
3096
+ * @returns Array of NodeLinkChapter objects (if empty than there are no chapters available)
3097
+ */
3098
+ getChapters(player: AmberLinkPlayer, track?: Track | UnresolvedTrack): Promise<NodeLinkChapter[]>;
3099
+ /**
3100
+ * @link {https://nodelink.js.org/docs/api/rest#node-information}
3101
+ * @returns
3102
+ */
3103
+ getConnectionMetrics(): Promise<ConnectionMetricsResponse>;
3104
+ /**
3105
+ * Stream audio directly from NodeLink without Discord voice connection. | Note this must be enabled by NodeLink...
3106
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#direct-streaming}
3107
+ */
3108
+ getDirectStream(track: Track | UnresolvedTrack): Promise<DirectStreamResponse>;
3109
+ /**
3110
+ * Stream raw PCM audio for custom processing or recording.
3111
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#loadstream}
3112
+ * @param track The track to stream
3113
+ * @param volume The volume to stream at
3114
+ * @param position The position to stream from
3115
+ * @param filters The filters to apply to the stream
3116
+ * @returns Returns a raw PCM stream with Content-Type: audio/l16;rate=48000;channels=2.
3117
+ */
3118
+ loadDirectStream(track: Track | UnresolvedTrack, volume: number, position: number, filters: object | string): Promise<ReadableStream>;
3119
+ /**
3120
+ * NodeLink supports selecting specific audio tracks for videos that contain multiple audio streams (e.g., Netflixstyle dubs, multi-language YouTube videos).
3121
+ * This function changes the current language of the audio, in place at the same position of the current track.
3122
+ * You can always do it manually by providing extra field in the track object "audioTrackId"
3123
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#additional-filters}
3124
+ * @param player The player to apply the filter to
3125
+ * @param language_audioTrackId The language of the audio track to select, see it in the pluginInfo.audioTracks
3126
+ */
3127
+ changeAudioTrackLanguage(player: AmberLinkPlayer, language_audioTrackId: string): Promise<any>;
3128
+ /**
3129
+ * Updates the YouTube configuration (RefreshToken or VisitorData) in real-time.
3130
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#update-config}
3131
+ */
3132
+ updateYoutubeConfig(refreshToken?: string, visitorData?: string): Promise<any>;
3133
+ getYoutubeConfig(validate?: boolean): Promise<{
3134
+ refreshToken: string;
3135
+ visitorData: string | null;
3136
+ isConfigured: boolean;
3137
+ isValid: boolean | null;
3138
+ }>;
3139
+ /**
3140
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#oauth}
3141
+ */
3142
+ getYoutubeOAUTH(refreshToken: string): Promise<YoutubeOAuthResponse>;
3143
+ /**
3144
+ * @link {https://nodelink.js.org/docs/api/nodelink-features#oauth}
3145
+ */
3146
+ updateYoutubeOAUTH(refreshToken: string): Promise<YoutubeOAuthResponse>;
3147
+ }
3148
+ /**
3149
+ * Shared AmberLink server transport used by AmberLink and third-party server nodes.
3150
+ */
3151
+ export declare class AmberLinkNode {
3152
+ private heartBeatPingTimestamp;
3153
+ private heartBeatPongTimestamp;
3154
+ private heartBeatInterval?;
3155
+ private pingTimeout?;
3156
+ nodeType: NodeType;
3157
+ isAlive: boolean;
3158
+ static _NodeLinkClass: unknown;
3159
+ /** The provided Options of the Node */
3160
+ options: AmberLinkNodeOptions;
3161
+ /** The amount of rest calls the node has made. */
3162
+ calls: number;
3163
+ /** Stats from AmberLink server, will be updated via an interval by AmberLink server. */
3164
+ stats: NodeStats;
3165
+ /** The current sessionId, only present when connected */
3166
+ sessionId?: string | null;
3167
+ /** Wether the node resuming is enabled or not */
3168
+ resuming: {
3169
+ enabled: boolean;
3170
+ timeout: number | null;
3171
+ };
3172
+ /** Actual AmberLink server Information of the Node */
3173
+ info: AudioNodeInfo | null;
3174
+ /** AmberLink-native capabilities, available only for first-party nodes. */
3175
+ amberLinkInfo: AmberLinkInfo | null;
3176
+ private readonly nativeLyricsProvider;
3177
+ /** current state of the Reconnections */
3178
+ reconnectionState: ReconnectionState;
3179
+ /** The Node Manager of this Node */
3180
+ private AmberLinkNodeManager;
3181
+ /** The Reconnection Timeout */
3182
+ private reconnectTimeout?;
3183
+ /** The Reconnection Attempt counter (array of datetimes when it tried it.) */
3184
+ private reconnectAttempts;
3185
+ /** The Socket of the AmberLink server */
3186
+ private socket;
3187
+ /** Internal REST namespace used by the current AmberLink server implementation. */
3188
+ private readonly restNamespace;
3189
+ /**
3190
+ * Returns the AmberLinkManager of the Node
3191
+ */
3192
+ private get _manager();
3193
+ /**
3194
+ * Returns the Heartbeat Ping of the Node
3195
+ */
3196
+ get heartBeatPing(): number;
3197
+ /**
3198
+ * Returns wether the plugin validations are enabled or not
3199
+ */
3200
+ get _checkForPlugins(): boolean;
3201
+ /**
3202
+ * Returns wether the source validations are enabled or not
3203
+ */
3204
+ get _checkForSources(): boolean;
3205
+ /**
3206
+ * Emits a debug event to the AmberLinkManager
3207
+ * @param name name of the event
3208
+ * @param eventData event data
3209
+ */
3210
+ private _emitDebugEvent;
3211
+ /**
3212
+ * Returns if connected to the Node.
3213
+ *
3214
+ * @example
3215
+ * ```ts
3216
+ * const isConnected = player.node.connected;
3217
+ * console.log("node is connected: ", isConnected ? "yes" : "no")
3218
+ * ```
3219
+ */
3220
+ get connected(): boolean;
3221
+ /**
3222
+ * Returns the current ConnectionStatus
3223
+ *
3224
+ * @example
3225
+ * ```ts
3226
+ * try {
3227
+ * const statusOfConnection = player.node.connectionStatus;
3228
+ * console.log("node's connection status is:", statusOfConnection)
3229
+ * } catch (error) {
3230
+ * console.error("no socket available?", error)
3231
+ * }
3232
+ * ```
3233
+ */
3234
+ get connectionStatus(): string;
3235
+ /**
3236
+ * Create a new Node
3237
+ * @param options server node Options
3238
+ * @param manager Node Manager
3239
+ *
3240
+ *
3241
+ * @example
3242
+ * ```ts
3243
+ * // don't create a node manually, instead use:
3244
+ *
3245
+ * client.amberlink.nodeManager.createNode(options)
3246
+ * ```
3247
+ */
3248
+ constructor(options: AmberLinkNodeOptions, manager: AmberLinkNodeManager);
3249
+ /**
3250
+ * Raw Request util function
3251
+ * @param endpoint endpoint string
3252
+ * @param modify modify the request
3253
+ * @param extraQueryUrlParams UrlSearchParams to use in a encodedURI, useful for example for flowertts
3254
+ * @returns object containing request and option information
3255
+ *
3256
+ * @example
3257
+ * ```ts
3258
+ * player.node.rawRequest(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET");
3259
+ * ```
3260
+ */
3261
+ rawRequest(endpoint: string, modify?: ModifyRequest): Promise<{
3262
+ response: Response;
3263
+ options: RequestInit & {
3264
+ path: string;
3265
+ extraQueryUrlParams?: URLSearchParams;
3266
+ };
3267
+ }>;
3268
+ /**
3269
+ * Makes an API call to the Node. Should only be used for manual parsing like for not supported plugins
3270
+ * @param endpoint The endpoint that we will make the call to
3271
+ * @param modify Used to modify the request before being sent
3272
+ * @returns The returned data
3273
+ *
3274
+ * @example
3275
+ * ```ts
3276
+ * player.node.request(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET", false);
3277
+ * ```
3278
+ */
3279
+ request(endpoint: string, modify: ModifyRequest | undefined, parseAsText: true): Promise<string>;
3280
+ request(endpoint: string, modify?: ModifyRequest, parseAsText?: false): Promise<any>;
3281
+ /** Call an AmberLink-owned API route outside the transport compatibility namespace. */
3282
+ requestAmberLink<T = unknown>(endpoint: string, query?: URLSearchParams): Promise<T>;
3283
+ /**
3284
+ * Search something raw on the node, please note only add tracks to players of that node
3285
+ * @param query SearchQuery Object
3286
+ * @param requestUser Request User for creating the player(s)
3287
+ * @param throwOnEmpty Wether to throw on an empty result or not
3288
+ * @returns Searchresult
3289
+ *
3290
+ * @example
3291
+ * ```ts
3292
+ * // use player.search() instead
3293
+ * player.node.search({ query: "Never gonna give you up by Rick Astley", source: "soundcloud" }, interaction.user);
3294
+ * player.node.search({ query: "https://deezer.com/track/123456789" }, interaction.user);
3295
+ * ```
3296
+ */
3297
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult>;
3298
+ /**
3299
+ * Search something using the lavaSearchPlugin (filtered searches by types)
3300
+ * @param query ExtendedSearchQuery Object
3301
+ * @param requestUser Request User for creating the player(s)
3302
+ * @param throwOnEmpty Wether to throw on an empty result or not
3303
+ * @returns ExtendedSearchResult (SearchResult if link is provided)
3304
+ *
3305
+ * @example
3306
+ * ```ts
3307
+ * // use player.search() instead
3308
+ * player.node.extendedSearch({ types: ["playlist", "album"], query: "Rick Astley", source: "spotify" }, interaction.user);
3309
+ * ```
3310
+ */
3311
+ extendedSearch(query: ExtendedSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<ExtendedSearchResponse | SearchResult>;
3312
+ /**
3313
+ * Update the AmberLinkPlayer State on the AmberLink server
3314
+ * @param data data to send to AmberLink server and sync locally
3315
+ * @returns result from AmberLink server
3316
+ *
3317
+ * @example
3318
+ * ```ts
3319
+ * // use player.search() instead
3320
+ * player.node.updatePlayer({ guildId: player.guildId, playerOptions: { paused: true } }); // example to pause it
3321
+ * ```
3322
+ */
3323
+ updatePlayer(data: PlayerUpdateInfo): Promise<NodePlayerData>;
3324
+ /**
3325
+ * Destroys the AmberLinkPlayer on the AmberLink server
3326
+ * @param guildId
3327
+ * @returns request result
3328
+ *
3329
+ * @example
3330
+ * ```ts
3331
+ * // use player.destroy() instead
3332
+ * player.node.destroyPlayer(player.guildId);
3333
+ * ```
3334
+ */
3335
+ destroyPlayer(guildId: any): Promise<void>;
3336
+ /**
3337
+ * Connect to the server node
3338
+ * @param sessionId Provide the Session Id of the previous connection, to resume the node and it's player(s)
3339
+ * @returns void
3340
+ *
3341
+ * @example
3342
+ * ```ts
3343
+ * player.node.connect(); // if provided on bootup in managerOptions#nodes, this will be called automatically when doing AmberLink server.init()
3344
+ *
3345
+ * // or connect from a resuming session:
3346
+ * player.node.connect("sessionId");
3347
+ * ```
3348
+ */
3349
+ connect(sessionId?: string): void;
3350
+ private heartBeat;
3351
+ /**
3352
+ * Get the id of the node
3353
+ *
3354
+ * @example
3355
+ * ```ts
3356
+ * const nodeId = player.node.id;
3357
+ * console.log("node id is: ", nodeId)
3358
+ * ```
3359
+ */
3360
+ get id(): string;
3361
+ /**
3362
+ * Destroys the Node-Connection (Websocket) and all player's of the node
3363
+ * @param destroyReason Destroy Reason to use when destroying the players
3364
+ * @param deleteNode wether to delete the nodte from the nodes list too, if false it will emit a disconnect. @default true
3365
+ * @param movePlayers whether to movePlayers to different eligible connected node. If false players won't be moved @default false
3366
+ * @returns void
3367
+ *
3368
+ * @example
3369
+ * Destroys node and its players
3370
+ * ```ts
3371
+ * player.node.destroy("custom AmberLinkPlayer Destroy Reason", true);
3372
+ * ```
3373
+ * destroys only the node and moves its players to different connected node.
3374
+ * ```ts
3375
+ * player.node.destroy("custom AmberLinkPlayer Destroy Reason", true, true);
3376
+ * ```
3377
+ */
3378
+ destroy(destroyReason?: DestroyReasonsType, deleteNode?: boolean, movePlayers?: boolean): void;
3379
+ /**
3380
+ * Disconnects the Node-Connection (Websocket)
3381
+ * @param disconnectReason Disconnect Reason to use when disconnecting Node
3382
+ * @returns void
3383
+ *
3384
+ * Also the node will not get re-connected again.
3385
+ *
3386
+ * @example
3387
+ * ```ts
3388
+ * player.node.disconnect("Forcefully disconnect the connection to the node.");
3389
+ * ```
3390
+ */
3391
+ disconnect(disconnectReason?: DisconnectReasonsType): void;
3392
+ /**
3393
+ * Pick the best ready node to move players to.
3394
+ * A node must be connected and have a sessionId before a player can be migrated to it.
3395
+ */
3396
+ private getReadyMigrationNode;
3397
+ private getMigrationErrorMessage;
3398
+ private getMigrationConfig;
3399
+ private getMigrationReservationCount;
3400
+ private reserveMigrationTarget;
3401
+ private releaseMigrationTarget;
3402
+ private getEffectiveMigrationLoad;
3403
+ private selectMigrationTarget;
3404
+ private hasAnyHealthyMigrationNode;
3405
+ private isMigrationNodeHealthy;
3406
+ private waitForMigrationCapacity;
3407
+ /**
3408
+ * Move a batch of players to a ready node with bounded concurrency.
3409
+ * This keeps migration responsive without flooding the replacement node with requests.
3410
+ */
3411
+ private movePlayersToReplacementNode;
3412
+ /**
3413
+ * Gets all Players of a Node
3414
+ * @returns array of players inside of AmberLink server
3415
+ *
3416
+ * @example
3417
+ * ```ts
3418
+ * const node = AmberLink server.nodes.get("NODEID");
3419
+ * const playersOfNode = await node?.fetchAllPlayers();
3420
+ * ```
3421
+ */
3422
+ fetchAllPlayers(): Promise<NodePlayerData[] | InvalidNodeRestRequest | null>;
3423
+ /**
3424
+ * Gets specific AmberLinkPlayer Information
3425
+ * @returns AmberLink server player object if player exists on AmberLink server
3426
+ *
3427
+ * @example
3428
+ * ```ts
3429
+ * const node = AmberLink server.nodes.get("NODEID");
3430
+ * const playerInformation = await node?.fetchPlayer("guildId");
3431
+ * ```
3432
+ */
3433
+ fetchPlayer(guildId: string): Promise<NodePlayerData | InvalidNodeRestRequest | null>;
3434
+ /**
3435
+ * Updates the session with and enables/disables resuming and timeout
3436
+ * @param resuming Whether resuming is enabled for this session or not
3437
+ * @param timeout The timeout in seconds (default is 60s)
3438
+ * @returns the result of the request
3439
+ *
3440
+ * @example
3441
+ * ```ts
3442
+ * const node = player.node || AmberLink server.nodes.get("NODEID");
3443
+ * await node?.updateSession(true, 180e3); // will enable resuming for 180seconds
3444
+ * ```
3445
+ */
3446
+ updateSession(resuming?: boolean, timeout?: number): Promise<Session | InvalidNodeRestRequest | null>;
3447
+ /**
3448
+ * Decode Track or Tracks
3449
+ */
3450
+ decode: {
3451
+ /**
3452
+ * Decode a single track into its info
3453
+ * @param encoded valid encoded base64 string from a track
3454
+ * @param requester the requesteruser for building the track
3455
+ * @returns decoded track from AmberLink server
3456
+ *
3457
+ * @example
3458
+ * ```ts
3459
+ * const encodedBase64 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA=';
3460
+ * const track = await player.node.decode.singleTrack(encodedBase64, interaction.user);
3461
+ * ```
3462
+ */
3463
+ singleTrack: (encoded: Base64, requester: unknown) => Promise<Track>;
3464
+ /**
3465
+ * Decodes multiple tracks into their info
3466
+ * @param encodeds valid encoded base64 string array from all tracks
3467
+ * @param requester the requesteruser for building the tracks
3468
+ * @returns array of all tracks you decoded
3469
+ *
3470
+ * @example
3471
+ * ```ts
3472
+ * const encodedBase64_1 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA=';
3473
+ * const encodedBase64_2 = 'QAABJAMAClRhbGsgYSBMb3QACjQwNHZpbmNlbnQAAAAAAAHr1gBxTzpodHRwczovL2FwaS12Mi5zb3VuZGNsb3VkLmNvbS9tZWRpYS9zb3VuZGNsb3VkOnRyYWNrczo4NTE0MjEwNzYvMzUyYTRiOTAtNzYxOS00M2E5LWJiOGItMjIxMzE0YzFjNjNhL3N0cmVhbS9obHMAAQAsaHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS80MDR2aW5jZW50L3RhbGstYS1sb3QBADpodHRwczovL2kxLnNuZGNkbi5jb20vYXJ0d29ya3MtRTN1ek5Gc0Y4QzBXLTAtb3JpZ2luYWwuanBnAQAMUVpITkExOTg1Nzg0AApzb3VuZGNsb3VkAAAAAAAAAAA=';
3474
+ * const tracks = await player.node.decode.multipleTracks([encodedBase64_1, encodedBase64_2], interaction.user);
3475
+ * ```
3476
+ */
3477
+ multipleTracks: (encodeds: Base64[], requester: unknown) => Promise<Track[]>;
3478
+ };
3479
+ lyrics: {
3480
+ /**
3481
+ * Get a normalized synchronized lyric timeline. Word timestamps are preserved when the provider has them.
3482
+ * AmberLink uses its native API; third-party nodes use the client provider with an optional legacy fallback.
3483
+ */
3484
+ getTimeline: (track: Track, options?: LyricsLookupOptions) => Promise<AmberLinkLyricsTimeline | null>;
3485
+ /** Get synchronized lyrics for the player currently assigned to this node. */
3486
+ getCurrentTimeline: (guildId: string, options?: LyricsLookupOptions) => Promise<AmberLinkLyricsTimeline | null>;
3487
+ /**
3488
+ * Get the lyrics of a track
3489
+ * @param track the track to get the lyrics for
3490
+ * @param skipTrackSource wether to skip the track source or not
3491
+ * @returns the lyrics of the track
3492
+ * @example
3493
+ *
3494
+ * ```ts
3495
+ * const lyrics = await player.node.lyrics.get(track, true);
3496
+ * // use it of player instead:
3497
+ * // const lyrics = await player.getLyrics(track, true);
3498
+ * ```
3499
+ */
3500
+ get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
3501
+ /**
3502
+ * Get the lyrics of the current playing track
3503
+ *
3504
+ * @param guildId the guild id of the player
3505
+ * @param skipTrackSource wether to skip the track source or not
3506
+ * @returns the lyrics of the current playing track
3507
+ * @example
3508
+ * ```ts
3509
+ * const lyrics = await player.node.lyrics.getCurrent(guildId);
3510
+ * // use it of player instead:
3511
+ * // const lyrics = await player.getCurrentLyrics();
3512
+ * ```
3513
+ */
3514
+ getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
3515
+ /**
3516
+ * subscribe to lyrics updates for a guild
3517
+ * @param guildId the guild id of the player
3518
+ * @param skipTrackSource wether to skip the track source or not
3519
+ * @returns request data of the request
3520
+ *
3521
+ * @example
3522
+ * ```ts
3523
+ * await player.node.lyrics.subscribe(guildId);
3524
+ * // use it of player instead:
3525
+ * // const lyrics = await player.subscribeLyrics();
3526
+ * ```
3527
+ */
3528
+ subscribe: (guildId: string, skipTrackSource?: boolean) => Promise<unknown>;
3529
+ /**
3530
+ * unsubscribe from lyrics updates for a guild
3531
+ * @param guildId the guild id of the player
3532
+ * @returns request data of the request
3533
+ *
3534
+ * @example
3535
+ * ```ts
3536
+ * await player.node.lyrics.unsubscribe(guildId);
3537
+ * // use it of player instead:
3538
+ * // const lyrics = await player.unsubscribeLyrics();
3539
+ * ```
3540
+ */
3541
+ unsubscribe: (guildId: string) => Promise<void>;
3542
+ };
3543
+ /**
3544
+ * Request AmberLink server statistics.
3545
+ * @returns the server node stats
3546
+ *
3547
+ * @example
3548
+ * ```ts
3549
+ * const nodeStats = await player.node.fetchStats();
3550
+ * ```
3551
+ */
3552
+ fetchStats(): Promise<BaseNodeStats>;
3553
+ /**
3554
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
3555
+ * @returns the connection metrics of the node
3556
+ *
3557
+ * @example
3558
+ * ```ts
3559
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
3560
+ * ```
3561
+ */
3562
+ fetchConnectionMetrics(): Promise<NodeLinkConnectionMetrics>;
3563
+ /**
3564
+ * Request AmberLink server version.
3565
+ * @returns the current used AmberLink server version
3566
+ *
3567
+ * @example
3568
+ * ```ts
3569
+ * const nodeVersion = await player.node.fetchVersion();
3570
+ * ```
3571
+ */
3572
+ fetchVersion(): Promise<string>;
3573
+ /**
3574
+ * Request AmberLink server information.
3575
+ * @returns AmberLink server info object
3576
+ *
3577
+ * @example
3578
+ * ```ts
3579
+ * const audioNodeInfo = await player.node.fetchInfo();
3580
+ * const availablePlugins:string[] = audioNodeInfo.plugins.map(plugin => plugin.name);
3581
+ * const availableSources:string[] = audioNodeInfo.sourceManagers;
3582
+ * ```
3583
+ */
3584
+ fetchInfo(): Promise<AudioNodeInfo>;
3585
+ /**
3586
+ * Returns the metric summary of the node
3587
+ * @returns the metric summary of the node
3588
+ */
3589
+ nodeMetricSummary(): NodeMetricSummary;
3590
+ /**
3591
+ * Get the node's health status with performance assessment.
3592
+ * @returns Object containing health status, performance rating, load balancing info, and recommendations
3593
+ *
3594
+ * @example
3595
+ * ```ts
3596
+ * const health = node.getHealthStatus();
3597
+ * console.log(`Node Status: ${health.status}`); // "healthy" | "degraded" | "critical" | "offline"
3598
+ * console.log(`Performance: ${health.performance}`); // "excellent" | "good" | "fair" | "poor"
3599
+ * console.log(`Penalty Score: ${health.penaltyScore}`); // Lower is better for load balancing
3600
+ * console.log(`Estimated Capacity: ${health.estimatedRemainingCapacity} more players`);
3601
+ * console.log(`Overloaded: ${health.isOverloaded}`);
3602
+ * console.log(`Needs Restart: ${health.needsRestart}`);
3603
+ * if (health.recommendations.length) {
3604
+ * console.log("Recommendations:", health.recommendations);
3605
+ * }
3606
+ * ```
3607
+ */
3608
+ getHealthStatus(thresholds?: HealthStatusThresholdOptions): HealthStatusObject;
3609
+ /**
3610
+ * AmberLink server's Route Planner Api
3611
+ */
3612
+ routePlannerApi: {
3613
+ /**
3614
+ * Get routplanner Info from AmberLink server for ip rotation
3615
+ * @returns the status of the routeplanner
3616
+ *
3617
+ * @example
3618
+ * ```ts
3619
+ * const routePlannerStatus = await player.node.routePlannerApi.getStatus();
3620
+ * const usedBlock = routePlannerStatus.details?.ipBlock;
3621
+ * const currentIp = routePlannerStatus.currentAddress;
3622
+ * ```
3623
+ */
3624
+ getStatus: () => Promise<RoutePlanner>;
3625
+ /**
3626
+ * Release blacklisted IP address into pool of IPs for ip rotation
3627
+ * @param address IP address
3628
+ * @returns request data of the request
3629
+ *
3630
+ * @example
3631
+ * ```ts
3632
+ * await player.node.routePlannerApi.unmarkFailedAddress("ipv6address");
3633
+ * ```
3634
+ */
3635
+ unmarkFailedAddress: (address: string) => Promise<unknown>;
3636
+ /**
3637
+ * Release all blacklisted IP addresses into pool of IPs
3638
+ * @returns request data of the request
3639
+ *
3640
+ * @example
3641
+ * ```ts
3642
+ * await player.node.routePlannerApi.unmarkAllFailedAddresses();
3643
+ * ```
3644
+ */
3645
+ unmarkAllFailedAddresses: () => Promise<unknown>;
3646
+ };
3647
+ /** @private Utils for validating the */
3648
+ private validate;
3649
+ /**
3650
+ * Checks if the node is a NodeLink node
3651
+ * @returns true if the node is a NodeLink node
3652
+ */
3653
+ isNodeLink(): this is NodeLinkNode;
3654
+ /** Checks whether this is a separately operated compatible node. */
3655
+ isThirdPartyNode(): this is AmberLinkNode;
3656
+ /** Checks if the node is an AmberLink node. */
3657
+ isAmberLinkNode(): boolean;
3658
+ /**
3659
+ * Checks a discovered AmberLink capability. Nested names use dot notation,
3660
+ * for example `filters.equalizer`. External nodes always return false.
3661
+ */
3662
+ supportsAmberLinkFeature(featurePath: string): boolean;
3663
+ /**
3664
+ * Sync the data of the player you make an action to AmberLink server to
3665
+ * @param data data to use to update the player
3666
+ * @param res result data from AmberLink server, to override, if available
3667
+ * @returns boolean
3668
+ */
3669
+ private syncPlayerData;
3670
+ /**
3671
+ * Get the rest Adress for making requests
3672
+ */
3673
+ private get restAddress();
3674
+ /**
3675
+ * If already trying to reconnect or pending, return
3676
+ */
3677
+ get isNodeReconnecting(): boolean;
3678
+ /**
3679
+ * Reconnect to the server node
3680
+ * @param force @default false Wether to instantly try to reconnect (force it)
3681
+ * @returns void
3682
+ *
3683
+ * @example
3684
+ * ```ts
3685
+ * await player.node.reconnect(true); //true forcefully trys the reconnect
3686
+ * ```
3687
+ */
3688
+ private reconnect;
3689
+ get reconnectionAttemptCount(): number;
3690
+ /**
3691
+ * Private Utility function to execute the reconnection
3692
+ */
3693
+ private executeReconnect;
3694
+ /**
3695
+ * Private function to reset the reconnection attempts
3696
+ * @returns
3697
+ */
3698
+ private resetReconnectionAttempts;
3699
+ /**
3700
+ * Private function to reset timeouts/intervals for heartbeating/pinging
3701
+ * @param heartbeat
3702
+ * @param ping
3703
+ * @returns
3704
+ */
3705
+ private resetAckTimeouts;
3706
+ /** @private util function for handling opening events from websocket */
3707
+ private open;
3708
+ /** @private util function for handling closing events from websocket */
3709
+ private close;
3710
+ /** @private util function for handling error events from websocket */
3711
+ private error;
3712
+ /** @private util function for handling message events from websocket */
3713
+ private message;
3714
+ /** @private middleware util function for handling all kind of events from websocket */
3715
+ private handleEvent;
3716
+ /**
3717
+ * nodeLink specific events handling https://nodelink.js.org/docs/api/websocket#incoming-events-server--client
3718
+ * @param eventName
3719
+ * @param player
3720
+ * @param track
3721
+ * @param payload
3722
+ */
3723
+ private nodeLinkEventHandler;
3724
+ private getTrackOfPayload;
3725
+ /** @private util function for handling trackStart event */
3726
+ private trackStart;
3727
+ /** @private util function for handling trackEnd event */
3728
+ private trackEnd;
3729
+ /** @private util function for handling trackStuck event */
3730
+ private trackStuck;
3731
+ /** @private util function for handling trackError event */
3732
+ private trackError;
3733
+ /** @private util function for handling socketClosed event */
3734
+ private socketClosed;
3735
+ /** @private util function for handling SponsorBlock Segmentloaded event */
3736
+ private SponsorBlockSegmentLoaded;
3737
+ /** @private util function for handling SponsorBlock SegmentSkipped event */
3738
+ private SponsorBlockSegmentSkipped;
3739
+ /** @private util function for handling SponsorBlock Chaptersloaded event */
3740
+ private SponsorBlockChaptersLoaded;
3741
+ /** @private util function for handling SponsorBlock Chaptersstarted event */
3742
+ private SponsorBlockChapterStarted;
3743
+ /**
3744
+ * Get the current sponsorblocks for the sponsorblock plugin
3745
+ * @param player passthrough the player
3746
+ * @returns sponsorblock seggment from AmberLink server
3747
+ *
3748
+ * @example
3749
+ * ```ts
3750
+ * // use it on the player via player.getSponsorBlock();
3751
+ * const sponsorBlockSegments = await player.node.getSponsorBlock(player);
3752
+ * ```
3753
+ */
3754
+ getSponsorBlock(player: AmberLinkPlayer): Promise<SponsorBlockSegment[]>;
3755
+ /**
3756
+ * Set the current sponsorblocks for the sponsorblock plugin
3757
+ * @param player passthrough the player
3758
+ * @returns void
3759
+ *
3760
+ * @example
3761
+ * ```ts
3762
+ * // use it on the player via player.setSponsorBlock();
3763
+ * const sponsorBlockSegments = await player.node.setSponsorBlock(player, ["sponsor", "selfpromo"]);
3764
+ * ```
3765
+ */
3766
+ setSponsorBlock(player: AmberLinkPlayer, segments?: SponsorBlockSegment[]): Promise<void>;
3767
+ /**
3768
+ * Delete the sponsorblock plugins
3769
+ * @param player passthrough the player
3770
+ * @returns void
3771
+ *
3772
+ * @example
3773
+ * ```ts
3774
+ * // use it on the player via player.deleteSponsorBlock();
3775
+ * const sponsorBlockSegments = await player.node.deleteSponsorBlock(player);
3776
+ * ```
3777
+ */
3778
+ deleteSponsorBlock(player: AmberLinkPlayer): Promise<void>;
3779
+ /** private util function for handling the queue end event */
3780
+ private queueEnd;
3781
+ /**
3782
+ * Emitted whenever a line of lyrics gets emitted
3783
+ * @event
3784
+ * @param {AmberLinkPlayer} player The player that emitted the event
3785
+ * @param {Track} track The track that emitted the event
3786
+ * @param {LyricsLineEvent} payload The payload of the event
3787
+ */
3788
+ private LyricsLine;
3789
+ /**
3790
+ * Emitted whenever the lyrics for a track got found
3791
+ * @event
3792
+ * @param {AmberLinkPlayer} player The player that emitted the event
3793
+ * @param {Track} track The track that emitted the event
3794
+ * @param {LyricsFoundEvent} payload The payload of the event
3795
+ */
3796
+ private LyricsFound;
3797
+ /**
3798
+ * Emitted whenever the lyrics for a track got not found
3799
+ * @event
3800
+ * @param {AmberLinkPlayer} player The player that emitted the event
3801
+ * @param {Track} track The track that emitted the event
3802
+ * @param {LyricsNotFoundEvent} payload The payload of the event
3803
+ */
3804
+ private LyricsNotFound;
3805
+ /**
3806
+ * @private
3807
+ * util function to check if a provided source is valid with current node.
3808
+ * @param {AudioSearchPlatform} src
3809
+ * @returns {boolean} True if provided source is valid.
3810
+ */
3811
+ private isSourcePluginPlatform;
3812
+ }
3813
+ export declare class AmberLinkNodeManager extends EventEmitter {
3814
+ /**
3815
+ * Emit an event
3816
+ * @param event The event to emit
3817
+ * @param args The arguments to pass to the event
3818
+ * @returns
3819
+ */
3820
+ emit<Event extends keyof NodeManagerEvents>(event: Event, ...args: Parameters<NodeManagerEvents[Event]>): boolean;
3821
+ /**
3822
+ * Add an event listener
3823
+ * @param event The event to listen to
3824
+ * @param listener The listener to add
3825
+ * @returns
3826
+ */
3827
+ on<Event extends keyof NodeManagerEvents>(event: Event, listener: NodeManagerEvents[Event]): this;
3828
+ /**
3829
+ * Add an event listener that only fires once
3830
+ * @param event The event to listen to
3831
+ * @param listener The listener to add
3832
+ * @returns
3833
+ */
3834
+ once<Event extends keyof NodeManagerEvents>(event: Event, listener: NodeManagerEvents[Event]): this;
3835
+ /**
3836
+ * Remove an event listener
3837
+ * @param event The event to remove the listener from
3838
+ * @param listener The listener to remove
3839
+ * @returns
3840
+ */
3841
+ off<Event extends keyof NodeManagerEvents>(event: Event, listener: NodeManagerEvents[Event]): this;
3842
+ /**
3843
+ * Remove an event listener
3844
+ * @param event The event to remove the listener from
3845
+ * @param listener The listener to remove
3846
+ * @returns
3847
+ */
3848
+ removeListener<Event extends keyof NodeManagerEvents>(event: Event, listener: NodeManagerEvents[Event]): this;
3849
+ /**
3850
+ * The AmberLinkManager that created this AmberLinkNodeManager
3851
+ */
3852
+ AmberLinkManager: AmberLinkManager;
3853
+ /**
3854
+ * A map of all nodes in the nodeManager
3855
+ */
3856
+ nodes: MiniMap<string, AmberLinkNode | NodeLinkNode>;
3857
+ /** @internal Coordinates player migrations between nodes owned by this manager. */
3858
+ readonly playerMigration: {
3859
+ reservations: Map<string, number>;
3860
+ capacityWaiters: Set<() => void>;
3861
+ };
3862
+ /** @internal Wakes migrations waiting for capacity on one of this manager's nodes. */
3863
+ signalPlayerMigrationCapacityChange(): void;
3864
+ /**
3865
+ * @param AmberLinkManager The AmberLinkManager that created this AmberLinkNodeManager
3866
+ */
3867
+ constructor(AmberLinkManager: AmberLinkManager);
3868
+ /**
3869
+ * Disconnects all Nodes from AmberLink server ws sockets
3870
+ * @param deleteAllNodes if the nodes should also be deleted from nodeManager.nodes
3871
+ * @param destroyPlayers if the players should be destroyed
3872
+ * @returns amount of disconnected Nodes
3873
+ */
3874
+ disconnectAll(deleteAllNodes?: boolean, destroyPlayers?: boolean): Promise<number>;
3875
+ /**
3876
+ * Connects all not connected nodes
3877
+ * @returns Amount of connected Nodes
3878
+ */
3879
+ connectAll(): Promise<number>;
3880
+ /**
3881
+ * Forcefully reconnects all nodes
3882
+ * @returns amount of nodes
3883
+ */
3884
+ reconnectAll(): Promise<number>;
3885
+ /**
3886
+ * Create a node and add it to the nodeManager
3887
+ * @param options The options for the node
3888
+ * @returns The node that was created
3889
+ */
3890
+ createNode<T extends AmberLinkNode | NodeLinkNode>(options: AmberLinkNodeOptions | NodeLinkNode | AmberLinkNode): T;
3891
+ /**
3892
+ * Get the nodes sorted for the least usage, by a sorttype
3893
+ * @param sortType The type of sorting to use
3894
+ * @returns
3895
+ */
3896
+ leastUsedNodes(sortType?: "memory" | "cpuNode" | "cpuSystem" | "calls" | "playingPlayers" | "players", filterForNodeTypes?: (NodeType | NodeLinkNode | AmberLinkNode)[]): AmberLinkNode[];
3897
+ /**
3898
+ * Delete a node from the nodeManager and destroy it
3899
+ * @param node The node to delete
3900
+ * @param movePlayers whether to movePlayers to different connected node before deletion. @default false
3901
+ * @returns
3902
+ *
3903
+ * @example
3904
+ * Deletes the node
3905
+ * ```ts
3906
+ * client.amberlink.nodeManager.deleteNode("nodeId to delete");
3907
+ * ```
3908
+ * Moves players to a different node before deleting
3909
+ * ```ts
3910
+ * client.amberlink.nodeManager.deleteNode("nodeId to delete", true);
3911
+ * ```
3912
+ */
3913
+ deleteNode(node: NodeIdentifier | AmberLinkNode | NodeLinkNode, movePlayers?: boolean): void;
3914
+ /**
3915
+ * Get a node from the nodeManager
3916
+ * @param node The node to get either by idetnifier, by class or by enum
3917
+ * @returns The node that was retrieved
3918
+ */
3919
+ getNode(node: NodeIdentifier | AmberLinkNode | NodeLinkNode | NodeType): AmberLinkNode | NodeLinkNode | undefined;
3920
+ }
3921
+ /**
3922
+ * The events from the AmberLink manager
3923
+ */
3924
+ export interface AmberLinkManagerEvents<CustomPlayerT extends AmberLinkPlayer = AmberLinkPlayer> {
3925
+ /**
3926
+ * Emitted when a Track started playing.
3927
+ * @event Manager#trackStart
3928
+ */
3929
+ trackStart: (player: CustomPlayerT, track: Track | null, payload: TrackStartEvent) => void;
3930
+ /**
3931
+ * Emitted when a Track finished.
3932
+ * @event Manager#trackEnd
3933
+ */
3934
+ trackEnd: (player: CustomPlayerT, track: Track | null, payload: TrackEndEvent) => void;
3935
+ /**
3936
+ * Emitted when a Track got stuck while playing.
3937
+ * @event Manager#trackStuck
3938
+ */
3939
+ trackStuck: (player: CustomPlayerT, track: Track | null, payload: TrackStuckEvent) => void;
3940
+ /**
3941
+ * Emitted when a Track errored.
3942
+ * @event Manager#trackError
3943
+ */
3944
+ trackError: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: TrackExceptionEvent) => void;
3945
+ /**
3946
+ * Emitted when the Playing finished and no more tracks in the queue.
3947
+ * @event Manager#queueEnd
3948
+ */
3949
+ queueEnd: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
3950
+ /**
3951
+ * Emitted when a AmberLinkPlayer is created.
3952
+ * @event Manager#playerCreate
3953
+ */
3954
+ playerCreate: (player: CustomPlayerT) => void;
3955
+ /**
3956
+ * Emitted when a AmberLinkPlayer is moved within the channel.
3957
+ * @event Manager#playerMove
3958
+ */
3959
+ playerMove: (player: CustomPlayerT, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
3960
+ /**
3961
+ * Emitted when a AmberLinkPlayer is disconnected from a channel.
3962
+ * @event Manager#playerDisconnect
3963
+ */
3964
+ playerDisconnect: (player: CustomPlayerT, voiceChannelId: string) => void;
3965
+ /**
3966
+ * Emitted when a AmberLinkPlayer automatically reconnects after a disconnect.
3967
+ * This event is triggered when the player successfully reconnects to the voice channel
3968
+ * and resumes playback after being disconnected (requires onDisconnect.autoReconnect to be enabled).
3969
+ * @event Manager#playerReconnect
3970
+ */
3971
+ playerReconnect: (player: CustomPlayerT, voiceChannelId: string) => void;
3972
+ /**
3973
+ * Emitted when a Node-Socket got closed for a specific AmberLinkPlayer.
3974
+ * Usually emits when the audio websocket to discord is closed, This can happen for various reasons (normal and abnormal), e.g. when using an expired voice server update. 4xxx codes are usually bad.
3975
+ *
3976
+ * So this is just information, normally AmberLink server should handle disconnections
3977
+ *
3978
+ * Discord Docs:
3979
+ * @link https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
3980
+ *
3981
+ * Discord voice connection lifecycle documentation.
3982
+ * @event Manager#playerSocketClosed
3983
+ */
3984
+ playerSocketClosed: (player: CustomPlayerT, payload: WebSocketClosedEvent) => void;
3985
+ /**
3986
+ * Emitted when a AmberLinkPlayer get's destroyed
3987
+ * @event Manager#playerDestroy
3988
+ */
3989
+ playerDestroy: (player: CustomPlayerT, destroyReason?: DestroyReasonsType) => void;
3990
+ /**
3991
+ * Always emits when the player (on AmberLink server side) got updated
3992
+ * @event Manager#playerUpdate
3993
+ */
3994
+ playerUpdate: (oldPlayerJson: PlayerJson, newPlayer: CustomPlayerT) => void;
3995
+ /**
3996
+ * Always emits when the player (on client side) got updated via a function-call.
3997
+ * This is useful for example, if you want to save the player data on every update, or similar.
3998
+ * @event Manager#playerClientUpdate
3999
+ *
4000
+ * Emits only when you call one of those functions:
4001
+ * player.pause()
4002
+ * player.resume()
4003
+ * player.seek()
4004
+ * player.setRepeatMode()
4005
+ * player.setVolume()
4006
+ * and on every call of the filterManager.
4007
+ */
4008
+ playerClientUpdate: (oldPlayerJson: PlayerJson, newPlayer: CustomPlayerT) => void;
4009
+ /**
4010
+ * Emitted when the player's selfMuted or serverMuted state changed (true -> false | false -> true)
4011
+ * @event Manager#playerMuteChange
4012
+ */
4013
+ playerMuteChange: (player: CustomPlayerT, selfMuted: boolean, serverMuted: boolean) => void;
4014
+ /**
4015
+ * Emitted when the player's selfDeafed or serverDeafed state changed (true -> false | false -> true)
4016
+ * @event Manager#playerDeafChange
4017
+ */
4018
+ playerDeafChange: (player: CustomPlayerT, selfDeafed: boolean, serverDeafed: boolean) => void;
4019
+ /**
4020
+ * Emitted when the player's suppressed (true -> false | false -> true)
4021
+ * @event Manager#playerSuppressChange
4022
+ */
4023
+ playerSuppressChange: (player: CustomPlayerT, suppress: boolean) => void;
4024
+ /**
4025
+ * Emitted when the player's queue got empty, and the timeout started
4026
+ * @event Manager#playerQueueEmptyStart
4027
+ */
4028
+ playerQueueEmptyStart: (player: CustomPlayerT, timeoutMs: number) => void;
4029
+ /**
4030
+ * Emitted when the player's queue got empty, and the timeout finished leading to destroying the player
4031
+ * @event Manager#playerQueueEmptyEnd
4032
+ */
4033
+ playerQueueEmptyEnd: (player: CustomPlayerT) => void;
4034
+ /**
4035
+ * Emitted when the player's queue got empty, and the timeout got cancelled becuase a track got re-added to it.
4036
+ * @event Manager#playerQueueEmptyEnd
4037
+ */
4038
+ playerQueueEmptyCancel: (player: CustomPlayerT) => void;
4039
+ /**
4040
+ * Emitted, when a user joins the voice channel, while there is a player existing
4041
+ * @event Manager#playerQueueEmptyStart
4042
+ */
4043
+ playerVoiceJoin: (player: CustomPlayerT, userId: string) => void;
4044
+ /**
4045
+ * Emitted, when a user leaves the voice channel, while there is a player existing
4046
+ * @event Manager#playerQueueEmptyEnd
4047
+ */
4048
+ playerVoiceLeave: (player: CustomPlayerT, userId: string) => void;
4049
+ /**
4050
+ * SPONSORBLOCK-PLUGIN EVENT
4051
+ * Emitted when Segments are loaded
4052
+ * @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
4053
+ * @event Manager#trackError
4054
+ */
4055
+ SegmentsLoaded: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentsLoaded) => void;
4056
+ /**
4057
+ * SPONSORBLOCK-PLUGIN EVENT
4058
+ * Emitted when a specific Segment was skipped
4059
+ * @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
4060
+ * @event Manager#trackError
4061
+ */
4062
+ SegmentSkipped: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentSkipped) => void;
4063
+ /**
4064
+ * SPONSORBLOCK-PLUGIN EVENT
4065
+ * Emitted when a specific Chapter starts playing
4066
+ * @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
4067
+ * @event Manager#trackError
4068
+ */
4069
+ ChapterStarted: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: SponsorBlockChapterStarted) => void;
4070
+ /**
4071
+ * SPONSORBLOCK-PLUGIN EVENT
4072
+ * Emitted when Chapters are loaded
4073
+ * @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
4074
+ * @event Manager#trackError
4075
+ */
4076
+ ChaptersLoaded: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
4077
+ /**
4078
+ * AmberLink client Debug Event
4079
+ * Emitted for several erros, and logs within AmberLink Client, if managerOptions.advancedOptions.enableDebugEvents is true
4080
+ * Useful for debugging the AmberLink Client
4081
+ *
4082
+ * @event Manager#debug
4083
+ */
4084
+ debug: (eventKey: DebugEvents, eventData: {
4085
+ message: string;
4086
+ state: "log" | "warn" | "error";
4087
+ error?: Error | string;
4088
+ functionLayer: string;
4089
+ }) => void;
4090
+ /**
4091
+ * Emitted when a Lyrics line is received
4092
+ * @link https://github.com/topi314/LavaLyrics
4093
+ * @event Manager#LyricsLine
4094
+ */
4095
+ LyricsLine: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: LyricsLineEvent) => void;
4096
+ /**
4097
+ * Emitted when a Lyrics is found
4098
+ * @link https://github.com/topi314/LavaLyrics
4099
+ * @event Manager#LyricsFound
4100
+ */
4101
+ LyricsFound: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: LyricsFoundEvent) => void;
4102
+ /**
4103
+ * Emitted when a Lyrics is not found
4104
+ * @link https://github.com/topi314/LavaLyrics
4105
+ * @event Manager#LyricsNotFound
4106
+ */
4107
+ LyricsNotFound: (player: CustomPlayerT, track: Track | UnresolvedTrack | null, payload: LyricsNotFoundEvent) => void;
4108
+ playerResumed: (player: CustomPlayerT, track: Track | UnresolvedTrack | null) => void;
4109
+ playerPaused: (player: CustomPlayerT, track: Track | UnresolvedTrack | null) => void;
4110
+ }
4111
+ /**
4112
+ * The Bot client Options needed for the manager
4113
+ */
4114
+ export interface BotClientOptions {
4115
+ /** Bot Client Id */
4116
+ id: string;
4117
+ /** Bot Client Username */
4118
+ username?: string;
4119
+ /** So users can pass entire objects / classes */
4120
+ [x: string | number | symbol]: unknown;
4121
+ }
4122
+ /** Sub Manager Options, for player specific things */
4123
+ export interface ManagerPlayerOptions<CustomPlayerT extends AmberLinkPlayer = AmberLinkPlayer> {
4124
+ /** If the AmberLink server volume should be decremented by a configured amount */
4125
+ volumeDecrementer?: number;
4126
+ /** How often it should update the player Position */
4127
+ clientBasedPositionUpdateInterval?: number;
4128
+ /** What should be used as a searchPlatform, if no source was provided during the query */
4129
+ defaultSearchPlatform?: SearchPlatform;
4130
+ /** Allow custom sources which AmberLink Client does not support (yet) */
4131
+ allowCustomSources?: boolean;
4132
+ /** Applies volume via a filter instead of the AmberLink server volume transformer */
4133
+ applyVolumeAsFilter?: boolean;
4134
+ /** Transforms the saved data of a requested user */
4135
+ requesterTransformer?: (requester: unknown) => unknown;
4136
+ /** What AmberLink Client should do when the player reconnects */
4137
+ onDisconnect?: {
4138
+ /** Try to reconnect? -> If fails -> Destroy */
4139
+ autoReconnect?: boolean;
4140
+ /** Only try to reconnect if there are tracks in the queue */
4141
+ autoReconnectOnlyWithTracks?: boolean;
4142
+ /** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
4143
+ destroyPlayer?: boolean;
4144
+ };
4145
+ /** Minimum time to play the song before autoPlayFunction is executed (prevents error spamming) Set to 0 to disable it @default 10000 */
4146
+ minAutoPlayMs?: number;
4147
+ /** Allows you to declare how many tracks are allowed to error/stuck within a time-frame before player is destroyed @default "{threshold: 35000, maxAmount: 3 }" */
4148
+ maxErrorsPerTime?: {
4149
+ /** The threshold time to count errors (recommended is 35s) */
4150
+ threshold: number;
4151
+ /** The max amount of errors within the threshold time which are allowed before destroying the player (when errors > maxAmount -> player.destroy()) */
4152
+ maxAmount: number;
4153
+ };
4154
+ onEmptyQueue?: {
4155
+ /** Get's executed onEmptyQueue -> You can do any track queue previous transformations, if you add a track to the queue -> it will play it, if not queueEnd will execute! */
4156
+ autoPlayFunction?: (player: CustomPlayerT, lastPlayedTrack: Track) => Promise<void>;
4157
+ destroyAfterMs?: number;
4158
+ };
4159
+ useUnresolvedData?: boolean;
4160
+ /**
4161
+ * If true (default), when changing nodes, `setSponsorBlock()` with default categories is called
4162
+ * even if the user never explicitly set categories. This is needed so the SponsorBlock plugin
4163
+ * registers its event listeners (ChapterStarted/ChapterLoaded) on the new node.
4164
+ * Set to false to disable this behavior if you don't use SponsorBlock events.
4165
+ * @default true
4166
+ */
4167
+ enforceSponsorBlockRequestForEventEnablement?: boolean;
4168
+ }
4169
+ export type DeepRequired<T> = { [K in keyof T]-?: NonNullable<T[K]> extends object ? DeepRequired<NonNullable<T[K]>> : NonNullable<T[K]>; };
4170
+ export type RequiredManagerOptions<T extends AmberLinkPlayer> = DeepRequired<ManagerOptions<T>>;
4171
+ type PlayerConstructor<T extends AmberLinkPlayer = AmberLinkPlayer> = new (options: PlayerOptions, AmberLinkManager: AmberLinkManager, dontEmitPlayerCreateEvent?: boolean) => T;
4172
+ /** Manager Options used to create the manager */
4173
+ export interface ManagerOptions<CustomPlayerT extends AmberLinkPlayer = AmberLinkPlayer> {
4174
+ /** The Node Options, for all Nodes! (on init) */
4175
+ nodes: (AmberLinkNodeOptions | NodeLinkNode | AmberLinkNode)[];
4176
+ /** @async The Function to send the voice connection changes from AmberLink server to Discord */
4177
+ sendToShard: (guildId: string, payload: GuildShardPayload) => void;
4178
+ /** The Bot Client's Data for Authorization */
4179
+ client?: BotClientOptions;
4180
+ /** QueueOptions for all Queues */
4181
+ queueOptions?: ManagerQueueOptions;
4182
+ /** PlayerOptions for all Players */
4183
+ playerOptions?: ManagerPlayerOptions<CustomPlayerT>;
4184
+ /** The player class you want to use when creating a player. (can be extendable) */
4185
+ playerClass?: PlayerConstructor<CustomPlayerT>;
4186
+ /** If it should skip to the next Track on TrackEnd / TrackError etc. events */
4187
+ autoSkip?: boolean;
4188
+ /** If it should automatically move the player to the next node when node is down */
4189
+ autoMove?: boolean;
4190
+ /** If it should skip to the next Track if track.resolve errors while trying to play a track. */
4191
+ autoSkipOnResolveError?: boolean;
4192
+ /**
4193
+ * If the library's internal fire-and-forget lifecycle calls (e.g. autoSkip `player.play()`,
4194
+ * `player.destroy()`, and the fire-and-forget queue `save()` inside `AmberLinkPlayer#play()`) should
4195
+ * catch their own rejections instead of letting them surface as unhandled rejections which
4196
+ * may crash the host application.
4197
+ * Default: false - rejections surface as unhandled rejections, exactly as if this option
4198
+ * did not exist.
4199
+ */
4200
+ catchLifeCycleRejections?: boolean;
4201
+ /** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
4202
+ emitNewSongsOnly?: boolean;
4203
+ /** Only allow link requests with links either matching some of that regExp or including some of that string */
4204
+ linksWhitelist?: (RegExp | string)[];
4205
+ /** Never allow link requests with links either matching some of that regExp or including some of that string (doesn't even allow if it's whitelisted) */
4206
+ linksBlacklist?: (RegExp | string)[];
4207
+ /** If links should be allowed or not. If set to false, it will throw an error if a link was provided. */
4208
+ linksAllowed?: boolean;
4209
+ /** Custom http headers to be sent with every request to AmberLink server */
4210
+ httpHeaders?: Record<string, string>;
4211
+ /** Advanced Options for the Library, which may or may not be "library breaking" */
4212
+ advancedOptions?: {
4213
+ /** Max duration for that the filter fix duration works (in ms) - default is 8mins */
4214
+ maxFilterFixDuration?: number;
4215
+ /** Enable Debug event */
4216
+ enableDebugEvents?: boolean;
4217
+ /** optional */
4218
+ debugOptions?: {
4219
+ /** For logging custom searches */
4220
+ logCustomSearches?: boolean;
4221
+ /** logs for debugging the "no-Audio" playing error */
4222
+ noAudio?: boolean;
4223
+ /** For Logging the Destroy function */
4224
+ playerDestroy?: {
4225
+ /** To show the debug reason at all times. */
4226
+ debugLog?: boolean;
4227
+ /** If you get 'Error: Use AmberLinkPlayer#destroy("reason") not AmberLinkManager#deletePlayer() to stop the AmberLinkPlayer' put it on true */
4228
+ dontThrowError?: boolean;
4229
+ };
4230
+ };
4231
+ /** AmberLinkPlayer migration configuration */
4232
+ playerMigration?: {
4233
+ /** Maximum number of players migrated concurrently. Default: 5 */
4234
+ concurrency?: number;
4235
+ /** Maximum number of concurrent migrations to a single target node. Default: 2 */
4236
+ perTargetConcurrency?: number;
4237
+ /** Maximum time to wait for migration capacity before retrying. Default: 50ms */
4238
+ backpressureDelayMs?: number;
4239
+ };
4240
+ };
4241
+ }
4242
+ export declare class AmberLinkManager<CustomPlayerT extends AmberLinkPlayer = AmberLinkPlayer> extends EventEmitter {
4243
+ /**
4244
+ * Emit an event
4245
+ * @param event The event to emit
4246
+ * @param args The arguments to pass to the event
4247
+ * @returns
4248
+ */
4249
+ emit<Event extends keyof AmberLinkManagerEvents<CustomPlayerT>>(event: Event, ...args: Parameters<AmberLinkManagerEvents<CustomPlayerT>[Event]>): boolean;
4250
+ /**
4251
+ * Add an event listener
4252
+ * @param event The event to listen to
4253
+ * @param listener The listener to add
4254
+ * @returns
4255
+ */
4256
+ on<Event extends keyof AmberLinkManagerEvents<CustomPlayerT>>(event: Event, listener: AmberLinkManagerEvents<CustomPlayerT>[Event]): this;
4257
+ /**
4258
+ * Add an event listener that only fires once
4259
+ * @param event The event to listen to
4260
+ * @param listener The listener to add
4261
+ * @returns
4262
+ */
4263
+ once<Event extends keyof AmberLinkManagerEvents<CustomPlayerT>>(event: Event, listener: AmberLinkManagerEvents<CustomPlayerT>[Event]): this;
4264
+ /**
4265
+ * Remove an event listener
4266
+ * @param event The event to remove the listener from
4267
+ * @param listener The listener to remove
4268
+ * @returns
4269
+ */
4270
+ off<Event extends keyof AmberLinkManagerEvents<CustomPlayerT>>(event: Event, listener: AmberLinkManagerEvents<CustomPlayerT>[Event]): this;
4271
+ /**
4272
+ * Remove an event listener
4273
+ * @param event The event to remove the listener from
4274
+ * @param listener The listener to remove
4275
+ * @returns
4276
+ */
4277
+ removeListener<Event extends keyof AmberLinkManagerEvents<CustomPlayerT>>(event: Event, listener: AmberLinkManagerEvents<CustomPlayerT>[Event]): this;
4278
+ /** The Options of AmberLinkManager (changeable) */
4279
+ options: ManagerOptions<CustomPlayerT>;
4280
+ /** AmberLinkManager's AmberLinkNodeManager to manage all Nodes */
4281
+ nodeManager: AmberLinkNodeManager;
4282
+ /** AmberLinkManager's Utils Class */
4283
+ utils: ManagerUtils;
4284
+ /** Whether the manager was initiated or not */
4285
+ initiated: boolean;
4286
+ /** All Players stored in a MiniMap */
4287
+ readonly players: MiniMap<string, CustomPlayerT>;
4288
+ /**
4289
+ * Applies the options provided by the User
4290
+ * @param options
4291
+ * @returns
4292
+ */
4293
+ private applyOptions;
4294
+ /**
4295
+ * Validates the current manager's options
4296
+ * @param options
4297
+ */
4298
+ private validateOptions;
4299
+ /**
4300
+ * Emits a debug event to the AmberLinkManager
4301
+ * @param name name of the event
4302
+ * @param eventData event data
4303
+ */
4304
+ private _emitDebugEvent;
4305
+ private static readonly _noAudioDebugPrefix;
4306
+ /**
4307
+ * Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
4308
+ */
4309
+ private _debugNoAudio;
4310
+ /**
4311
+ * Create the AmberLink manager
4312
+ * @param options
4313
+ *
4314
+ * @example
4315
+ * ```ts
4316
+ * //const client = new Client({...}); // create your BOT Client (e.g. via discord.js)
4317
+ * client.amberlink = new AmberLinkManager({
4318
+ * nodes: [
4319
+ * {
4320
+ * authorization: "yourverystrongpassword",
4321
+ * host: "localhost",
4322
+ * port: 2333,
4323
+ * id: "testnode"
4324
+ * },
4325
+ * // You can also use parseAmberLinkConnUrl() to turn an amberlink://, thirdparty://, or nodelink:// URL into node options.
4326
+ * // parseAmberLinkConnUrl("amberlink://<nodeId>:<nodeAuthorization>@<NodeHost>:<NodePort>")
4327
+ * sendToShard(guildId, payload) => client.guilds.cache.get(guildId)?.shard?.send(payload),
4328
+ * ],
4329
+ * client: {
4330
+ * id: process.env.CLIENT_ID,
4331
+ * username: "TESTBOT"
4332
+ * },
4333
+ * // optional Options:
4334
+ * autoSkip: true,
4335
+ * playerOptions: {
4336
+ * applyVolumeAsFilter: false,
4337
+ * clientBasedPositionUpdateInterval: 150,
4338
+ * defaultSearchPlatform: "ytmsearch",
4339
+ * allowCustomSources: false,
4340
+ * volumeDecrementer: 0.75,
4341
+ * //requesterTransformer: YourRequesterTransformerFunction,
4342
+ * onDisconnect: {
4343
+ * autoReconnect: true,
4344
+ * destroyPlayer: false
4345
+ * },
4346
+ * onEmptyQueue: {
4347
+ * destroyAfterMs: 30_000,
4348
+ * //autoPlayFunction: YourAutoplayFunction,
4349
+ * },
4350
+ * useUnresolvedData: true
4351
+ * },
4352
+ * queueOptions: {
4353
+ * maxPreviousTracks: 25,
4354
+ * //queueStore: yourCustomQueueStoreManagerClass,
4355
+ * //queueChangesWatcher: yourCustomQueueChangesWatcherClass
4356
+ * },
4357
+ * linksBlacklist: [],
4358
+ * linksWhitelist: [],
4359
+ * advancedOptions: {
4360
+ * maxFilterFixDuration: 600_000,
4361
+ * debugOptions: {
4362
+ * noAudio: false,
4363
+ * playerDestroy: {
4364
+ * dontThrowError: false,
4365
+ * debugLogs: false
4366
+ * }
4367
+ * }
4368
+ * }
4369
+ * })
4370
+ * ```
4371
+ */
4372
+ constructor(options: ManagerOptions<CustomPlayerT>);
4373
+ /**
4374
+ * Get a AmberLinkPlayer from Lava
4375
+ * @param guildId The guildId of the player
4376
+ *
4377
+ * @example
4378
+ * ```ts
4379
+ * const player = client.amberlink.getPlayer(interaction.guildId);
4380
+ * ```
4381
+ * A quicker and easier way than doing:
4382
+ * ```ts
4383
+ * const player = client.amberlink.players.get(interaction.guildId);
4384
+ * ```
4385
+ * @returns
4386
+ */
4387
+ getPlayer(guildId: string): CustomPlayerT | undefined;
4388
+ /**
4389
+ * Create a Music-AmberLinkPlayer. If a player exists, then it returns it before creating a new one
4390
+ * @param options
4391
+ * @returns
4392
+ *
4393
+ * @example
4394
+ * ```ts
4395
+ * const player = client.amberlink.createPlayer({
4396
+ * guildId: interaction.guildId,
4397
+ * voiceChannelId: interaction.member.voice.channelId,
4398
+ * // everything below is optional
4399
+ * textChannelId: interaction.channelId,
4400
+ * volume: 100,
4401
+ * selfDeaf: true,
4402
+ * selfMute: false,
4403
+ * instaUpdateFiltersFix: true,
4404
+ * applyVolumeAsFilter: false
4405
+ * //only needed if you want to autopick node by region (configured by you)
4406
+ * // vcRegion: interaction.member.voice.rtcRegion,
4407
+ * // provide a specific node
4408
+ * // node: client.amberlink.nodeManager.leastUsedNodes("memory")[0]
4409
+ * });
4410
+ * ```
4411
+ */
4412
+ createPlayer(options: PlayerOptions): CustomPlayerT;
4413
+ /**
4414
+ * Destroy a player with optional destroy reason and disconnect it from the voice channel
4415
+ * @param guildId
4416
+ * @param destroyReason
4417
+ * @returns
4418
+ *
4419
+ * @example
4420
+ * ```ts
4421
+ * client.amberlink.destroyPlayer(interaction.guildId, "forcefully destroyed the player");
4422
+ * // recommend to do it on the player tho: player.destroy("forcefully destroyed the player");
4423
+ * ```
4424
+ */
4425
+ destroyPlayer(guildId: string, destroyReason?: string): Promise<void | CustomPlayerT>;
4426
+ /**
4427
+ * Delete's a player from the cache without destroying it on AmberLink server (only works when it's disconnected)
4428
+ * @param guildId
4429
+ * @returns
4430
+ *
4431
+ * @example
4432
+ * ```ts
4433
+ * client.amberlink.deletePlayer(interaction.guildId);
4434
+ * // shouldn't be used except you know what you are doing.
4435
+ * ```
4436
+ */
4437
+ deletePlayer(guildId: string): boolean | void;
4438
+ /**
4439
+ * Checks whether the the lib is useable based on if any node is connected
4440
+ *
4441
+ * @example
4442
+ * ```ts
4443
+ * if(!client.amberlink.useable) return console.error("can'T search yet, because there is no useable server node.")
4444
+ * // continue with code e.g. createing a player and searching
4445
+ * ```
4446
+ */
4447
+ get useable(): boolean;
4448
+ /**
4449
+ * Initiates the Manager, creates all nodes and connects all of them
4450
+ * @param clientData
4451
+ *
4452
+ * @example
4453
+ * ```ts
4454
+ * // on the bot ready event
4455
+ * client.on("ready", () => {
4456
+ * client.amberlink.init({
4457
+ * id: client.user.id,
4458
+ * username: client.user.username
4459
+ * });
4460
+ * });
4461
+ * ```
4462
+ */
4463
+ init(clientData: BotClientOptions): Promise<this>;
4464
+ /**
4465
+ * Sends voice data to the AmberLink server.
4466
+ * ! Without this the library won't work
4467
+ * @param data
4468
+ *
4469
+ * @example
4470
+ *
4471
+ * ```ts
4472
+ * // on the bot "raw" event
4473
+ * client.on("raw", (d) => {
4474
+ * // required in order to send audio updates and register channel deletion etc.
4475
+ * client.amberlink.sendRawData(d)
4476
+ * })
4477
+ * ```
4478
+ */
4479
+ sendRawData(data: VoicePacket | VoiceServer | VoiceState | ChannelDeletePacket): Promise<void>;
4480
+ }
4481
+ /** Default Sources Record, to allow source parsing with multiple inputs. */
4482
+ export declare const DefaultSources: Record<SearchPlatform, AudioSearchPlatform | ClientCustomSearchPlatformUtils>;
4483
+ /** Protocol identifiers for optional capabilities on external nodes. */
4484
+ export declare const ThirdPartyExtensions: {
4485
+ SpeechProvider: string;
4486
+ SourceProvider: string;
4487
+ CloudTextToSpeech: string;
4488
+ SearchProvider: string;
4489
+ JioSaavnProvider: string;
4490
+ ThirdPartyDspx: string;
4491
+ ThirdPartyLyrics: string;
4492
+ ThirdPartyFilterExtension: string;
4493
+ JavaTimedLyricsPlugin: string;
4494
+ PulseLinkPlugin: string;
4495
+ };
4496
+ /** AmberLink server Sources regexes for url validations */
4497
+ export declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
4498
+ export { AmberLinkFilterManager as FilterManager, AmberLinkNodeManager as NodeManager, AmberLinkPlayer as Player, AmberLinkQueue as Queue };