lavalink-client 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +140 -20
  2. package/dist/cjs/index.d.ts +7 -1
  3. package/dist/cjs/index.js +7 -1
  4. package/dist/cjs/structures/Constants.d.ts +40 -0
  5. package/dist/cjs/structures/Constants.js +244 -0
  6. package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  7. package/dist/cjs/structures/Filters.d.ts +2 -217
  8. package/dist/cjs/structures/Filters.js +12 -236
  9. package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
  10. package/dist/cjs/structures/LavalinkManager.js +60 -8
  11. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
  12. package/dist/cjs/structures/LavalinkManagerStatics.js +1 -1
  13. package/dist/cjs/structures/Node.d.ts +15 -156
  14. package/dist/cjs/structures/Node.js +140 -51
  15. package/dist/cjs/structures/NodeManager.d.ts +54 -52
  16. package/dist/cjs/structures/NodeManager.js +77 -5
  17. package/dist/cjs/structures/Player.d.ts +31 -124
  18. package/dist/cjs/structures/Player.js +78 -43
  19. package/dist/cjs/structures/Queue.d.ts +113 -42
  20. package/dist/cjs/structures/Queue.js +169 -8
  21. package/dist/cjs/structures/Types/Filters.d.ts +190 -0
  22. package/dist/cjs/structures/Types/Manager.d.ts +184 -0
  23. package/dist/cjs/structures/Types/Manager.js +2 -0
  24. package/dist/cjs/structures/Types/Node.d.ts +216 -0
  25. package/dist/cjs/structures/Types/Node.js +2 -0
  26. package/dist/cjs/structures/Types/Player.d.ts +108 -0
  27. package/dist/cjs/structures/Types/Player.js +2 -0
  28. package/dist/cjs/structures/Types/Queue.d.ts +34 -0
  29. package/dist/cjs/structures/Types/Queue.js +2 -0
  30. package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +4 -2
  31. package/dist/cjs/structures/Types/Track.js +2 -0
  32. package/dist/cjs/structures/Types/Utils.d.ts +367 -0
  33. package/dist/cjs/structures/Types/Utils.js +2 -0
  34. package/dist/cjs/structures/Utils.d.ts +13 -369
  35. package/dist/cjs/structures/Utils.js +40 -18
  36. package/dist/esm/index.d.ts +7 -1
  37. package/dist/esm/index.js +7 -1
  38. package/dist/esm/structures/Constants.d.ts +40 -0
  39. package/dist/esm/structures/Constants.js +241 -0
  40. package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  41. package/dist/esm/structures/Filters.d.ts +2 -217
  42. package/dist/esm/structures/Filters.js +7 -231
  43. package/dist/esm/structures/LavalinkManager.d.ts +31 -166
  44. package/dist/esm/structures/LavalinkManager.js +58 -6
  45. package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
  46. package/dist/esm/structures/LavalinkManagerStatics.js +1 -1
  47. package/dist/esm/structures/Node.d.ts +15 -156
  48. package/dist/esm/structures/Node.js +132 -43
  49. package/dist/esm/structures/NodeManager.d.ts +54 -52
  50. package/dist/esm/structures/NodeManager.js +74 -2
  51. package/dist/esm/structures/Player.d.ts +31 -124
  52. package/dist/esm/structures/Player.js +77 -42
  53. package/dist/esm/structures/Queue.d.ts +113 -42
  54. package/dist/esm/structures/Queue.js +169 -8
  55. package/dist/esm/structures/Types/Filters.d.ts +190 -0
  56. package/dist/esm/structures/Types/Manager.d.ts +184 -0
  57. package/dist/esm/structures/Types/Manager.js +1 -0
  58. package/dist/esm/structures/Types/Node.d.ts +216 -0
  59. package/dist/esm/structures/Types/Node.js +1 -0
  60. package/dist/esm/structures/Types/Player.d.ts +108 -0
  61. package/dist/esm/structures/Types/Player.js +1 -0
  62. package/dist/esm/structures/Types/Queue.d.ts +34 -0
  63. package/dist/esm/structures/Types/Queue.js +1 -0
  64. package/dist/{types/structures → esm/structures/Types}/Track.d.ts +4 -2
  65. package/dist/esm/structures/Types/Track.js +1 -0
  66. package/dist/esm/structures/Types/Utils.d.ts +367 -0
  67. package/dist/esm/structures/Types/Utils.js +1 -0
  68. package/dist/esm/structures/Utils.d.ts +13 -369
  69. package/dist/esm/structures/Utils.js +40 -18
  70. package/dist/types/index.d.ts +7 -1
  71. package/dist/types/structures/Constants.d.ts +40 -0
  72. package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  73. package/dist/types/structures/Filters.d.ts +2 -217
  74. package/dist/types/structures/LavalinkManager.d.ts +31 -166
  75. package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
  76. package/dist/types/structures/Node.d.ts +15 -156
  77. package/dist/types/structures/NodeManager.d.ts +54 -52
  78. package/dist/types/structures/Player.d.ts +31 -124
  79. package/dist/types/structures/Queue.d.ts +113 -42
  80. package/dist/types/structures/Types/Filters.d.ts +190 -0
  81. package/dist/types/structures/Types/Manager.d.ts +184 -0
  82. package/dist/types/structures/Types/Node.d.ts +216 -0
  83. package/dist/types/structures/Types/Player.d.ts +108 -0
  84. package/dist/types/structures/Types/Queue.d.ts +34 -0
  85. package/dist/{esm/structures → types/structures/Types}/Track.d.ts +4 -2
  86. package/dist/types/structures/Types/Utils.d.ts +367 -0
  87. package/dist/types/structures/Utils.d.ts +13 -369
  88. package/package.json +1 -1
  89. /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
  90. /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
