lavalink-client 2.3.0 → 2.3.3

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 (55) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/index.d.ts +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/structures/Constants.d.ts +44 -1
  5. package/dist/cjs/structures/Constants.js +45 -1
  6. package/dist/cjs/structures/LavalinkManager.js +80 -5
  7. package/dist/cjs/structures/Node.js +202 -20
  8. package/dist/cjs/structures/Player.d.ts +0 -1
  9. package/dist/cjs/structures/Player.js +73 -6
  10. package/dist/cjs/structures/Queue.js +29 -2
  11. package/dist/cjs/structures/Types/Manager.d.ts +25 -0
  12. package/dist/cjs/structures/Types/Queue.d.ts +1 -1
  13. package/dist/cjs/structures/Utils.js +68 -18
  14. package/dist/esm/index.d.ts +1 -0
  15. package/dist/esm/index.js +1 -0
  16. package/dist/esm/structures/Constants.d.ts +44 -1
  17. package/dist/esm/structures/Constants.js +44 -0
  18. package/dist/esm/structures/LavalinkManager.js +81 -6
  19. package/dist/esm/structures/Node.js +203 -21
  20. package/dist/esm/structures/Player.d.ts +0 -1
  21. package/dist/esm/structures/Player.js +73 -6
  22. package/dist/esm/structures/Queue.js +29 -2
  23. package/dist/esm/structures/Types/Manager.d.ts +25 -0
  24. package/dist/esm/structures/Types/Queue.d.ts +1 -1
  25. package/dist/esm/structures/Utils.js +68 -18
  26. package/dist/types/index.d.ts +1 -0
  27. package/dist/types/structures/Constants.d.ts +44 -1
  28. package/dist/types/structures/Player.d.ts +0 -1
  29. package/dist/types/structures/Types/Manager.d.ts +25 -0
  30. package/dist/types/structures/Types/Queue.d.ts +1 -1
  31. package/package.json +1 -1
  32. package/dist/index.d.ts +0 -10
  33. package/dist/index.js +0 -13
  34. package/dist/structures/Filters.d.ts +0 -230
  35. package/dist/structures/Filters.js +0 -472
  36. package/dist/structures/LavalinkManager.d.ts +0 -47
  37. package/dist/structures/LavalinkManager.js +0 -36
  38. package/dist/structures/LavalinkManagerStatics.d.ts +0 -3
  39. package/dist/structures/LavalinkManagerStatics.js +0 -76
  40. package/dist/structures/Node.d.ts +0 -171
  41. package/dist/structures/Node.js +0 -462
  42. package/dist/structures/NodeManager.d.ts +0 -58
  43. package/dist/structures/NodeManager.js +0 -25
  44. package/dist/structures/Player.d.ts +0 -101
  45. package/dist/structures/Player.js +0 -232
  46. package/dist/structures/PlayerManager.d.ts +0 -62
  47. package/dist/structures/PlayerManager.js +0 -26
  48. package/dist/structures/Queue.d.ts +0 -93
  49. package/dist/structures/Queue.js +0 -160
  50. package/dist/structures/QueueManager.d.ts +0 -77
  51. package/dist/structures/QueueManager.js +0 -74
  52. package/dist/structures/Track.d.ts +0 -27
  53. package/dist/structures/Track.js +0 -2
  54. package/dist/structures/Utils.d.ts +0 -183
  55. package/dist/structures/Utils.js +0 -43
@@ -1,3 +1,4 @@
1
+ import type { DebugEvents } from "../Constants";
1
2
  import type { Player } from "../Player";
2
3
  import type { LavalinkNodeOptions } from "./Node";
3
4
  import type { DestroyReasonsType, PlayerJson } from "./Player";
