lavalink-client 2.3.5 → 2.4.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 (62) hide show
  1. package/README.md +73 -6
  2. package/dist/cjs/structures/Constants.d.ts +4 -0
  3. package/dist/cjs/structures/Constants.js +7 -2
  4. package/dist/cjs/structures/Filters.d.ts +24 -0
  5. package/dist/cjs/structures/Filters.js +34 -10
  6. package/dist/cjs/structures/LavalinkManager.d.ts +4 -5
  7. package/dist/cjs/structures/LavalinkManager.js +36 -14
  8. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +2 -0
  9. package/dist/cjs/structures/LavalinkManagerStatics.js +11 -2
  10. package/dist/cjs/structures/Node.d.ts +107 -13
  11. package/dist/cjs/structures/Node.js +294 -76
  12. package/dist/cjs/structures/NodeManager.d.ts +2 -2
  13. package/dist/cjs/structures/NodeManager.js +19 -19
  14. package/dist/cjs/structures/Player.d.ts +51 -1
  15. package/dist/cjs/structures/Player.js +62 -0
  16. package/dist/cjs/structures/Queue.d.ts +9 -10
  17. package/dist/cjs/structures/Queue.js +3 -3
  18. package/dist/cjs/structures/Types/Manager.d.ts +59 -1
  19. package/dist/cjs/structures/Types/Node.d.ts +23 -1
  20. package/dist/cjs/structures/Types/Player.d.ts +5 -1
  21. package/dist/cjs/structures/Types/Queue.d.ts +6 -6
  22. package/dist/cjs/structures/Types/Track.d.ts +3 -1
  23. package/dist/cjs/structures/Types/Utils.d.ts +81 -8
  24. package/dist/cjs/structures/Utils.js +11 -9
  25. package/dist/esm/structures/Constants.d.ts +4 -0
  26. package/dist/esm/structures/Constants.js +6 -1
  27. package/dist/esm/structures/Filters.d.ts +24 -0
  28. package/dist/esm/structures/Filters.js +34 -10
  29. package/dist/esm/structures/LavalinkManager.d.ts +4 -5
  30. package/dist/esm/structures/LavalinkManager.js +36 -14
  31. package/dist/esm/structures/LavalinkManagerStatics.d.ts +2 -0
  32. package/dist/esm/structures/LavalinkManagerStatics.js +11 -2
  33. package/dist/esm/structures/Node.d.ts +107 -13
  34. package/dist/esm/structures/Node.js +294 -76
  35. package/dist/esm/structures/NodeManager.d.ts +2 -2
  36. package/dist/esm/structures/NodeManager.js +20 -20
  37. package/dist/esm/structures/Player.d.ts +51 -1
  38. package/dist/esm/structures/Player.js +62 -0
  39. package/dist/esm/structures/Queue.d.ts +9 -10
  40. package/dist/esm/structures/Queue.js +3 -3
  41. package/dist/esm/structures/Types/Manager.d.ts +59 -1
  42. package/dist/esm/structures/Types/Node.d.ts +23 -1
  43. package/dist/esm/structures/Types/Player.d.ts +5 -1
  44. package/dist/esm/structures/Types/Queue.d.ts +6 -6
  45. package/dist/esm/structures/Types/Track.d.ts +3 -1
  46. package/dist/esm/structures/Types/Utils.d.ts +81 -8
  47. package/dist/esm/structures/Utils.js +8 -6
  48. package/dist/types/structures/Constants.d.ts +4 -0
  49. package/dist/types/structures/Filters.d.ts +24 -0
  50. package/dist/types/structures/LavalinkManager.d.ts +4 -5
  51. package/dist/types/structures/LavalinkManagerStatics.d.ts +2 -0
  52. package/dist/types/structures/Node.d.ts +107 -13
  53. package/dist/types/structures/NodeManager.d.ts +2 -2
  54. package/dist/types/structures/Player.d.ts +51 -1
  55. package/dist/types/structures/Queue.d.ts +9 -10
  56. package/dist/types/structures/Types/Manager.d.ts +59 -1
  57. package/dist/types/structures/Types/Node.d.ts +23 -1
  58. package/dist/types/structures/Types/Player.d.ts +5 -1
  59. package/dist/types/structures/Types/Queue.d.ts +6 -6
  60. package/dist/types/structures/Types/Track.d.ts +3 -1
  61. package/dist/types/structures/Types/Utils.d.ts +81 -8
  62. package/package.json +29 -18
@@ -1,9 +1,9 @@
1
1
  import type { Player } from "./Player.js";
2
- import type { DestroyReasonsType } from "./Types/Player.js";
2
+ import type { DestroyReasonsType, DisconnectReasonsType } from "./Types/Player.js";
3
3
  import type { Track } from "./Types/Track.js";
4
4
  import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils.js";
5
5
  import type { NodeManager } from "./NodeManager.js";