@@ -1,58 +1,13 @@
1
- import { LavalinkFilterData } from "./Filters";
2
- import { LavalinkManager } from "./LavalinkManager";
3
- import { LavalinkNode, LavalinkNodeOptions, NodeStats } from "./Node";
4
- import { LavalinkPlayOptions, Player } from "./Player";
5
- import { LavalinkTrack, PluginInfo, Track, UnresolvedQuery, UnresolvedTrack } from "./Track";
1
+ import type { LavalinkNodeOptions } from "./Types/Node";
2
+ import type { LavalinkSearchPlatform, LavaSearchQuery, MiniMapConstructor, SearchPlatform, SearchQuery } from "./Types/Utils";
3
+ import type { LavalinkManager } from "./LavalinkManager";
4
+ import type { LavalinkNode } from "./Node";
5
+ import type { Player } from "./Player";
6
+ import type { LavalinkTrack, Track, UnresolvedQuery, UnresolvedTrack } from "./Types/Track";
6
7
  export declare const TrackSymbol: unique symbol;
7
8
  export declare const UnresolvedTrackSymbol: unique symbol;
8
9
  export declare const QueueSymbol: unique symbol;
9
10
  export declare const NodeSymbol: unique symbol;
10
- type Opaque<T, K> = T & {
11
- __opaque__: K;
12
- };
13
- export type IntegerNumber = Opaque<number, 'Int'>;
14
- export type FloatNumber = Opaque<number, 'Float'>;
15
- export type LavaSrcSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ymsearch";
16
- export type LavaSrcSearchPlatform = LavaSrcSearchPlatformBase | "ftts";
17
- export type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
18
- export type LavalinkClientSearchPlatform = "bcsearch";
19
- export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
20
- export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
21
- export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
22
- export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
23
- "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" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
24
- export type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
25
- 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" | "appleMusic" | "TwitchTv" | "vimeo";
26
- export interface PlaylistInfo {
27
- /** The playlist name */
28
- name: string;
29
- /** The playlist title (same as name) */
30
- title: string;
31
- /** The playlist Author */
32
- author?: string;
33
- /** The playlist Thumbnail */
34
- thumbnail?: string;
35
- /** A Uri to the playlist */
36
- uri?: string;
37
- /** The playlist selected track. */
38
- selectedTrack: Track | null;
39
- /** The duration of the entire playlist. (calcualted) */
40
- duration: number;
41
- }
42
- export interface SearchResult {
43
- loadType: LoadTypes;
44
- exception: Exception | null;
45
- pluginInfo: PluginInfo;
46
- playlist: PlaylistInfo | null;
47
- tracks: Track[];
48
- }
49
- export interface UnresolvedSearchResult {
50
- loadType: LoadTypes;
51
- exception: Exception | null;
52
- pluginInfo: PluginInfo;
53
- playlist: PlaylistInfo | null;
54
- tracks: UnresolvedTrack[];
55
- }
56
11
  /**
57
12
  * Parses Node Connection Url: "lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>"
58
13
  * @param connectionUrl
@@ -80,27 +35,28 @@ export declare class ManagerUtils {
80
35
  * @param data
81
36
  */
