lavalink-client 2.1.7 → 2.2.1

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 (39) hide show
  1. package/README.md +87 -1
  2. package/dist/cjs/structures/CustomSearches/BandCampSearch.js +3 -2
  3. package/dist/cjs/structures/Filters.d.ts +1 -1
  4. package/dist/cjs/structures/Filters.js +5 -5
  5. package/dist/cjs/structures/LavalinkManager.d.ts +23 -5
  6. package/dist/cjs/structures/LavalinkManager.js +15 -1
  7. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +3 -0
  8. package/dist/cjs/structures/LavalinkManagerStatics.js +8 -1
  9. package/dist/cjs/structures/Node.d.ts +317 -35
  10. package/dist/cjs/structures/Node.js +330 -85
  11. package/dist/cjs/structures/NodeManager.d.ts +1 -1
  12. package/dist/cjs/structures/Player.d.ts +44 -8
  13. package/dist/cjs/structures/Player.js +35 -27
  14. package/dist/cjs/structures/Queue.js +1 -1
  15. package/dist/cjs/structures/Utils.d.ts +5 -2
  16. package/dist/cjs/structures/Utils.js +7 -4
  17. package/dist/esm/structures/CustomSearches/BandCampSearch.js +2 -1
  18. package/dist/esm/structures/Filters.d.ts +1 -1
  19. package/dist/esm/structures/Filters.js +5 -5
  20. package/dist/esm/structures/LavalinkManager.d.ts +23 -5
  21. package/dist/esm/structures/LavalinkManager.js +15 -1
  22. package/dist/esm/structures/LavalinkManagerStatics.d.ts +3 -0
  23. package/dist/esm/structures/LavalinkManagerStatics.js +8 -1
  24. package/dist/esm/structures/Node.d.ts +317 -35
  25. package/dist/esm/structures/Node.js +330 -85
  26. package/dist/esm/structures/NodeManager.d.ts +1 -1
  27. package/dist/esm/structures/Player.d.ts +44 -8
  28. package/dist/esm/structures/Player.js +35 -27
  29. package/dist/esm/structures/Queue.js +1 -1
  30. package/dist/esm/structures/Utils.d.ts +5 -2
  31. package/dist/esm/structures/Utils.js +7 -4
  32. package/dist/types/structures/Filters.d.ts +1 -1
  33. package/dist/types/structures/LavalinkManager.d.ts +23 -5
  34. package/dist/types/structures/LavalinkManagerStatics.d.ts +3 -0
  35. package/dist/types/structures/Node.d.ts +317 -35
  36. package/dist/types/structures/NodeManager.d.ts +1 -1
  37. package/dist/types/structures/Player.d.ts +44 -8
  38. package/dist/types/structures/Utils.d.ts +5 -2
  39. package/package.json +5 -4
@@ -1,14 +1,19 @@
1
1
  /// <reference types="node" />
2
2
  import internal from "stream";
3
- import { Dispatcher, Pool } from "undici";
4
3
  import { NodeManager } from "./NodeManager";
5
4
  import { DestroyReasonsType, Player } from "./Player";
6
5
  import { Track } from "./Track";