6
- import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node.js";
6
+ import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, LyricsResult, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node.js";
7
7
  /**
8
8
  * Lavalink Node creator class
9
9
  */
@@ -13,6 +13,7 @@ export declare class LavalinkNode {
13
13
  get heartBeatPing(): number;
14
14
  private heartBeatInterval?;
15
15
  private pingTimeout?;
16
+ isAlive: boolean;
16
17
  /** The provided Options of the Node */
17
18
  options: LavalinkNodeOptions;
18
19
  /** The amount of rest calls the node has made. */
@@ -88,7 +89,8 @@ export declare class LavalinkNode {
88
89
  * player.node.request(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET", false);
89
90
  * ```
90
91
  */
91
- request(endpoint: string, modify?: ModifyRequest, parseAsText?: boolean): Promise<any>;
92
+ request(endpoint: string, modify: ModifyRequest | undefined, parseAsText: true): Promise<string>;
93
+ request(endpoint: string, modify?: ModifyRequest, parseAsText?: false): Promise<any>;
92
94
  /**
93
95
  * Search something raw on the node, please note only add tracks to players of that node
94
96
  * @param query SearchQuery Object
@@ -109,7 +111,7 @@ export declare class LavalinkNode {
109
111
  * @param query LavaSearchQuery Object
110
112
  * @param requestUser Request User for creating the player(s)
111
113
  * @param throwOnEmpty Wether to throw on an empty result or not
112
- * @returns LavaSearchresult
114
+ * @returns LavaSearchresult (SearchResult if link is provided)
113
115
  *
114
116
  * @example
115
117
  * ```ts
@@ -117,7 +119,7 @@ export declare class LavalinkNode {
117
119
  * player.node.lavaSearch({ types: ["playlist", "album"], query: "Rick Astley", source: "spotify" }, interaction.user);
118
120
  * ```
119
121
  */
120
- lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult | LavaSearchResponse>;
122
+ lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<LavaSearchResponse | SearchResult>;
121
123
  /**
122
124
  * Update the Player State on the Lavalink Server
123
125
  * @param data data to send to lavalink and sync locally
@@ -141,7 +143,7 @@ export declare class LavalinkNode {
141
143
  * player.node.destroyPlayer(player.guildId);
142
144
  * ```
143
145
  */
144
- destroyPlayer(guildId: any): Promise<any>;
146
+ destroyPlayer(guildId: any): Promise<void>;
145
147
  /**
146
148
  * Connect to the Lavalink Node
147
149
  * @param sessionId Provide the Session Id of the previous connection, to resume the node and it's player(s)
@@ -169,7 +171,7 @@ export declare class LavalinkNode {
169
171
  get id(): string;
170
172
  /**
171
173
  * Destroys the Node-Connection (Websocket) and all player's of the node
172
- * @param destroyReason Destroyreason to use when destroying the players
174
+ * @param destroyReason Destroy Reason to use when destroying the players
173
175
  * @param deleteNode wether to delete the nodte from the nodes list too, if false it will emit a disconnect. @default true
174
176
  * @returns void
175
177
  *
@@ -179,6 +181,19 @@ export declare class LavalinkNode {
179
181
  * ```
180
182
  */
181
183
  destroy(destroyReason?: DestroyReasonsType, deleteNode?: boolean): void;
184
+ /**
185
+ * Disconnects the Node-Connection (Websocket)
186
+ * @param disconnectReason Disconnect Reason to use when disconnecting Node
187
+ * @returns void
188
+ *
189
+ * Also the node will not get re-connected again.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * player.node.destroy("custom Player Destroy Reason", true);
194
+ * ```
195
+ */
196
+ disconnect(disconnectReason?: DisconnectReasonsType): void;
182
197
  /**
183
198
  * Returns if connected to the Node.
184
199
  *
@@ -189,7 +204,6 @@ export declare class LavalinkNode {
189
204
  * ```
190
205
  */
191
206
  get connected(): boolean;
192
- isAlive: boolean;
193
207
  /**
194
208
  * Returns the current ConnectionStatus
195
209
  *
@@ -214,7 +228,7 @@ export declare class LavalinkNode {
214
228
  * const playersOfLavalink = await node?.fetchAllPlayers();
215
229
  * ```
216
230
  */
217
- fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest>;
231
+ fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest | null>;
218
232
  /**
219
233
  * Gets specific Player Information
220
234
  * @returns lavalink player object if player exists on lavalink
@@ -225,7 +239,7 @@ export declare class LavalinkNode {
225
239
  * const playerInformation = await node?.fetchPlayer("guildId");
226
240
  * ```
227
241
  */
228
- fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest>;
242
+ fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest | null>;
229
243
  /**
230
244
  * Updates the session with and enables/disables resuming and timeout
231
245
  * @param resuming Whether resuming is enabled for this session or not
@@ -238,7 +252,7 @@ export declare class LavalinkNode {
238
252
  * await node?.updateSession(true, 180e3); // will enable resuming for 180seconds
239
253
  * ```
240
254
  */
241
- updateSession(resuming?: boolean, timeout?: number): Promise<InvalidLavalinkRestRequest | Session>;
255
+ updateSession(resuming?: boolean, timeout?: number): Promise<Session | InvalidLavalinkRestRequest | null>;
242
256
  /**
243
257
  * Decode Track or Tracks
244
258
  */
@@ -271,6 +285,62 @@ export declare class LavalinkNode {
271
285
  */
272
286
  multipleTracks: (encodeds: Base64[], requester: unknown) => Promise<Track[]>;
273
287
  };
288
+ lyrics: {
289
+ /**
290
+ * Get the lyrics of a track
291
+ * @param track the track to get the lyrics for
292
+ * @param skipTrackSource wether to skip the track source or not
293
+ * @returns the lyrics of the track
294
+ * @example
295
+ *
296
+ * ```ts
297
+ * const lyrics = await player.node.lyrics.get(track, true);
298
+ * // use it of player instead:
299
+ * // const lyrics = await player.getLyrics(track, true);
300
+ * ```
301
+ */
302
+ get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
303
+ /**
304
+ * Get the lyrics of the current playing track
305
+ *
306
+ * @param guildId the guild id of the player
307
+ * @param skipTrackSource wether to skip the track source or not
308
+ * @returns the lyrics of the current playing track
309
+ * @example
310
+ * ```ts
311
+ * const lyrics = await player.node.lyrics.getCurrent(guildId);
312
+ * // use it of player instead:
313
+ * // const lyrics = await player.getCurrentLyrics();
314
+ * ```
315
+ */
316
+ getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
317
+ /**
318
+ * subscribe to lyrics updates for a guild
319
+ * @param guildId the guild id of the player
320
+ * @returns request data of the request
321
+ *
322
+ * @example
323
+ * ```ts
324
+ * await player.node.lyrics.subscribe(guildId);
325
+ * // use it of player instead:
326
+ * // const lyrics = await player.subscribeLyrics();
327
+ * ```
328
+ */
329
+ subscribe: (guildId: string) => Promise<unknown>;
330
+ /**
331
+ * unsubscribe from lyrics updates for a guild
332
+ * @param guildId the guild id of the player
333
+ * @returns request data of the request
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * await player.node.lyrics.unsubscribe(guildId);
338
+ * // use it of player instead:
339
+ * // const lyrics = await player.unsubscribeLyrics();
340
+ * ```
341
+ */
342
+ unsubscribe: (guildId: string) => Promise<void>;
343
+ };
274
344
  /**
275
345
  * Request Lavalink statistics.
276
346
  * @returns the lavalink node stats
@@ -329,7 +399,7 @@ export declare class LavalinkNode {
329
399
  * await player.node.routePlannerApi.unmarkFailedAddress("ipv6address");
330
400
  * ```
331
401
  */
332
- unmarkFailedAddress: (address: string) => Promise<void>;
402
+ unmarkFailedAddress: (address: string) => Promise<unknown>;
333
403
  /**
334
404
  * Release all blacklisted IP addresses into pool of IPs
335
405
  * @returns request data of the request
@@ -339,7 +409,7 @@ export declare class LavalinkNode {
339
409
  * await player.node.routePlannerApi.unmarkAllFailedAddresses();
340
410
  * ```
341
411
  */
342
- unmarkAllFailedAddresses: () => Promise<any>;
412
+ unmarkAllFailedAddresses: () => Promise<unknown>;
343
413
  };
344
414
  /** @private Utils for validating the */
345
415
  private validate;
@@ -432,4 +502,28 @@ export declare class LavalinkNode {
432
502
  deleteSponsorBlock(player: Player): Promise<void>;
433
503
  /** private util function for handling the queue end event */
434
504
  private queueEnd;
505
+ /**
506
+ * Emitted whenever a line of lyrics gets emitted
507
+ * @event
508
+ * @param {Player} player The player that emitted the event
509
+ * @param {Track} track The track that emitted the event
510
+ * @param {LyricsLineEvent} payload The payload of the event
511
+ */
512
+ private LyricsLine;
513
+ /**
514
+ * Emitted whenever the lyrics for a track got found
515
+ * @event
516
+ * @param {Player} player The player that emitted the event
517
+ * @param {Track} track The track that emitted the event
518
+ * @param {LyricsFoundEvent} payload The payload of the event
519
+ */
520
+ private LyricsFound;
521
+ /**
522
+ * Emitted whenever the lyrics for a track got not found
523
+ * @event
524
+ * @param {Player} player The player that emitted the event
525
+ * @param {Track} track The track that emitted the event
526
+ * @param {LyricsNotFoundEvent} payload The payload of the event
527
+ */
528
+ private LyricsNotFound;
435
529
  }