82
37
  isNode(data: LavalinkNode): boolean;
38
+ getTransformedRequester(requester: unknown): unknown;
83
39
  /**
84
40
  * Validate if a data is equal to node options
85
41
  * @param data
86
42
  */
87
- isNodeOptions(data: LavalinkNodeOptions | any): boolean;
43
+ isNodeOptions(data: LavalinkNodeOptions): boolean;
88
44
  /**
89
- * Validate if a data is euqal to a track
45
+ * Validate if a data is equal to a track
90
46
  * @param data the Track to validate
91
47
  * @returns
92
48
  */
93
- isTrack(data: Track | any): boolean;
49
+ isTrack(data: Track | UnresolvedTrack): data is Track;
94
50
  /**
95
51
  * Checks if the provided argument is a valid UnresolvedTrack.
96
52
  * @param track
97
53
  */
98
- isUnresolvedTrack(data: UnresolvedTrack | any): boolean;
54
+ isUnresolvedTrack(data: UnresolvedTrack | Track): data is UnresolvedTrack;
99
55
  /**
100
56
  * Checks if the provided argument is a valid UnresolvedTrack.
101
57
  * @param track
102
58
  */
103
- isUnresolvedTrackQuery(data: UnresolvedQuery | any): boolean;
59
+ isUnresolvedTrackQuery(data: UnresolvedQuery): boolean;
104
60
  getClosestTrack(data: UnresolvedTrack, player: Player): Promise<Track | undefined>;
105
61
  validateQueryString(node: LavalinkNode, queryString: string, sourceString?: LavalinkSearchPlatform): void;
106
62
  transformQuery(query: SearchQuery): {
@@ -115,16 +71,6 @@ export declare class ManagerUtils {
115
71
  };
116
72
  validateSourceString(node: LavalinkNode, sourceString: SearchPlatform): void;
117
73
  }