7
6
  import { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Utils";
8
- /** Modifies any outgoing REST requests. */
9
- export type ModifyRequest = (options: Dispatcher.RequestOptions) => void;
7
+ /** Ability to manipulate fetch requests */
8
+ export type ModifyRequest = (options: RequestInit & {
9
+ path: string;
10
+ extraQueryUrlParams?: URLSearchParams;
11
+ }) => void;
10
12
  export declare const validSponsorBlocks: string[];
11
13
  export type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
14
+ /**
15
+ * Node Options for creating a lavalink node
16
+ */
12
17
  export interface LavalinkNodeOptions {
13
18
  /** The Lavalink Server-Ip / Domain-URL */
14
19
  host: string;
@@ -24,15 +29,16 @@ export interface LavalinkNodeOptions {
24
29
  id?: string;
25
30
  /** Voice Regions of this Node */
26
31
  regions?: string[];
27
- /** Options for the undici http pool used for http requests */
28
- poolOptions?: Pool.Options;
29
32
  /** The retryAmount for the node. */
30
33
  retryAmount?: number;
31
34
  /** The retryDelay for the node. */
32
35
  retryDelay?: number;
33
- /** Pool Undici Options - requestTimeout */
34
- requestTimeout?: number;
36
+ /** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
37
+ requestSignalTimeoutMS?: number;
35
38
  }
39
+ /**
40
+ * Memory Stats object from lavalink
41
+ */
36
42
  export interface MemoryStats {
37
43
  /** The free memory of the allocated amount. */
38
44
  free: number;
@@ -43,6 +49,9 @@ export interface MemoryStats {
43
49
  /** The reservable memory. */
44
50
  reservable: number;
45
51
  }
52
+ /**
53
+ * CPU Stats object from lavalink
54
+ */
46
55
  export interface CPUStats {
47
56
  /** The core amount the host machine has. */
48
57
  cores: number;
@@ -51,6 +60,9 @@ export interface CPUStats {
51
60
  /** The lavalink load. */
52
61
  lavalinkLoad: number;
53
62
  }
63
+ /**
64
+ * FrameStats Object from lavalink
65
+ */
54
66
  export interface FrameStats {
55
67
  /** The amount of sent frames. */
56
68
  sent?: number;
@@ -59,6 +71,9 @@ export interface FrameStats {
59
71
  /** The amount of deficit frames. */
60
72
  deficit?: number;
61
73
  }
74
+ /**
75
+ * BaseNodeStats object from Lavalink
76
+ */
62
77
  export interface BaseNodeStats {
63
78
  /** The amount of players on the node. */
64
79
  players: number;
@@ -73,10 +88,16 @@ export interface BaseNodeStats {
73
88
  /** The frame stats for the node. */
74
89
  frameStats: FrameStats;
75
90
  }
91
+ /**
92
+ * Interface for nodeStats from lavalink
93
+ */
76
94
  export interface NodeStats extends BaseNodeStats {
77
95
  /** The frame stats for the node. */
78
96
  frameStats: FrameStats;
79
97
  }
98
+ /**
99
+ * Entire lavalink information object from lavalink
100
+ */
80
101
  export interface LavalinkInfo {
81
102
  /** The version of this Lavalink server */
82
103
  version: VersionObject;
@@ -95,6 +116,9 @@ export interface LavalinkInfo {
95
116
  /** The enabled plugins for this server */
96
117
  plugins: PluginObject[];
97
118
  }
119
+ /**
120
+ * Lavalink's version object from lavalink
121
+ */
98
122
  export interface VersionObject {
99
123
  /** The full version string of this Lavalink server */
100
124
  semver: string;
@@ -109,6 +133,9 @@ export interface VersionObject {
109
133
  /** The build metadata according to semver as a . separated list of identifiers */
110
134
  build?: string;
111
135
  }
136
+ /**
137
+ * Git information object from lavalink
138
+ */
112
139
  export interface GitObject {
113
140
  /** The branch this Lavalink server was built on */
114
141
  branch: string;
@@ -117,18 +144,26 @@ export interface GitObject {
117
144
  /** The millisecond unix timestamp for when the commit was created */
118
145
  commitTime: string;
119
146
  }
147
+ /**
148
+ * Lavalink's plugins object from lavalink's plugin
149
+ */
120
150
  export interface PluginObject {
121
151
  /** The name of the plugin */
122
152
  name: string;
123
153
  /** The version of the plugin */
124
154
  version: string;
125
155
  }
156
+ /**
157
+ * Lavalink Node creator class
158
+ */
126
159
  export declare class LavalinkNode {
127
160
  /** The provided Options of the Node */
128
161
  options: LavalinkNodeOptions;
129
162
  /** The amount of rest calls the node has made. */
130
163
  calls: number;
164
+ /** Stats from lavalink, will be updated via an interval by lavalink. */
131
165
  stats: NodeStats;
166
+ /** The current sessionId, only present when connected */
132
167
  sessionId?: string | null;
133
168
  /** Wether the node resuming is enabled or not */
134
169
  resuming: {
@@ -145,77 +180,205 @@ export declare class LavalinkNode {
145
180
  private reconnectAttempts;
146
181
  /** The Socket of the Lavalink */
147
182
  private socket;
148
- /** The Rest Server for this Lavalink */
149
- private rest;
150
183
  /** Version of what the Lavalink Server should be */
151
184
  private version;
152
185
  /**
153
186
  * Create a new Node
154
187
  * @param options Lavalink Node Options
155
188
  * @param manager Node Manager
189
+ *
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * // don't create a node manually, instead use:
194
+ *
195
+ * client.lavalink.nodeManager.createNode(options)
196
+ * ```
156
197
  */
157
198
  constructor(options: LavalinkNodeOptions, manager: NodeManager);
199
+ /**
200
+ * Parse url params correctly for lavalink requests, including support for urls and uris.
201
+ * @param url input url object
202
+ * @param extraQueryUrlParams UrlSearchParams to use in a encodedURI, useful for example for flowertts
203
+ * @returns the url as a valid string
204
+ *
205
+ * @example
206
+ * ```ts
207
+ * player.node.getRequestingUrl(new URL(`http://localhost:2333/v4/loadtracks?identifier=Never gonna give you up`));
208
+ * ```
209
+ */
210
+ private getRequestingUrl;
158
211
  /**
159
212
  * Raw Request util function
160
213
  * @param endpoint endpoint string
161
214
  * @param modify modify the request
162
- * @returns
215
+ * @param extraQueryUrlParams UrlSearchParams to use in a encodedURI, useful for example for flowertts
216
+ * @returns object containing request and option information
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * player.node.rawRequest(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET");
221
+ * ```
163
222
  */
164
223
  private rawRequest;
165
224
  /**
166
- * Makes an API call to the Node
225
+ * Makes an API call to the Node. Should only be used for manual parsing like for not supported plugins
167
226
  * @param endpoint The endpoint that we will make the call to
168
227
  * @param modify Used to modify the request before being sent
169
228
  * @returns The returned data
229
+ *
230
+ * @example
231
+ * ```ts
232
+ * player.node.request(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET", false);
233
+ * ```
170
234
  */
171
- request(endpoint: string, modify?: ModifyRequest, parseAsText?: boolean): Promise<unknown>;
235
+ request(endpoint: string, modify?: ModifyRequest, parseAsText?: boolean): Promise<any>;
172
236
  /**
173
237
  * Search something raw on the node, please note only add tracks to players of that node
174
238
  * @param query SearchQuery Object
175
239
  * @param requestUser Request User for creating the player(s)
240
+ * @param throwOnEmpty Wether to throw on an empty result or not
176
241
  * @returns Searchresult
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * // use player.search() instead
246
+ * player.node.search({ query: "Never gonna give you up by Rick Astley", source: "soundcloud" }, interaction.user);
247
+ * player.node.search({ query: "https://deezer.com/track/123456789" }, interaction.user);
248
+ * ```
249
+ */
250
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult>;
251
+ /**
252
+ * Search something using the lavaSearchPlugin (filtered searches by types)
253
+ * @param query LavaSearchQuery Object
254
+ * @param requestUser Request User for creating the player(s)
255
+ * @param throwOnEmpty Wether to throw on an empty result or not
256
+ * @returns LavaSearchresult
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * // use player.search() instead
261
+ * player.node.lavaSearch({ types: ["playlist", "album"], query: "Rick Astley", source: "spotify" }, interaction.user);
262
+ * ```
177
263
  */
178
- search(query: SearchQuery, requestUser: unknown): Promise<SearchResult>;
179
264
  lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult | LavaSearchResponse>;
180
265
  /**
181
266
  * Update the Player State on the Lavalink Server
182
- * @param data
183
- * @returns
267
+ * @param data data to send to lavalink and sync locally
268
+ * @returns result from lavalink
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * // use player.search() instead
273
+ * player.node.updatePlayer({ guildId: player.guildId, playerOptions: { paused: true } }); // example to pause it
274
+ * ```
184
275
  */
185
276
  updatePlayer(data: PlayerUpdateInfo): Promise<LavalinkPlayer>;
186
277
  /**
187
278
  * Destroys the Player on the Lavalink Server
188
279
  * @param guildId
189
- * @returns
280
+ * @returns request result
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * // use player.destroy() instead
285
+ * player.node.destroyPlayer(player.guildId);
286
+ * ```
190
287
  */
191
- destroyPlayer(guildId: any): Promise<unknown>;
288
+ destroyPlayer(guildId: any): Promise<any>;
192
289
  /**
193
290
  * Connect to the Lavalink Node
194
291
  * @param sessionId Provide the Session Id of the previous connection, to resume the node and it's player(s)
195
- * @returns
292
+ * @returns void
293
+ *
294
+ * @example
295
+ * ```ts
296
+ * player.node.connect(); // if provided on bootup in managerOptions#nodes, this will be called automatically when doing lavalink.init()
297
+ *
298
+ * // or connect from a resuming session:
299
+ * player.node.connect("sessionId");
300
+ * ```
196
301
  */
197
302
  connect(sessionId?: string): void;
198
- /** Get the id of the node */
303
+ /**
304
+ * Get the id of the node
305
+ *
306
+ * @example
307
+ * ```ts
308
+ * const nodeId = player.node.id;
309
+ * console.log("node id is: ", nodeId)
310
+ * ```
311
+ */
199
312
  get id(): string;
200
313
  /**
201
314
  * Destroys the Node-Connection (Websocket) and all player's of the node
202
- * @returns
315
+ * @param destroyReason Destroyreason to use when destroying the players
316
+ * @param deleteNode wether to delete the nodte from the nodes list too, if false it will emit a disconnect. @default true
317
+ * @returns void
318
+ *
319
+ * @example
320
+ * ```ts
321
+ * player.node.destroy("custom Player Destroy Reason", true);
322
+ * ```
203
323
  */
204
324
  destroy(destroyReason?: DestroyReasonsType, deleteNode?: boolean): void;
205
- /** Returns if connected to the Node. */
325
+ /**
326
+ * Returns if connected to the Node.
327
+ *
328
+ * @example
329
+ * ```ts
330
+ * const isConnected = player.node.connected;
331
+ * console.log("node is connected: ", isConnected ? "yes" : "no")
332
+ * ```
333
+ */
206
334
  get connected(): boolean;
335
+ /**
336
+ * Returns the current ConnectionStatus
337
+ *
338
+ * @example
339
+ * ```ts
340
+ * try {
341
+ * const statusOfConnection = player.node.connectionStatus;
342
+ * console.log("node's connection status is:", statusOfConnection)
343
+ * } catch (error) {
344
+ * console.error("no socket available?", error)
345
+ * }
346
+ * ```
347
+ */
348
+ get connectionStatus(): string;
207
349
  /**
208
350
  * Gets all Players of a Node
351
+ * @returns array of players inside of lavalink
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * const node = lavalink.nodes.get("NODEID");
356
+ * const playersOfLavalink = await node?.fetchAllPlayers();
357
+ * ```
209
358
  */
210
359
  fetchAllPlayers(): Promise<LavalinkPlayer[]>;
211
360
  /**
212
361
  * Gets specific Player Information
362
+ * @returns lavalink player object if player exists on lavalink
363
+ *
364
+ * @example
365
+ * ```ts
366
+ * const node = lavalink.nodes.get("NODEID");
367
+ * const playerInformation = await node?.fetchPlayer("guildId");
368
+ * ```
213
369
  */
214
370
  fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest>;
215
371
  /**
216
372
  * Updates the session with and enables/disables resuming and timeout
217
373
  * @param resuming Whether resuming is enabled for this session or not
218
374
  * @param timeout The timeout in seconds (default is 60s)
375
+ * @returns the result of the request
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * const node = player.node || lavalink.nodes.get("NODEID");
380
+ * await node?.updateSession(true, 180e3); // will enable resuming for 180seconds
381
+ * ```
219
382
  */
220
383
  updateSession(resuming?: boolean, timeout?: number): Promise<InvalidLavalinkRestRequest | Session>;
221
384
  /**
@@ -223,31 +386,63 @@ export declare class LavalinkNode {
223
386
  */
224
387
  decode: {
225
388
  /**
226
- * Decode a single track into its info, where BASE64 is the encoded base64 data.
227
- * @param encoded
228
- * @returns
389
+ * Decode a single track into its info
390
+ * @param encoded valid encoded base64 string from a track
391
+ * @param requester the requesteruser for building the track
392
+ * @returns decoded track from lavalink
393
+ *
394
+ * @example
395
+ * ```ts
396
+ * const encodedBase64 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA=';
397
+ * const track = await player.node.decode.singleTrack(encodedBase64, interaction.user);
398
+ * ```
229
399
  */
230
400
  singleTrack: (encoded: Base64, requester: unknown) => Promise<Track>;
231
401
  /**
402
+ * Decodes multiple tracks into their info
403
+ * @param encodeds valid encoded base64 string array from all tracks
404
+ * @param requester the requesteruser for building the tracks
405
+ * @returns array of all tracks you decoded
232
406
  *
233
- * @param encodeds Decodes multiple tracks into their info
234
- * @returns
407
+ * @example
408
+ * ```ts
409
+ * const encodedBase64_1 = 'QAACDgMACk5vIERpZ2dpdHkAC0JsYWNrc3RyZWV0AAAAAAAEo4AABjkxNjQ5NgABAB9odHRwczovL2RlZXplci5jb20vdHJhY2svOTE2NDk2AQBpaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvY292ZXIvZGFlN2EyNjViNzlmYjcxMjc4Y2RlMjUwNDg0OWQ2ZjcvMTAwMHgxMDAwLTAwMDAwMC04MC0wLTAuanBnAQAMVVNJUjE5NjAwOTc4AAZkZWV6ZXIBAChObyBEaWdnaXR5OiBUaGUgVmVyeSBCZXN0IE9mIEJsYWNrc3RyZWV0AQAjaHR0cHM6Ly93d3cuZGVlemVyLmNvbS9hbGJ1bS8xMDMyNTQBACJodHRwczovL3d3dy5kZWV6ZXIuY29tL2FydGlzdC8xODYxAQBqaHR0cHM6Ly9lLWNkbnMtaW1hZ2VzLmR6Y2RuLm5ldC9pbWFnZXMvYXJ0aXN0L2YxNmNhYzM2ZmVjMzkxZjczN2I3ZDQ4MmY1YWM3M2UzLzEwMDB4MTAwMC0wMDAwMDAtODAtMC0wLmpwZwEAT2h0dHBzOi8vY2RuLXByZXZpZXctYS5kemNkbi5uZXQvc3RyZWFtL2MtYTE1Yjg1NzFhYTYyMDBjMDQ0YmY1OWM3NmVkOTEyN2MtNi5tcDMAAAAAAAAAAAA=';
410
+ * const encodedBase64_2 = 'QAABJAMAClRhbGsgYSBMb3QACjQwNHZpbmNlbnQAAAAAAAHr1gBxTzpodHRwczovL2FwaS12Mi5zb3VuZGNsb3VkLmNvbS9tZWRpYS9zb3VuZGNsb3VkOnRyYWNrczo4NTE0MjEwNzYvMzUyYTRiOTAtNzYxOS00M2E5LWJiOGItMjIxMzE0YzFjNjNhL3N0cmVhbS9obHMAAQAsaHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS80MDR2aW5jZW50L3RhbGstYS1sb3QBADpodHRwczovL2kxLnNuZGNkbi5jb20vYXJ0d29ya3MtRTN1ek5Gc0Y4QzBXLTAtb3JpZ2luYWwuanBnAQAMUVpITkExOTg1Nzg0AApzb3VuZGNsb3VkAAAAAAAAAAA=';
411
+ * const tracks = await player.node.decode.multipleTracks([encodedBase64_1, encodedBase64_2], interaction.user);
412
+ * ```
235
413
  */
236
414
  multipleTracks: (encodeds: Base64[], requester: unknown) => Promise<Track[]>;
237
415
  };
238
416
  /**
239
417
  * Request Lavalink statistics.
240
- * @returns
418
+ * @returns the lavalink node stats
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * const lavalinkStats = await player.node.fetchStats();
423
+ * ```
241
424
  */
242
425
  fetchStats(): Promise<BaseNodeStats>;
243
426
  /**
244
427
  * Request Lavalink version.
245
- * @returns
428
+ * @returns the current used lavalink version
429
+ *
430
+ * @example
431
+ * ```ts
432
+ * const lavalinkVersion = await player.node.fetchVersion();
433
+ * ```
246
434
  */
247
435
  fetchVersion(): Promise<string>;
248
436
  /**
249
437
  * Request Lavalink information.
250
- * @returns
438
+ * @returns lavalink info object
439
+ *
440
+ * @example
441
+ * ```ts
442
+ * const lavalinkInfo = await player.node.fetchInfo();
443
+ * const availablePlugins:string[] = lavalinkInfo.plugins.map(plugin => plugin.name);
444
+ * const availableSources:string[] = lavalinkInfo.sourceManagers;
445
+ * ```
251
446
  */
252
447
  fetchInfo(): Promise<LavalinkInfo>;
253
448
  /**
@@ -255,40 +450,127 @@ export declare class LavalinkNode {
255
450
  */
256
451
  routePlannerApi: {
257
452
  /**
258
- * Get routplanner Info from Lavalink
453
+ * Get routplanner Info from Lavalink for ip rotation
454
+ * @returns the status of the routeplanner
455
+ *
456
+ * @example
457
+ * ```ts
458
+ * const routePlannerStatus = await player.node.routePlannerApi.getStatus();
459
+ * const usedBlock = routePlannerStatus.details?.ipBlock;
460
+ * const currentIp = routePlannerStatus.currentAddress;
461
+ * ```
259
462
  */
260
463
  getStatus: () => Promise<RoutePlanner>;
261
464
  /**
262
- * Release blacklisted IP address into pool of IPs
465
+ * Release blacklisted IP address into pool of IPs for ip rotation
263
466
  * @param address IP address
467
+ * @returns request data of the request
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * await player.node.routePlannerApi.unmarkFailedAddress("ipv6address");
472
+ * ```
264
473
  */
265
474
  unmarkFailedAddress: (address: string) => Promise<void>;
266
475
  /**
267
476
  * Release all blacklisted IP addresses into pool of IPs
477
+ * @returns request data of the request
478
+ *
479
+ * @example
480
+ * ```ts
481
+ * await player.node.routePlannerApi.unmarkAllFailedAddresses();
482
+ * ```
268
483
  */
269
- unmarkAllFailedAddresses: () => Promise<unknown>;
484
+ unmarkAllFailedAddresses: () => Promise<any>;
270
485
  };
271
- /** Private Utils */
486
+ /** @private Utils for validating the */
272
487
  private validate;
488
+ /**
489
+ * Sync the data of the player you make an action to lavalink to
490
+ * @param data data to use to update the player
491
+ * @param res result data from lavalink, to override, if available
492
+ * @returns boolean
493
+ */
273
494
  private syncPlayerData;
274
- private get poolAddress();
495
+ /**
496
+ * Get the rest Adress for making requests
497
+ */
498
+ private get restAddress();
499
+ /**
500
+ * Reconnect to the lavalink node
501
+ * @param instaReconnect @default false wether to instantly try to reconnect
502
+ * @returns void
503
+ *
504
+ * @example
505
+ * ```ts
506
+ * await player.node.reconnect();
507
+ * ```
508
+ */
275
509
  private reconnect;
510
+ /** @private util function for handling opening events from websocket */
276
511
  private open;
512
+ /** @private util function for handling closing events from websocket */
277
513
  private close;
514
+ /** @private util function for handling error events from websocket */
278
515
  private error;
516
+ /** @private util function for handling message events from websocket */
279
517
  private message;
518
+ /** @private middleware util function for handling all kind of events from websocket */
280
519
  private handleEvent;
520
+ /** @private util function for handling trackStart event */
281
521
  private trackStart;
522
+ /** @private util function for handling trackEnd event */
282
523
  private trackEnd;
524
+ /** @private util function for handling trackStuck event */
283
525
  private trackStuck;
526
+ /** @private util function for handling trackError event */
284
527
  private trackError;
528
+ /** @private util function for handling socketClosed event */
285
529
  private socketClosed;
530
+ /** @private util function for handling SponsorBlock Segmentloaded event */
286
531
  private SponsorBlockSegmentLoaded;
287
- private SponsorBlockSegmentkipped;
532
+ /** @private util function for handling SponsorBlock SegmentSkipped event */
533
+ private SponsorBlockSegmentSkipped;
534
+ /** @private util function for handling SponsorBlock Chaptersloaded event */
288
535
  private SponsorBlockChaptersLoaded;
536
+ /** @private util function for handling SponsorBlock Chaptersstarted event */
289
537
  private SponsorBlockChapterStarted;
538
+ /**
539
+ * Get the current sponsorblocks for the sponsorblock plugin
540
+ * @param player passthrough the player
541
+ * @returns sponsorblock seggment from lavalink
542
+ *
543
+ * @example
544
+ * ```ts
545
+ * // use it on the player via player.getSponsorBlock();
546
+ * const sponsorBlockSegments = await player.node.getSponsorBlock(player);
547
+ * ```
548
+ */
290
549
  getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
550
+ /**
551
+ * Set the current sponsorblocks for the sponsorblock plugin
552
+ * @param player passthrough the player
553
+ * @returns void
554
+ *
555
+ * @example
556
+ * ```ts
557
+ * // use it on the player via player.setSponsorBlock();
558
+ * const sponsorBlockSegments = await player.node.setSponsorBlock(player, ["sponsor", "selfpromo"]);
559
+ * ```
560
+ */
291
561
  setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
562
+ /**
563
+ * Delete the sponsorblock plugins
564
+ * @param player passthrough the player
565
+ * @returns void
566
+ *
567
+ * @example
568
+ * ```ts
569
+ * // use it on the player via player.deleteSponsorBlock();
570
+ * const sponsorBlockSegments = await player.node.deleteSponsorBlock(player);
571
+ * ```
572
+ */
292
573
  deleteSponsorBlock(player: Player): Promise<void>;
574
+ /** private util function for handling the queue end event */
293
575
  private queueEnd;
294
576
  }
@@ -5,7 +5,7 @@ import { LavalinkNode, LavalinkNodeOptions } from "./Node";
5
5
  import { DestroyReasonsType } from "./Player";
6
6
  import { LavalinkPlayer, MiniMap } from "./Utils";
7
7
  type LavalinkNodeIdentifier = string;
8
- interface NodeManagerEvents {
8
+ export interface NodeManagerEvents {
9
9
  /**
10
10
  * Emitted when a Node is created.
11
11
  * @event Manager.nodeManager#create
@@ -4,28 +4,58 @@ import { LavalinkNode, SponsorBlockSegment } from "./Node";
4
4
  import { Queue } from "./Queue";
5
5
  import { Track, UnresolvedTrack } from "./Track";
6
6
  import { Base64, LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Utils";
7
- type PlayerDestroyReasons = "QueueEmpty" | "NodeDestroy" | "NodeDeleted" | "LavalinkNoVoice" | "NodeReconnectFail" | "PlayerReconnectFail" | "Disconnected" | "ChannelDeleted" | "ReconnectAllNodes" | "DisconnectAllNodes";
8
- export type DestroyReasonsType = PlayerDestroyReasons | string;
9
- export declare const DestroyReasons: Record<PlayerDestroyReasons, PlayerDestroyReasons>;
7
+ export declare enum DestroyReasons {
8
+ QueueEmpty = "QueueEmpty",
9
+ NodeDestroy = "NodeDestroy",
10
+ NodeDeleted = "NodeDeleted",
11
+ LavalinkNoVoice = "LavalinkNoVoice",
12
+ NodeReconnectFail = "NodeReconnectFail",
13
+ Disconnected = "Disconnected",
14
+ PlayerReconnectFail = "PlayerReconnectFail",
15
+ ChannelDeleted = "ChannelDeleted",
16
+ DisconnectAllNodes = "DisconnectAllNodes",
17
+ ReconnectAllNodes = "ReconnectAllNodes"
18
+ }
19
+ export type DestroyReasonsType = keyof typeof DestroyReasons | string;
10
20
  export interface PlayerJson {
21
+ /** Guild Id where the player was playing in */
11
22
  guildId: string;
23
+ /** Options provided to the player */
12
24
  options: PlayerOptions;
25
+ /** Voice Channel Id the player was playing in */
13
26
  voiceChannelId: string;
27
+ /** Text Channel Id the player was synced to */
14
28
  textChannelId?: string;
29
+ /** Position the player was at */
15
30
  position: number;
31
+ /** Lavalink's position the player was at */
16
32
  lastPosition: number;
33
+ /** Last time the position was sent from lavalink */
34
+ lastPositionChange: number;
35
+ /** Volume in % from the player (without volumeDecrementer) */
17
36
  volume: number;
37
+ /** Real Volume used in lavalink (with the volumeDecrementer) */
18
38
  lavalinkVolume: number;
39
+ /** The repeatmode from the player */
19
40
  repeatMode: RepeatMode;
41
+ /** Pause state */
20
42
  paused: boolean;
43
+ /** Wether the player was playing or not */
21
44
  playing: boolean;
45
+ /** When the player was created */
22
46
  createdTimeStamp?: number;
47
+ /** All current used fitlers Data */
23
48
  filters: FilterData;
49
+ /** The player's ping object */
24
50
  ping: {
51
+ /** Ping to the voice websocket server */
25
52
  ws: number;
53
+ /** Avg. calc. Ping to the lavalink server */
26
54
  lavalink: number;
27
55
  };
56
+ /** Equalizer Bands used in lavalink */
28
57
  equalizer: EQBand[];
58
+ /** The Id of the last used node */
29
59
  nodeId?: string;
30
60
  }
31
61
  export type RepeatMode = "queue" | "track" | "off";
@@ -88,10 +118,15 @@ export interface PlayOptions extends LavalinkPlayOptions {
88
118
  clientTrack?: Track | UnresolvedTrack;
89
119
  }
90
120
  export interface Player {
121
+ /** Filter Manager per player */
91
122
  filterManager: FilterManager;
123
+ /** circular reference to the lavalink Manager from the Player for easier use */
92
124
  LavalinkManager: LavalinkManager;
125
+ /** Player options currently used, mutation doesn't affect player's state */
93
126
  options: PlayerOptions;
127
+ /** The lavalink node assigned the the player, don't change it manually */
94
128
  node: LavalinkNode;
129
+ /** The queue from the player */
95
130
  queue: Queue;
96
131
  }
97
132
  export declare class Player {
@@ -117,7 +152,9 @@ export declare class Player {
117
152
  /** The Volume Lavalink actually is outputting */
118
153
  lavalinkVolume: number;
119
154
  /** The current Positin of the player (Calculated) */
120
- position: number;
155
+ get position(): number;
156
+ /** The timestamp when the last position change update happened */
157
+ lastPositionChange: number;
121
158
  /** The current Positin of the player (from Lavalink) */
122
159
  lastPosition: number;
123
160
  /** When the player was created [Timestamp in Ms] (from lavalink) */
@@ -163,7 +200,7 @@ export declare class Player {
163
200
  * @param ignoreVolumeDecrementer If it should ignore the volumedecrementer option
164
201
  */
165
202
  setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
166
- lavaSearch(query: LavaSearchQuery, requestUser: unknown): Promise<import("./Utils").SearchResult | import("./Utils").LavaSearchResponse>;
203
+ lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Utils").SearchResult | import("./Utils").LavaSearchResponse>;
167
204
  setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
168
205
  getSponsorBlock(): Promise<SponsorBlockSegment[]>;
169
206
  deleteSponsorBlock(): Promise<void>;
@@ -172,7 +209,7 @@ export declare class Player {
172
209
  * @param query Query for your data
173
210
  * @param requestUser
174
211
  */
175
- search(query: SearchQuery, requestUser: unknown): Promise<import("./Utils").SearchResult | import("./Utils").UnresolvedSearchResult>;
212
+ search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Utils").SearchResult | import("./Utils").UnresolvedSearchResult>;
176
213
  /**
177
214
  * Pause the player
178
215
  */
@@ -220,7 +257,7 @@ export declare class Player {
220
257
  /**
221
258
  * Destroy the player and disconnect from the voice channel
222
259
  */
223
- destroy(reason?: string, disconnect?: boolean): Promise<this>;
260
+ destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
224
261
  /**
225
262
  * Move the player on a different Audio-Node
226
263
  * @param newNode New Node / New Node Id
@@ -229,4 +266,3 @@ export declare class Player {
229
266
  /** Converts the Player including Queue to a Json state */
230
267
  toJSON(): PlayerJson;
231
268
  }
232
- export {};