@@ -100,6 +101,19 @@ export interface LavalinkManagerEvents {
100
101
  * @event Manager#trackError
101
102
  */
102
103
  "ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
104
+ /**
105
+ * Lavalink-Client Debug Event
106
+ * Emitted for several erros, and logs within lavalink-client, if managerOptions.advancedOptions.enableDebugEvents is true
107
+ * Useful for debugging the lavalink-client
108
+ *
109
+ * @event Manager#debug
110
+ */
111
+ "debug": (eventKey: DebugEvents, eventData: {
112
+ message: string;
113
+ state: "log" | "warn" | "error";
114
+ error?: Error | string;
115
+ functionLayer: string;
116
+ }) => void;
103
117
  }
104
118
  /**
105
119
  * The Bot client Options needed for the manager
@@ -131,6 +145,15 @@ export interface ManagerPlayerOptions {
131
145
  /** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
132
146
  destroyPlayer?: boolean;
133
147
  };
148
+ /** Minimum time to play the song before autoPlayFunction is executed (prevents error spamming) Set to 0 to disable it @default 10000 */
149
+ minAutoPlayMs?: number;
150
+ /** 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 }" */
151
+ maxErrorsPerTime?: {
152
+ /** The threshold time to count errors (recommended is 35s) */
153
+ threshold: number;
154
+ /** The max amount of errors within the threshold time which are allowed before destroying the player (when errors > maxAmount -> player.destroy()) */
155
+ maxAmount: number;
156
+ };
134
157
  onEmptyQueue?: {
135
158
  /** 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! */
136
159
  autoPlayFunction?: (player: Player, lastPlayedTrack: Track) => Promise<void>;
@@ -166,6 +189,8 @@ export interface ManagerOptions {
166
189
  advancedOptions?: {
167
190
  /** Max duration for that the filter fix duration works (in ms) - default is 8mins */
168
191
  maxFilterFixDuration?: number;
192
+ /** Enable Debug event */
193
+ enableDebugEvents?: boolean;
169
194
  /** optional */
170
195
  debugOptions?: {
171
196
  /** For logging custom searches */
@@ -28,7 +28,7 @@ export interface QueueChangesWatcher {
28
28
  /** get a Value (MUST RETURN UNPARSED!) */
29
29
  tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
30
30
  /** Set a value inside a guildId (MUST BE UNPARSED) */
31
- tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
31
+ tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number | number[], oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
32
32
  /** Set a value inside a guildId (MUST BE UNPARSED) */
33
33
  shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
34
34
  }
@@ -1,5 +1,6 @@
1
1
  import { URL } from "node:url";
2
2
  import { isRegExp } from "node:util/types";
3
+ import { DebugEvents } from "./Constants";
3
4
  import { DefaultSources, LavalinkPlugins, SourceLinksRegexes } from "./LavalinkManagerStatics";
4
5
  export const TrackSymbol = Symbol("LC-Track");
5
6
  export const UnresolvedTrackSymbol = Symbol("LC-Track-Unresolved");
@@ -71,6 +72,14 @@ export class ManagerUtils {
71
72
  return r;
72
73
  }
73
74
  catch (error) {
75
+ if (this.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
76
+ this.LavalinkManager?.emit("debug", DebugEvents.BuildTrackError, {
77
+ error: error,
78
+ functionLayer: "ManagerUtils > buildTrack()",
79
+ message: "Error while building track",
80
+ state: "error",
81
+ });
82
+ }
74
83
  throw new RangeError(`Argument "data" is not a valid track: ${error.message}`);
75
84
  }
76
85
  }
@@ -129,7 +138,14 @@ export class ManagerUtils {
129
138
  : requester;
130
139
  }
131
140
  catch (e) {
132
- console.error("errored while transforming requester:", e);
141
+ if (this.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
142
+ this.LavalinkManager?.emit("debug", DebugEvents.TransformRequesterFunctionFailed, {
143
+ error: e,
144
+ functionLayer: "ManagerUtils > getTransformedRequester()",
145
+ message: "Your custom transformRequesterFunction failed to execute, please check your function for errors.",
146
+ state: "error",
147
+ });
148
+ }
133
149
  return requester;
134
150
  }
135
151
  }
@@ -195,62 +211,96 @@ export class ManagerUtils {
195
211
  return typeof data === "object" && !("info" in data) && typeof data.title === "string";
196
212
  }
197
213
  async getClosestTrack(data, player) {
198
- return getClosestTrack(data, player);
214
+ try {
215
+ return getClosestTrack(data, player);
216
+ }
217
+ catch (e) {
218
+ if (this.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
219
+ this.LavalinkManager?.emit("debug", DebugEvents.GetClosestTrackFailed, {
220
+ error: e,
221
+ functionLayer: "ManagerUtils > getClosestTrack()",
222
+ message: "Failed to resolve track because the getClosestTrack function failed.",
223
+ state: "error",
224
+ });
225
+ }
226
+ throw e;
227
+ }
199
228
  }
200
229
  validateQueryString(node, queryString, sourceString) {
201
230
  if (!node.info)
202
231
  throw new Error("No Lavalink Node was provided");
203
232
  if (!node.info.sourceManagers?.length)
204
233
  throw new Error("Lavalink Node, has no sourceManagers enabled");
234
+ if (!queryString.trim().length)
235
+ throw new Error(`Query string is empty, please provide a valid query string.`);
205
236
  if (sourceString === "speak" && queryString.length > 100)
206
- // checks for blacklisted links / domains / queries
207
- if (this.LavalinkManager.options?.linksBlacklist?.length > 0 && this.LavalinkManager.options?.linksBlacklist.some(v => (typeof v === "string" && (queryString.toLowerCase().includes(v.toLowerCase()) || v.toLowerCase().includes(queryString.toLowerCase()))) || isRegExp(v) && v.test(queryString))) {
237
+ throw new Error(`Query is speak, which is limited to 100 characters.`);
238
+ // checks for blacklisted links / domains / queries
239
+ if (this.LavalinkManager.options?.linksBlacklist?.length > 0) {
240
+ if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
241
+ this.LavalinkManager.emit("debug", DebugEvents.ValidatingBlacklistLinks, {
242
+ state: "log",
243
+ message: `Validating Query against LavalinkManager.options.linksBlacklist, query: "${queryString}"`,
244
+ functionLayer: "(LavalinkNode > node | player) > search() > validateQueryString()",
245
+ });
246
+ }
247
+ if (this.LavalinkManager.options?.linksBlacklist.some(v => (typeof v === "string" && (queryString.toLowerCase().includes(v.toLowerCase()) || v.toLowerCase().includes(queryString.toLowerCase()))) || isRegExp(v) && v.test(queryString))) {
208
248
  throw new Error(`Query string contains a link / word which is blacklisted.`);
209
249
  }
250
+ }
210
251
  if (!/^https?:\/\//.test(queryString))
211
252
  return;
212
253
  else if (this.LavalinkManager.options?.linksAllowed === false)
213
254
  throw new Error("Using links to make a request is not allowed.");
214
255
  // checks for if the query is whitelisted (should only work for links, so it skips the check for no link queries)
215
- if (this.LavalinkManager.options?.linksWhitelist?.length > 0 && !this.LavalinkManager.options?.linksWhitelist.some(v => (typeof v === "string" && (queryString.toLowerCase().includes(v.toLowerCase()) || v.toLowerCase().includes(queryString.toLowerCase()))) || isRegExp(v) && v.test(queryString))) {
216
- throw new Error(`Query string contains a link / word which isn't whitelisted.`);
256
+ if (this.LavalinkManager.options?.linksWhitelist?.length > 0) {
257
+ if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
258
+ this.LavalinkManager.emit("debug", DebugEvents.ValidatingWhitelistLinks, {
259
+ state: "log",
260
+ message: `Link was provided to the Query, validating against LavalinkManager.options.linksWhitelist, query: "${queryString}"`,
261
+ functionLayer: "(LavalinkNode > node | player) > search() > validateQueryString()",
262
+ });
263
+ }
264
+ if (!this.LavalinkManager.options?.linksWhitelist.some(v => (typeof v === "string" && (queryString.toLowerCase().includes(v.toLowerCase()) || v.toLowerCase().includes(queryString.toLowerCase()))) || isRegExp(v) && v.test(queryString))) {
265
+ throw new Error(`Query string contains a link / word which isn't whitelisted.`);
266
+ }
217
267
  }
218
268
  // missing links: beam.pro local getyarn.io clypit pornhub reddit ocreamix soundgasm
219
269
  if ((SourceLinksRegexes.YoutubeMusicRegex.test(queryString) || SourceLinksRegexes.YoutubeRegex.test(queryString)) && !node.info?.sourceManagers?.includes("youtube")) {
220
- throw new Error("Lavalink Node has not 'youtube' enabled");
270
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'youtube' enabled");
221
271
  }
222
272
  if ((SourceLinksRegexes.SoundCloudMobileRegex.test(queryString) || SourceLinksRegexes.SoundCloudRegex.test(queryString)) && !node.info?.sourceManagers?.includes("soundcloud")) {
223
- throw new Error("Lavalink Node has not 'soundcloud' enabled");
273
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'soundcloud' enabled");
224
274
  }
225
275
  if (SourceLinksRegexes.bandcamp.test(queryString) && !node.info?.sourceManagers?.includes("bandcamp")) {
226
- throw new Error("Lavalink Node has not 'bandcamp' enabled (introduced with lavaplayer 2.2.0 or lavalink 4.0.6)");
276
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'bandcamp' enabled (introduced with lavaplayer 2.2.0 or lavalink 4.0.6)");
227
277
  }
228
278
  if (SourceLinksRegexes.TwitchTv.test(queryString) && !node.info?.sourceManagers?.includes("twitch")) {
229
- throw new Error("Lavalink Node has not 'twitch' enabled");
279
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'twitch' enabled");
230
280
  }
231
281
  if (SourceLinksRegexes.vimeo.test(queryString) && !node.info?.sourceManagers?.includes("vimeo")) {
232
- throw new Error("Lavalink Node has not 'vimeo' enabled");
282
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'vimeo' enabled");
233
283
  }
234
284
  if (SourceLinksRegexes.tiktok.test(queryString) && !node.info?.sourceManagers?.includes("tiktok")) {
235
- throw new Error("Lavalink Node has not 'tiktok' enabled");
285
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'tiktok' enabled");
236
286
  }
237
287
  if (SourceLinksRegexes.mixcloud.test(queryString) && !node.info?.sourceManagers?.includes("mixcloud")) {
238
- throw new Error("Lavalink Node has not 'mixcloud' enabled");
288
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'mixcloud' enabled");
239
289
  }
240
290
  if (SourceLinksRegexes.AllSpotifyRegex.test(queryString) && !node.info?.sourceManagers?.includes("spotify")) {
241
- throw new Error("Lavalink Node has not 'spotify' enabled");
291
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'spotify' enabled");
242
292
  }
243
293
  if (SourceLinksRegexes.appleMusic.test(queryString) && !node.info?.sourceManagers?.includes("applemusic")) {
244
- throw new Error("Lavalink Node has not 'applemusic' enabled");
294
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'applemusic' enabled");
245
295
  }
246
296
  if (SourceLinksRegexes.AllDeezerRegex.test(queryString) && !node.info?.sourceManagers?.includes("deezer")) {
247
- throw new Error("Lavalink Node has not 'deezer' enabled");
297
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'deezer' enabled");
248
298
  }
249
299
  if (SourceLinksRegexes.AllDeezerRegex.test(queryString) && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
250
- throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'deezer' to work");
300
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'http' enabled, which is required to have 'deezer' to work");
251
301
  }
252
302
  if (SourceLinksRegexes.musicYandex.test(queryString) && !node.info?.sourceManagers?.includes("yandexmusic")) {
253
- throw new Error("Lavalink Node has not 'yandexmusic' enabled");
303
+ throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'yandexmusic' enabled");
254
304
  }
255
305
  return;
256
306
  }
@@ -13,3 +13,4 @@ export * from "./structures/Types/Player";
13
13
  export * from "./structures/Types/Queue";
14
14
  export * from "./structures/Types/Node";
15
15
  export * from "./structures/Constants";
16
+ export * from "./structures/Types/Manager";
@@ -1,4 +1,45 @@
1
1
  import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters";
2
+ export declare enum DebugEvents {
3
+ SetSponsorBlock = "SetSponsorBlock",
4
+ DeleteSponsorBlock = "DeleteSponsorBlock",
5
+ TrackEndReplaced = "TrackEndReplaced",
6
+ AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
7
+ AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
8
+ TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
9
+ QueueEnded = "QueueEnded",
10
+ TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
11
+ TrackStartNoTrack = "TrackStartNoTrack",
12
+ ResumingFetchingError = "ResumingFetchingError",
13
+ PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
14
+ PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
15
+ PlayerUpdateSuccess = "PlayerUpdateSuccess",
16
+ HeartBeatTriggered = "HeartBeatTriggered",
17
+ NoSocketOnDestroy = "NoSocketOnDestroy",
18
+ SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
19
+ TryingConnectWhileConnected = "TryingConnectWhileConnected",
20
+ LavaSearchNothingFound = "LavaSearchNothingFound",
21
+ SearchNothingFound = "SearchNothingFound",
22
+ ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
23
+ ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
24
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
25
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
26
+ PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
27
+ PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
28
+ PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
29
+ PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
30
+ PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
31
+ PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
32
+ PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
33
+ BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
34
+ PlayerChangeNode = "PlayerChangeNode",
35
+ BuildTrackError = "BuildTrackError",
36
+ TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
37
+ GetClosestTrackFailed = "GetClosestTrackFailed",
38
+ PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
39
+ FailedToConnectToNodes = "FailedToConnectToNodes",
40
+ NoAudioDebug = "NoAudioDebug",
41
+ PlayerAutoReconnect = "PlayerAutoReconnect"
42
+ }
2
43
  export declare enum DestroyReasons {
3
44
  QueueEmpty = "QueueEmpty",
4
45
  NodeDestroy = "NodeDestroy",
@@ -9,7 +50,9 @@ export declare enum DestroyReasons {
9
50
  PlayerReconnectFail = "PlayerReconnectFail",
10
51
  ChannelDeleted = "ChannelDeleted",
11
52
  DisconnectAllNodes = "DisconnectAllNodes",
12
- ReconnectAllNodes = "ReconnectAllNodes"
53
+ ReconnectAllNodes = "ReconnectAllNodes",
54
+ TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
55
+ TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
13
56
  }
14
57
  export declare const validSponsorBlocks: string[];
15
58
  /** The audio Outputs Data map declaration */
@@ -134,7 +134,6 @@ export declare class Player {
134
134
  * @param repeatMode
135
135
  */
136
136
  setRepeatMode(repeatMode: RepeatMode): Promise<this>;
137
- 1: any;
138
137
  /**
139
138
  * Skip the current song, or a specific amount of songs
140
139
  * @param amount provide the index of the next track to skip to
@@ -1,3 +1,4 @@
1
+ import type { DebugEvents } from "../Constants";
1
2
  import type { Player } from "../Player";
2
3
  import type { LavalinkNodeOptions } from "./Node";
3
4
  import type { DestroyReasonsType, PlayerJson } from "./Player";
@@ -100,6 +101,19 @@ export interface LavalinkManagerEvents {
100
101
  * @event Manager#trackError
101
102
  */
102
103
  "ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
104
+ /**
105
+ * Lavalink-Client Debug Event
106
+ * Emitted for several erros, and logs within lavalink-client, if managerOptions.advancedOptions.enableDebugEvents is true
107
+ * Useful for debugging the lavalink-client
108
+ *
109
+ * @event Manager#debug
110
+ */
111
+ "debug": (eventKey: DebugEvents, eventData: {
112
+ message: string;
113
+ state: "log" | "warn" | "error";
114
+ error?: Error | string;
115
+ functionLayer: string;
116
+ }) => void;
103
117
  }
104
118
  /**
105
119
  * The Bot client Options needed for the manager
@@ -131,6 +145,15 @@ export interface ManagerPlayerOptions {
131
145
  /** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
132
146
  destroyPlayer?: boolean;
133
147
  };
148
+ /** Minimum time to play the song before autoPlayFunction is executed (prevents error spamming) Set to 0 to disable it @default 10000 */
149
+ minAutoPlayMs?: number;
150
+ /** 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 }" */
151
+ maxErrorsPerTime?: {
152
+ /** The threshold time to count errors (recommended is 35s) */
153
+ threshold: number;
154
+ /** The max amount of errors within the threshold time which are allowed before destroying the player (when errors > maxAmount -> player.destroy()) */
155
+ maxAmount: number;
156
+ };
134
157
  onEmptyQueue?: {
135
158
  /** 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! */
136
159
  autoPlayFunction?: (player: Player, lastPlayedTrack: Track) => Promise<void>;
@@ -166,6 +189,8 @@ export interface ManagerOptions {
166
189
  advancedOptions?: {
167
190
  /** Max duration for that the filter fix duration works (in ms) - default is 8mins */
168
191
  maxFilterFixDuration?: number;
192
+ /** Enable Debug event */
193
+ enableDebugEvents?: boolean;
169
194
  /** optional */
170
195
  debugOptions?: {
171
196
  /** For logging custom searches */
@@ -28,7 +28,7 @@ export interface QueueChangesWatcher {
28
28
  /** get a Value (MUST RETURN UNPARSED!) */
29
29
  tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
30
30
  /** Set a value inside a guildId (MUST BE UNPARSED) */
31
- tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
31
+ tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number | number[], oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
32
32
  /** Set a value inside a guildId (MUST BE UNPARSED) */
33
33
  shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lavalink-client",
3
- "version": "2.3.0",
3
+ "version": "2.3.3",
4
4
  "description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/dist/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export * from "./structures/LavalinkManager";
2
- export * from "./structures/Filters";
3
- export * from "./structures/LavalinkManagerStatics";
4
- export * from "./structures/Node";
5
- export * from "./structures/NodeManager";
6
- export * from "./structures/Player";
7
- export * from "./structures/PlayerManager";
8
- export * from "./structures/Queue";
9
- export * from "./structures/Track";
10
- export * from "./structures/Utils";
package/dist/index.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./structures/LavalinkManager"), exports);
5
- tslib_1.__exportStar(require("./structures/Filters"), exports);
6
- tslib_1.__exportStar(require("./structures/LavalinkManagerStatics"), exports);
7
- tslib_1.__exportStar(require("./structures/Node"), exports);
8
- tslib_1.__exportStar(require("./structures/NodeManager"), exports);
9
- tslib_1.__exportStar(require("./structures/Player"), exports);
10
- tslib_1.__exportStar(require("./structures/PlayerManager"), exports);
11
- tslib_1.__exportStar(require("./structures/Queue"), exports);
12
- tslib_1.__exportStar(require("./structures/Track"), exports);
13
- tslib_1.__exportStar(require("./structures/Utils"), exports);
@@ -1,230 +0,0 @@
1
- import { Player } from "./Player";
2
- export type AudioOutputs = "mono" | "stereo" | "left" | "right";
3
- export interface FilterManager {
4
- player: Player;
5
- }
6
- export declare class FilterManager {
7
- equalizerBands: EQBand[];
8
- filterUpdatedState: number;
9
- filters: PlayerFilters;
10
- data: LavalinkFilterData;
11
- constructor(player: Player);
12
- applyPlayerFilters(): Promise<void>;
13
- /**
14
- * Checks if the filters are correctly stated (active / not-active)
15
- * @param oldFilterTimescale
16
- * @returns
17
- */
18
- checkFiltersState(oldFilterTimescale?: Partial<TimescaleFilter>): boolean;
19
- /**
20
- * Reset all Filters
21
- */
22
- resetFilters(): Promise<PlayerFilters>;
23
- /**
24
- * Set the AudioOutput Filter
25
- * @param type
26
- */
27
- setAudioOutput(type: AudioOutputs): Promise<AudioOutputs>;
28
- /**
29
- * Set custom filter.timescale#speed . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
30
- * @param speed
31
- * @returns
32
- */
33
- setSpeed(speed?: number): Promise<boolean>;
34
- /**
35
- * Set custom filter.timescale#pitch . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
36
- * @param speed
37
- * @returns
38
- */
39
- setPitch(pitch?: number): Promise<boolean>;
40
- /**
41
- * Set custom filter.timescale#rate . This method disabled both: nightcore & vaporwave. use 1 to reset it to normal
42
- * @param speed
43
- * @returns
44
- */
45
- setRate(rate?: number): Promise<boolean>;
46
- /**
47
- * Enabels / Disables the rotation effect, (Optional: provide your Own Data)
48
- * @param rotationHz
49
- * @returns
50
- */
51
- toggleRotation(rotationHz?: number): Promise<boolean>;
52
- /**
53
- * Enabels / Disables the Vibrato effect, (Optional: provide your Own Data)
54
- * @param frequency
55
- * @param depth
56
- * @returns
57
- */
58
- toggleVibrato(frequency?: number, depth?: number): Promise<boolean>;
59
- /**
60
- * Enabels / Disables the Tremolo effect, (Optional: provide your Own Data)
61
- * @param frequency
62
- * @param depth
63
- * @returns
64
- */
65
- toggleTremolo(frequency?: number, depth?: number): Promise<boolean>;
66
- /**
67
- * Enabels / Disables the LowPass effect, (Optional: provide your Own Data)
68
- * @param smoothing
69
- * @returns
70
- */
71
- toggleLowPass(smoothing?: number): Promise<boolean>;
72
- /**
73
- * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
74
- * @param delay
75
- * @param decay
76
- * @returns
77
- */
78
- toggleEcho(delay?: number, decay?: number): Promise<boolean>;
79
- /**
80
- * Enabels / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
81
- * @param delay
82
- * @param decay
83
- * @returns
84
- */
85
- toggleReverb(delay?: number, decay?: number): Promise<boolean>;
86
- /**
87
- * Enables / Disabels a Nightcore-like filter Effect. Disables/Overwrides both: custom and Vaporwave Filter
88
- * @param speed
89
- * @param pitch
90
- * @param rate
91
- * @returns
92
- */
93
- toggleNightcore(speed?: number, pitch?: number, rate?: number): Promise<boolean>;
94
- /**
95
- * Enables / Disabels a Vaporwave-like filter Effect. Disables/Overwrides both: custom and nightcore Filter
96
- * @param speed
97
- * @param pitch
98
- * @param rate
99
- * @returns
100
- */
101
- toggleVaporwave(speed?: number, pitch?: number, rate?: number): Promise<boolean>;
102
- /**
103
- * Enable / Disables a Karaoke like Filter Effect
104
- * @param level
105
- * @param monoLevel
106
- * @param filterBand
107
- * @param filterWidth
108
- * @returns
109
- */
110
- toggleKaraoke(level?: number, monoLevel?: number, filterBand?: number, filterWidth?: number): Promise<boolean>;
111
- /** Function to find out if currently there is a custom timescamle etc. filter applied */
112
- isCustomFilterActive(): boolean;
113
- /**
114
- * Sets the players equalizer band on-top of the existing ones.
115
- * @param bands
116
- */
117
- setEQ(bands: EQBand | EQBand[]): Promise<this>;
118
- /** Clears the equalizer bands. */
119
- clearEQ(): Promise<this>;
120
- }
121
- export declare const validAudioOutputs: {
122
- mono: {
123
- leftToLeft: number;
124
- leftToRight: number;
125
- rightToLeft: number;
126
- rightToRight: number;
127
- };
128
- stereo: {
129
- leftToLeft: number;
130
- leftToRight: number;
131
- rightToLeft: number;
132
- rightToRight: number;
133
- };
134
- left: {
135
- leftToLeft: number;
136
- leftToRight: number;
137
- rightToLeft: number;
138
- rightToRight: number;
139
- };
140
- right: {
141
- leftToLeft: number;
142
- leftToRight: number;
143
- rightToLeft: number;
144
- rightToRight: number;
145
- };
146
- };
147
- export interface PlayerFilters {
148
- /** Sets nightcore to false, and vaporwave to false */
149
- custom: boolean;
150
- /** Sets custom to false, and vaporwave to false */
151
- nightcore: boolean;
152
- /** Sets custom to false, and nightcore to false */
153
- vaporwave: boolean;
154
- /** only with the custom lavalink filter plugin */
155
- echo: boolean;
156
- /** only with the custom lavalink filter plugin */
157
- reverb: boolean;
158
- rotation: boolean;
159
- karaoke: boolean;
160
- tremolo: boolean;
161
- vibrato: boolean;
162
- lowPass: boolean;
163
- /** audio Output (default stereo, mono sounds the fullest and best for not-stereo tracks) */
164
- audioOutput: AudioOutputs;
165
- /** Lavalink Volume FILTER (not player Volume, think of it as a gain booster) */
166
- volume: boolean;
167
- }
168
- export interface EQBand {
169
- band: number;
170
- gain: number;
171
- }
172
- export interface KaraokeFilter {
173
- level?: number;
174
- monoLevel?: number;
175
- filterBand?: number;
176
- filterWidth?: number;
177
- }
178
- export interface TimescaleFilter {
179
- speed?: number;
180
- pitch?: number;
181
- rate?: number;
182
- }
183
- export interface FreqFilter {
184
- frequency?: number;
185
- depth?: number;
186
- }
187
- export interface RotationFilter {
188
- rotationHz?: number;
189
- }
190
- export interface DistortionFilter {
191
- sinOffset?: number;
192
- sinScale?: number;
193
- cosOffset?: number;
194
- cosScale?: number;
195
- tanOffset?: number;
196
- tanScale?: number;
197
- offset?: number;
198
- scale?: number;
199
- }
200
- export interface ChannelMixFilter {
201
- leftToLeft?: number;
202
- leftToRight?: number;
203
- rightToLeft?: number;
204
- rightToRight?: number;
205
- }
206
- export interface LowPassFilter {
207
- smoothing?: number;
208
- }
209
- export interface EchoFilter {
210
- delay: number;
211
- decay: number;
212
- }
213
- export interface ReverbFilter {
214
- delay: number;
215
- decay: number;
216
- }
217
- export interface LavalinkFilterData {
218
- volume?: number;
219
- equalizer?: EQBand[];
220
- karaoke?: KaraokeFilter;
221
- timescale?: TimescaleFilter;
222
- tremolo?: FreqFilter;
223
- vibrato?: FreqFilter;
224
- rotation?: RotationFilter;
225
- distortion?: DistortionFilter;
226
- channelMix?: ChannelMixFilter;
227
- lowPass?: LowPassFilter;
228
- echo: EchoFilter;
229
- reverb: ReverbFilter;
230
- }