118
- /**
119
- * @internal
120
- */
121
- export interface MiniMapConstructor {
122
- new (): MiniMap<unknown, unknown>;
123
- new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): MiniMap<K, V>;
124
- new <K, V>(iterable: Iterable<readonly [K, V]>): MiniMap<K, V>;
125
- readonly prototype: MiniMap<unknown, unknown>;
126
- readonly [Symbol.species]: MiniMapConstructor;
127
- }
128
74
  /**
129
75
  * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
130
76
  *
@@ -134,7 +80,7 @@ export interface MiniMap<K, V> extends Map<K, V> {
134
80
  constructor: MiniMapConstructor;
135
81
  }
136
82
  export declare class MiniMap<K, V> extends Map<K, V> {
137
- constructor(data?: any[]);
83
+ constructor(data?: [K, V][]);
138
84
  /**
139
85
  * Identical to
140
86
  * [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
@@ -166,306 +112,4 @@ export declare class MiniMap<K, V> extends Map<K, V> {
166
112
  map<T>(fn: (value: V, key: K, miniMap: this) => T): T[];
167
113
  map<This, T>(fn: (this: This, value: V, key: K, miniMap: this) => T, thisArg: This): T[];
168
114
  }
169
- export type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents;
170
- export type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
171
- export interface Exception {
172
- /** Severity of the error */
173
- severity: Severity;
174
- /** Nodejs Error */
175
- error?: Error;
176
- /** Message by lavalink */
177
- message: string;
178
- /** Cause by lavalink */
179
- cause: string;
180
- }
181
- export interface PlayerEvent {
182
- op: "event";
183
- type: PlayerEventType;
184
- guildId: string;
185
- }
186
- export interface TrackStartEvent extends PlayerEvent {
187
- type: "TrackStartEvent";
188
- track: string;
189
- }
190
- export interface TrackEndEvent extends PlayerEvent {
191
- type: "TrackEndEvent";
192
- track: string;
193
- reason: TrackEndReason;
194
- }
195
- export interface TrackExceptionEvent extends PlayerEvent {
196
- type: "TrackExceptionEvent";
197
- exception?: Exception;
198
- error: string;
199
- }
200
- export interface TrackStuckEvent extends PlayerEvent {
201
- type: "TrackStuckEvent";
202
- thresholdMs: number;
203
- }
204
- export interface WebSocketClosedEvent extends PlayerEvent {
205
- type: "WebSocketClosedEvent";
206
- code: number;
207
- byRemote: boolean;
208
- reason: string;
209
- }
210
- /**
211
- * Types & Events for Sponsorblock-plugin from Lavalink: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
212
- */
213
- export type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
214
- export type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
215
- export interface SponsorBlockSegmentsLoaded extends PlayerEvent {
216
- type: "SegmentsLoaded";
217
- segments: {
218
- category: string;
219
- start: number;
220
- end: number;
221
- }[];
222
- }
223
- export interface SponsorBlockSegmentSkipped extends PlayerEvent {
224
- type: "SegmentSkipped";
225
- segment: {
226
- category: string;
227
- start: number;
228
- end: number;
229
- };
230
- }
231
- export interface SponsorBlockChapterStarted extends PlayerEvent {
232
- type: "ChapterStarted";
233
- /** The Chapter which started */
234
- chapter: {
235
- /** The Name of the Chapter */
236
- name: string;
237
- start: number;
238
- end: number;
239
- duration: number;
240
- };
241
- }
242
- export interface SponsorBlockChaptersLoaded extends PlayerEvent {
243
- type: "ChaptersLoaded";
244
- /** All Chapters loaded */
245
- chapters: {
246
- /** The Name of the Chapter */
247
- name: string;
248
- start: number;
249
- end: number;
250
- duration: number;
251
- }[];
252
- }
253
- export type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
254
- export type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
255
- export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType;
256
- export type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
257
- export interface InvalidLavalinkRestRequest {
258
- /** Rest Request Data for when it was made */
259
- timestamp: number;
260
- /** Status of the request */
261
- status: number;
262
- /** Specific Errro which was sent */
263
- error: string;
264
- /** Specific Message which was created */
265
- message?: string;
266
- /** The specific error trace from the request */
267
- trace?: unknown;
268
- /** Path of where it's from */
269
- path: string;
270
- }
271
- export interface LavalinkPlayerVoice {
272
- /** The Voice Token */
273
- token: string;
274
- /** The Voice Server Endpoint */
275
- endpoint: string;
276
- /** The Voice SessionId */
277
- sessionId: string;
278
- /** Wether or not the player is connected */
279
- connected?: boolean;
280
- /** The Ping to the voice server */
281
- ping?: number;
282
- }
283
- export interface LavalinkPlayerVoiceOptions extends Omit<LavalinkPlayerVoice, 'connected' | 'ping'> {
284
- }
285
- export interface FailingAddress {
286
- /** The failing address */
287
- failingAddress: string;
288
- /** The timestamp when the address failed */
289
- failingTimestamp: number;
290
- /** The timestamp when the address failed as a pretty string */
291
- failingTime: string;
292
- }
293
- type RoutePlannerTypes = "RotatingIpRoutePlanner" | "NanoIpRoutePlanner" | "RotatingNanoIpRoutePlanner" | "BalancingIpRoutePlanner";
294
- export interface RoutePlanner {
295
- class?: RoutePlannerTypes;
296
- details?: {
297
- /** The ip block being used */
298
- ipBlock: {
299
- /** The type of the ip block */
300
- type: "Inet4Address" | "Inet6Address";
301
- /** The size of the ip block */
302
- size: string;
303
- };
304
- /** The failing addresses */
305
- failingAddresses: FailingAddress[];
306
- /** The number of rotations */
307
- rotateIndex?: string;
308
- /** The current offset in the block */
309
- ipIndex?: string;
310
- /** The current address being used */
311
- currentAddress?: string;
312
- /** The current offset in the ip block */
313
- currentAddressIndex?: string;
314
- /** The information in which /64 block ips are chosen. This number increases on each ban. */
315
- blockIndex?: string;
316
- };
317
- }
318
- export interface Session {
319
- /** Wether or not session is resuming or not */
320
- resuming: boolean;
321
- /** For how long a session is lasting while not connected */
322
- timeout: number;
323
- }
324
- export interface GuildShardPayload {
325
- /** The OP code */
326
- op: number;
327
- /** Data to send */
328
- d: {
329
- /** Guild id to apply voice settings */
330
- guild_id: string;
331
- /** channel to move/connect to, or null to leave it */
332
- channel_id: string | null;
333
- /** wether or not mute yourself */
334
- self_mute: boolean;
335
- /** wether or not deafen yourself */
336
- self_deaf: boolean;
337
- };
338
- }
339
- export interface PlayerUpdateInfo {
340
- /** guild id of the player */
341
- guildId: string;
342
- /** Player options to provide to lavalink */
343
- playerOptions: LavalinkPlayOptions;
344
- /** Whether or not replace the current track with the new one (true is recommended) */
345
- noReplace?: boolean;
346
- }
347
- export interface LavalinkPlayer {
348
- /** Guild Id of the player */
349
- guildId: string;
350
- /** IF playing a track, all of the track information */
351
- track?: LavalinkTrack;
352
- /** Lavalink volume (mind volumedecrementer) */
353
- volume: number;
354
- /** Wether it's paused or not */
355
- paused: boolean;
356
- /** Voice Endpoint data */
357
- voice: LavalinkPlayerVoice;
358
- /** All Audio Filters */
359
- filters: Partial<LavalinkFilterData>;
360
- /** Lavalink-Voice-State Variables */
361
- state: {
362
- /** Time since connection established */
363
- time: number;
364
- /** Position of the track */
365
- position: number;
366
- /** COnnected or not */
367
- connected: boolean;
368
- /** Ping to voice server */
369
- ping: number;
370
- };
371
- }
372
- export interface ChannelDeletePacket {
373
- /** Packet key for channel delete */
374
- t: "CHANNEL_DELETE";
375
- /** data which is sent and relevant */
376
- d: {
377
- /** guild id */
378
- guild_id: string;
379
- /** Channel id */
380
- id: string;
381
- };
382
- }
383
- export interface VoiceState {
384
- /** OP key from lavalink */
385
- op: "voiceUpdate";
386
- /** GuildId provided by lavalink */
387
- guildId: string;
388
- /** Event data */
389
- event: VoiceServer;
390
- /** Session Id of the voice connection */
391
- sessionId?: string;
392
- /** guild id of the voice channel */
393
- guild_id: string;
394
- /** user id from the voice connection */
395
- user_id: string;
396
- /** Session Id of the voice connection */
397
- session_id: string;
398
- /** Voice Channel Id */
399
- channel_id: string;
400
- }
401
- /** The Base64 decodes tring by lavalink */
402
- export type Base64 = string;
403
- export interface VoiceServer {
404
- /** Voice Token */
405
- token: string;
406
- /** Guild Id of the voice server connection */
407
- guild_id: string;
408
- /** Server Endpoint */
409
- endpoint: string;
410
- }
411
- export interface VoicePacket {
412
- /** Voice Packet Keys to send */
413
- t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
414
- /** Voice Packets to send */
415
- d: VoiceState | VoiceServer;
416
- }
417
- export interface NodeMessage extends NodeStats {
418
- /** The type of the event */
419
- type: PlayerEventType;
420
- /** what ops are applying to that event */
421
- op: "stats" | "playerUpdate" | "event";
422
- /** The specific guild id for that message */
423
- guildId: string;
424
- }
425
115
  export declare function queueTrackEnd(player: Player): Promise<Track>;
426
- /** Specific types to filter for lavasearch, will be filtered to correct types */
427
- export type LavaSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
428
- export interface LavaSearchFilteredResponse {
429
- /** The Information of a playlist provided by lavasearch */
430
- info: PlaylistInfo;
431
- /** additional plugin information */
432
- pluginInfo: PluginInfo;
433
- /** List of tracks */
434
- tracks: Track[];
435
- }
436
- export interface LavaSearchResponse {
437
- /** An array of tracks, only present if track is in types */
438
- tracks: Track[];
439
- /** An array of albums, only present if album is in types */
440
- albums: LavaSearchFilteredResponse[];
441
- /** An array of artists, only present if artist is in types */
442
- artists: LavaSearchFilteredResponse[];
443
- /** An array of playlists, only present if playlist is in types */
444
- playlists: LavaSearchFilteredResponse[];
445
- /** An array of text results, only present if text is in types */
446
- texts: {
447
- text: string;
448
- pluginInfo: PluginInfo;
449
- }[];
450
- /** Addition result data provided by plugins */
451
- pluginInfo: PluginInfo;
452
- }
453
- /** SearchQuery Object for raw lavalink requests */
454
- export type SearchQuery = {
455
- /** lavalink search Query / identifier string */
456
- query: string;
457
- /** Extra url query params to use, e.g. for flowertts */
458
- extraQueryUrlParams?: URLSearchParams;
459
- /** Source to append to the search query string */
460
- source?: SearchPlatform;
461
- } | /** Our just the search query / identifier string */ string;
462
- /** SearchQuery Object for Lavalink LavaSearch Plugin requests */
463
- export type LavaSearchQuery = {
464
- /** lavalink search Query / identifier string */
465
- query: string;
466
- /** Source to append to the search query string */
467
- source: LavaSrcSearchPlatformBase;
468
- /** The Types to filter the search to */
469
- types?: LavaSearchType[];
470
- };
471
- export {};
@@ -44,13 +44,19 @@ class ManagerUtils {
44
44
  if (!data.info)
45
45
  throw new RangeError("Argument 'data.info' must be present.");
46
46
  try {
47
+ let transformedRequester = typeof requester === "object"
48
+ ? this.getTransformedRequester(requester)
49
+ : undefined;
50
+ if (!transformedRequester && typeof data?.userData?.requester === "object" && data.userData.requester !== null) {
51
+ transformedRequester = this.getTransformedRequester(data.userData.requester);
52
+ }
47
53
  const r = {
48
54
  encoded: data.encoded,
49
55
  info: {
50
56
  identifier: data.info.identifier,
51
57
  title: data.info.title,
52
58
  author: data.info.author,
53
- duration: data.info.duration || data.info.length,
59
+ duration: data.info?.duration || data.info?.length,
54
60
  artworkUrl: data.info.artworkUrl || data.pluginInfo?.artworkUrl || data.plugin?.artworkUrl,
55
61
  uri: data.info.uri,
56
62
  sourceName: data.info.sourceName,
@@ -58,8 +64,12 @@ class ManagerUtils {
58
64
  isStream: data.info.isStream,
59
65
  isrc: data.info.isrc,
60
66
  },
61
- pluginInfo: this.buildPluginInfo(data),
62
- requester: typeof this.LavalinkManager?.options?.playerOptions?.requesterTransformer === "function" ? this.LavalinkManager?.options?.playerOptions?.requesterTransformer(data?.requester || requester) : requester,
67
+ userData: {
68
+ ...(data.userData || {}),
69
+ requester: transformedRequester
70
+ },
71
+ pluginInfo: this.buildPluginInfo(data, "clientData" in data ? data.clientData : {}),
72
+ requester: transformedRequester || this.getTransformedRequester(this.LavalinkManager?.options?.client),
63
73
  };
64
74
  Object.defineProperty(r, exports.TrackSymbol, { configurable: true, value: true });
65
75
  return r;
@@ -80,7 +90,7 @@ class ManagerUtils {
80
90
  encoded: query.encoded || undefined,
81
91
  info: query.info ? query.info : query.title ? query : undefined,
82
92
  pluginInfo: this.buildPluginInfo(query),
83
- requester: typeof this.LavalinkManager?.options?.playerOptions?.requesterTransformer === "function" ? this.LavalinkManager?.options?.playerOptions?.requesterTransformer((query?.requester || requester)) : requester,
93
+ requester: this.getTransformedRequester(requester),
84
94
  async resolve(player) {
85
95
  const closest = await getClosestTrack(this, player);
86
96
  if (!closest)
@@ -116,6 +126,17 @@ class ManagerUtils {
116
126
  return false;
117
127
  return true;
118
128
  }
129
+ getTransformedRequester(requester) {
130
+ try {
131
+ return typeof this.LavalinkManager?.options?.playerOptions?.requesterTransformer === "function"
132
+ ? this.LavalinkManager?.options?.playerOptions?.requesterTransformer(requester)
133
+ : requester;
134
+ }
135
+ catch (e) {
136
+ console.error("errored while transforming requester:", e);
137
+ return requester;
138
+ }
139
+ }
119
140
  /**
120
141
  * Validate if a data is equal to node options
121
142
  * @param data
@@ -129,26 +150,26 @@ class ManagerUtils {
129
150
  return false;
130
151
  if (typeof data.authorization !== "string" || !data.authorization.length)
131
152
  return false;
132
- if ("secure" in data && typeof data.secure !== "boolean")
153
+ if ("secure" in data && typeof data.secure !== "boolean" && data.secure !== undefined)
133
154
  return false;
134
- if ("sessionId" in data && typeof data.sessionId !== "string")
155
+ if ("sessionId" in data && typeof data.sessionId !== "string" && data.sessionId !== undefined)
135
156
  return false;
136
- if ("id" in data && typeof data.id !== "string")
157
+ if ("id" in data && typeof data.id !== "string" && data.id !== undefined)
137
158
  return false;
138
- if ("regions" in data && (!Array.isArray(data.regions) || !data.regions.every(v => typeof v === "string")))
159
+ if ("regions" in data && (!Array.isArray(data.regions) || !data.regions.every(v => typeof v === "string") && data.regions !== undefined))
139
160
  return false;
140
- if ("poolOptions" in data && typeof data.poolOptions !== "object")
161
+ if ("poolOptions" in data && typeof data.poolOptions !== "object" && data.poolOptions !== undefined)
141
162
  return false;
142
- if ("retryAmount" in data && (typeof data.retryAmount !== "number" || isNaN(data.retryAmount) || data.retryAmount <= 0))
163
+ if ("retryAmount" in data && (typeof data.retryAmount !== "number" || isNaN(data.retryAmount) || data.retryAmount <= 0 && data.retryAmount !== undefined))
143
164
  return false;
144
- if ("retryDelay" in data && (typeof data.retryDelay !== "number" || isNaN(data.retryDelay) || data.retryDelay <= 0))
165
+ if ("retryDelay" in data && (typeof data.retryDelay !== "number" || isNaN(data.retryDelay) || data.retryDelay <= 0 && data.retryDelay !== undefined))
145
166
  return false;
146
- if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0))
167
+ if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== undefined))
147
168
  return false;
148
169
  return true;
149
170
  }
150
171
  /**
151
- * Validate if a data is euqal to a track
172
+ * Validate if a data is equal to a track
152
173
  * @param data the Track to validate
153
174
  * @returns
154
175
  */
@@ -168,7 +189,7 @@ class ManagerUtils {
168
189
  return false;
169
190
  if (data[exports.UnresolvedTrackSymbol] === true)
170
191
  return true;
171
- return typeof data === "object" && (("info" in data && typeof data.info.title === "string") || typeof data.encoded === "string") && typeof data.resolve === "function";
192
+ return typeof data === "object" && (("info" in data && typeof data.info.title === "string") || typeof data.encoded === "string") && "resolve" in data && typeof data.resolve === "function";
172
193
  }
173
194
  /**
174
195
  * Checks if the provided argument is a valid UnresolvedTrack.
@@ -345,10 +366,11 @@ class MiniMap extends Map {
345
366
  }
346
367
  exports.MiniMap = MiniMap;
347
368
  async function queueTrackEnd(player) {
348
- if (player.queue.current) { // if there was a current Track -> Add it
369
+ if (player.queue.current && !player.queue.current?.pluginInfo?.clientData?.previousTrack) { // If there was a current Track already and repeatmode === true, add it to the queue.
349
370
  player.queue.previous.unshift(player.queue.current);
350
371
  if (player.queue.previous.length > player.queue.options.maxPreviousTracks)
351
372
  player.queue.previous.splice(player.queue.options.maxPreviousTracks, player.queue.previous.length);
373
+ await player.queue.utils.save();
352
374
  }
353
375
  // and if repeatMode == queue, add it back to the queue!
354
376
  if (player.repeatMode === "queue" && player.queue.current)
@@ -378,11 +400,11 @@ async function applyUnresolvedData(resTrack, data, utils) {
378
400
  resTrack.info.author = data.info.author;
379
401
  }
380
402
  else { // only overwrite if undefined / invalid
381
- if ((resTrack.info.title == 'Unknown title' || resTrack.info.title == "Unspecified description") && resTrack.info.title != data.info.title)
403
+ if ((resTrack.info.title === 'Unknown title' || resTrack.info.title === "Unspecified description") && resTrack.info.title != data.info.title)
382
404
  resTrack.info.title = data.info.title;
383
- if (resTrack.info.author != data.info.author)
405
+ if (resTrack.info.author !== data.info.author)
384
406
  resTrack.info.author = data.info.author;
385
- if (resTrack.info.artworkUrl != data.info.artworkUrl)
407
+ if (resTrack.info.artworkUrl !== data.info.artworkUrl)
386
408
  resTrack.info.artworkUrl = data.info.artworkUrl;
387
409
  }
388
410
  for (const key of Object.keys(data.info))
@@ -5,5 +5,11 @@ export * from "./structures/Node";
5
5
  export * from "./structures/NodeManager";
6
6
  export * from "./structures/Player";
7
7
  export * from "./structures/Queue";
8
- export * from "./structures/Track";
9
8
  export * from "./structures/Utils";
9
+ export * from "./structures/Types/Track";
10
+ export * from "./structures/Types/Utils";
11
+ export * from "./structures/Types/Filters";
12
+ export * from "./structures/Types/Player";
13
+ export * from "./structures/Types/Queue";
14
+ export * from "./structures/Types/Node";
15
+ export * from "./structures/Constants";
package/dist/esm/index.js CHANGED
@@ -5,5 +5,11 @@ export * from "./structures/Node";
5
5
  export * from "./structures/NodeManager";
6
6
  export * from "./structures/Player";
7
7
  export * from "./structures/Queue";
8
- export * from "./structures/Track";
9
8
  export * from "./structures/Utils";
9
+ export * from "./structures/Types/Track";
10
+ export * from "./structures/Types/Utils";
11
+ export * from "./structures/Types/Filters";
12
+ export * from "./structures/Types/Player";
13
+ export * from "./structures/Types/Queue";
14
+ export * from "./structures/Types/Node";
15
+ export * from "./structures/Constants";
@@ -0,0 +1,40 @@
1
+ import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters";
2
+ export declare enum DestroyReasons {
3
+ QueueEmpty = "QueueEmpty",
4
+ NodeDestroy = "NodeDestroy",
5
+ NodeDeleted = "NodeDeleted",
6
+ LavalinkNoVoice = "LavalinkNoVoice",
7
+ NodeReconnectFail = "NodeReconnectFail",
8
+ Disconnected = "Disconnected",
9
+ PlayerReconnectFail = "PlayerReconnectFail",
10
+ ChannelDeleted = "ChannelDeleted",
11
+ DisconnectAllNodes = "DisconnectAllNodes",
12
+ ReconnectAllNodes = "ReconnectAllNodes"
13
+ }
14
+ export declare const validSponsorBlocks: string[];
15
+ /** The audio Outputs Data map declaration */
16
+ export declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
17
+ export declare const EQList: {
18
+ /** A Bassboost Equalizer, so high it distorts the audio */
19
+ BassboostEarrape: EQBand[];
20
+ /** A High and decent Bassboost Equalizer */
21
+ BassboostHigh: EQBand[];
22
+ /** A decent Bassboost Equalizer */
23
+ BassboostMedium: EQBand[];
24
+ /** A slight Bassboost Equalizer */
25
+ BassboostLow: EQBand[];
26
+ /** Makes the Music slightly "better" */
27
+ BetterMusic: EQBand[];
28
+ /** Makes the Music sound like rock music / sound rock music better */
29
+ Rock: EQBand[];
30
+ /** Makes the Music sound like Classic music / sound Classic music better */
31
+ Classic: EQBand[];
32
+ /** Makes the Music sound like Pop music / sound Pop music better */
33
+ Pop: EQBand[];
34
+ /** Makes the Music sound like Electronic music / sound Electronic music better */
35
+ Electronic: EQBand[];
36
+ /** Boosts all Bands slightly for louder and fuller sound */
37
+ FullSound: EQBand[];
38
+ /** Boosts basses + lower highs for a pro gaming sound */
39
+ Gaming: EQBand[];
40
+ };