lavalink-client 2.10.0 → 2.10.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.
package/README.md CHANGED
@@ -181,6 +181,8 @@ const node = client.lavalink.lavalinkManager.getNode("id") as NodeLinkNode;
181
181
  node.addMixerLayer()
182
182
  ```
183
183
 
184
+ ⚠️ NODELINK does not really require you to run "instaUpdateFiltersFix" on player creation.
185
+
184
186
  ### NodeLink Specific Methods
185
187
 
186
188
  - **`node.getYoutubeOAUTH(refreshToken)`**: Exchange a Refresh Token for an Access Token. [Docs](https://nodelink.js.org/docs/api/nodelink-features#oauth)
package/dist/index.cjs CHANGED
@@ -1546,10 +1546,8 @@ var LavalinkNode = class _LavalinkNode {
1546
1546
  if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
1547
1547
  if (/^https?:\/\//.test(Query.query))
1548
1548
  return this.search({ query: Query.query, source: Query.source }, requestUser);
1549
- if (!["spsearch", "sprec", "amsearch", "dzsearch", "dzisrc", "ytmsearch", "ytsearch"].includes(Query.source))
1550
- throw new SyntaxError(
1551
- `Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`
1552
- );
1549
+ if (!this.isLavaSrcSource(Query.source))
1550
+ throw new SyntaxError(`Query.source must be an available source from LavaSrc`);
1553
1551
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasearch-plugin"))
1554
1552
  throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
1555
1553
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin"))
@@ -1975,7 +1973,10 @@ var LavalinkNode = class _LavalinkNode {
1975
1973
  throw new RangeError(
1976
1974
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
1977
1975
  );
1978
- const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1976
+ let url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1977
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
1978
+ url = `/loadlyrics?encodedTrack=${track.encoded}`;
1979
+ }
1979
1980
  return await this.request(url);
1980
1981
  },
1981
1982
  /**
@@ -2001,7 +2002,10 @@ var LavalinkNode = class _LavalinkNode {
2001
2002
  throw new RangeError(
2002
2003
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
2003
2004
  );
2004
- const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
2005
+ let url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
2006
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
2007
+ url = `/loadlyrics?encodedTrack=${this._LManager.getPlayer(guildId)?.queue.current?.encoded}`;
2008
+ }
2005
2009
  return await this.request(url);
2006
2010
  },
2007
2011
  /**
@@ -3134,6 +3138,25 @@ var LavalinkNode = class _LavalinkNode {
3134
3138
  this._LManager.emit("LyricsNotFound", player, track, payload);
3135
3139
  return;
3136
3140
  }
3141
+ /**
3142
+ * @private
3143
+ * util function to check if a provided source is valid with current node.
3144
+ * @param {LavalinkSearchPlatform} src
3145
+ * @returns {boolean} True if provided source is valid.
3146
+ */
3147
+ isLavaSrcSource(src) {
3148
+ const source = /* @__PURE__ */ new Set([]);
3149
+ if (this.info?.sourceManagers.includes("spotify")) source.add("spsearch").add("sprec");
3150
+ if (this.info?.sourceManagers.includes("applemusic")) source.add("amsearch");
3151
+ if (this.info?.sourceManagers.includes("deezer")) source.add("dzsearch").add("dzrec").add("dzisrc");
3152
+ if (this.info?.sourceManagers.includes("yandexmusic")) source.add("ymsearch").add("ymrec");
3153
+ if (this.info?.sourceManagers.includes("vkmusic")) source.add("vksearch").add("vkrec");
3154
+ if (this.info?.sourceManagers.includes("tidal")) source.add("tdsearch").add("tdrec");
3155
+ if (this.info?.sourceManagers.includes("qobuz")) source.add("qbsearch").add("qbisrc").add("qbrec");
3156
+ if (this.info?.sourceManagers.includes("pandora")) source.add("pdsearch").add("pdisrc").add("pdrec");
3157
+ if (this.info?.sourceManagers.includes("youtube")) source.add("ytsearch").add("ytmsearch");
3158
+ return typeof src === "string" && source.has(src);
3159
+ }
3137
3160
  };
3138
3161
 
3139
3162
  // src/structures/NodeLink.ts
@@ -6092,7 +6115,7 @@ var Player = class {
6092
6115
  );
6093
6116
  if (this.queue.current || this.queue.tracks.length) {
6094
6117
  const trackSources = new Set(
6095
- [this.queue.current, ...this.queue.tracks].map((track) => track.info.sourceName)
6118
+ [this.queue.current, ...this.queue.tracks].map((track) => track?.info?.sourceName).filter(Boolean)
6096
6119
  );
6097
6120
  const missingSources = [...trackSources].filter(
6098
6121
  (source) => !updateNode.info?.sourceManagers.includes(source)
package/dist/index.d.cts CHANGED
@@ -3680,6 +3680,13 @@ declare class LavalinkNode {
3680
3680
  * @param {LyricsNotFoundEvent} payload The payload of the event
3681
3681
  */
3682
3682
  private LyricsNotFound;
3683
+ /**
3684
+ * @private
3685
+ * util function to check if a provided source is valid with current node.
3686
+ * @param {LavalinkSearchPlatform} src
3687
+ * @returns {boolean} True if provided source is valid.
3688
+ */
3689
+ private isLavaSrcSource;
3683
3690
  }
3684
3691
 
3685
3692
  declare class NodeManager extends EventEmitter {
package/dist/index.d.ts CHANGED
@@ -3680,6 +3680,13 @@ declare class LavalinkNode {
3680
3680
  * @param {LyricsNotFoundEvent} payload The payload of the event
3681
3681
  */
3682
3682
  private LyricsNotFound;
3683
+ /**
3684
+ * @private
3685
+ * util function to check if a provided source is valid with current node.
3686
+ * @param {LavalinkSearchPlatform} src
3687
+ * @returns {boolean} True if provided source is valid.
3688
+ */
3689
+ private isLavaSrcSource;
3683
3690
  }
3684
3691
 
3685
3692
  declare class NodeManager extends EventEmitter {
package/dist/index.js CHANGED
@@ -1481,10 +1481,8 @@ var LavalinkNode = class _LavalinkNode {
1481
1481
  if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
1482
1482
  if (/^https?:\/\//.test(Query.query))
1483
1483
  return this.search({ query: Query.query, source: Query.source }, requestUser);
1484
- if (!["spsearch", "sprec", "amsearch", "dzsearch", "dzisrc", "ytmsearch", "ytsearch"].includes(Query.source))
1485
- throw new SyntaxError(
1486
- `Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`
1487
- );
1484
+ if (!this.isLavaSrcSource(Query.source))
1485
+ throw new SyntaxError(`Query.source must be an available source from LavaSrc`);
1488
1486
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasearch-plugin"))
1489
1487
  throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
1490
1488
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin"))
@@ -1910,7 +1908,10 @@ var LavalinkNode = class _LavalinkNode {
1910
1908
  throw new RangeError(
1911
1909
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
1912
1910
  );
1913
- const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1911
+ let url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1912
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
1913
+ url = `/loadlyrics?encodedTrack=${track.encoded}`;
1914
+ }
1914
1915
  return await this.request(url);
1915
1916
  },
1916
1917
  /**
@@ -1936,7 +1937,10 @@ var LavalinkNode = class _LavalinkNode {
1936
1937
  throw new RangeError(
1937
1938
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
1938
1939
  );
1939
- const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
1940
+ let url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
1941
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
1942
+ url = `/loadlyrics?encodedTrack=${this._LManager.getPlayer(guildId)?.queue.current?.encoded}`;
1943
+ }
1940
1944
  return await this.request(url);
1941
1945
  },
1942
1946
  /**
@@ -3069,6 +3073,25 @@ var LavalinkNode = class _LavalinkNode {
3069
3073
  this._LManager.emit("LyricsNotFound", player, track, payload);
3070
3074
  return;
3071
3075
  }
3076
+ /**
3077
+ * @private
3078
+ * util function to check if a provided source is valid with current node.
3079
+ * @param {LavalinkSearchPlatform} src
3080
+ * @returns {boolean} True if provided source is valid.
3081
+ */
3082
+ isLavaSrcSource(src) {
3083
+ const source = /* @__PURE__ */ new Set([]);
3084
+ if (this.info?.sourceManagers.includes("spotify")) source.add("spsearch").add("sprec");
3085
+ if (this.info?.sourceManagers.includes("applemusic")) source.add("amsearch");
3086
+ if (this.info?.sourceManagers.includes("deezer")) source.add("dzsearch").add("dzrec").add("dzisrc");
3087
+ if (this.info?.sourceManagers.includes("yandexmusic")) source.add("ymsearch").add("ymrec");
3088
+ if (this.info?.sourceManagers.includes("vkmusic")) source.add("vksearch").add("vkrec");
3089
+ if (this.info?.sourceManagers.includes("tidal")) source.add("tdsearch").add("tdrec");
3090
+ if (this.info?.sourceManagers.includes("qobuz")) source.add("qbsearch").add("qbisrc").add("qbrec");
3091
+ if (this.info?.sourceManagers.includes("pandora")) source.add("pdsearch").add("pdisrc").add("pdrec");
3092
+ if (this.info?.sourceManagers.includes("youtube")) source.add("ytsearch").add("ytmsearch");
3093
+ return typeof src === "string" && source.has(src);
3094
+ }
3072
3095
  };
3073
3096
 
3074
3097
  // src/structures/NodeLink.ts
@@ -6027,7 +6050,7 @@ var Player = class {
6027
6050
  );
6028
6051
  if (this.queue.current || this.queue.tracks.length) {
6029
6052
  const trackSources = new Set(
6030
- [this.queue.current, ...this.queue.tracks].map((track) => track.info.sourceName)
6053
+ [this.queue.current, ...this.queue.tracks].map((track) => track?.info?.sourceName).filter(Boolean)
6031
6054
  );
6032
6055
  const missingSources = [...trackSources].filter(
6033
6056
  (source) => !updateNode.info?.sourceManagers.includes(source)
package/dist/index.mjs CHANGED
@@ -1481,10 +1481,8 @@ var LavalinkNode = class _LavalinkNode {
1481
1481
  if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
1482
1482
  if (/^https?:\/\//.test(Query.query))
1483
1483
  return this.search({ query: Query.query, source: Query.source }, requestUser);
1484
- if (!["spsearch", "sprec", "amsearch", "dzsearch", "dzisrc", "ytmsearch", "ytsearch"].includes(Query.source))
1485
- throw new SyntaxError(
1486
- `Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`
1487
- );
1484
+ if (!this.isLavaSrcSource(Query.source))
1485
+ throw new SyntaxError(`Query.source must be an available source from LavaSrc`);
1488
1486
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasearch-plugin"))
1489
1487
  throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
1490
1488
  if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin"))
@@ -1910,7 +1908,10 @@ var LavalinkNode = class _LavalinkNode {
1910
1908
  throw new RangeError(
1911
1909
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
1912
1910
  );
1913
- const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1911
+ let url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1912
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
1913
+ url = `/loadlyrics?encodedTrack=${track.encoded}`;
1914
+ }
1914
1915
  return await this.request(url);
1915
1916
  },
1916
1917
  /**
@@ -1936,7 +1937,10 @@ var LavalinkNode = class _LavalinkNode {
1936
1937
  throw new RangeError(
1937
1938
  `there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`
1938
1939
  );
1939
- const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
1940
+ let url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
1941
+ if (this.nodeType === "NodeLink" /* NodeLink */) {
1942
+ url = `/loadlyrics?encodedTrack=${this._LManager.getPlayer(guildId)?.queue.current?.encoded}`;
1943
+ }
1940
1944
  return await this.request(url);
1941
1945
  },
1942
1946
  /**
@@ -3069,6 +3073,25 @@ var LavalinkNode = class _LavalinkNode {
3069
3073
  this._LManager.emit("LyricsNotFound", player, track, payload);
3070
3074
  return;
3071
3075
  }
3076
+ /**
3077
+ * @private
3078
+ * util function to check if a provided source is valid with current node.
3079
+ * @param {LavalinkSearchPlatform} src
3080
+ * @returns {boolean} True if provided source is valid.
3081
+ */
3082
+ isLavaSrcSource(src) {
3083
+ const source = /* @__PURE__ */ new Set([]);
3084
+ if (this.info?.sourceManagers.includes("spotify")) source.add("spsearch").add("sprec");
3085
+ if (this.info?.sourceManagers.includes("applemusic")) source.add("amsearch");
3086
+ if (this.info?.sourceManagers.includes("deezer")) source.add("dzsearch").add("dzrec").add("dzisrc");
3087
+ if (this.info?.sourceManagers.includes("yandexmusic")) source.add("ymsearch").add("ymrec");
3088
+ if (this.info?.sourceManagers.includes("vkmusic")) source.add("vksearch").add("vkrec");
3089
+ if (this.info?.sourceManagers.includes("tidal")) source.add("tdsearch").add("tdrec");
3090
+ if (this.info?.sourceManagers.includes("qobuz")) source.add("qbsearch").add("qbisrc").add("qbrec");
3091
+ if (this.info?.sourceManagers.includes("pandora")) source.add("pdsearch").add("pdisrc").add("pdrec");
3092
+ if (this.info?.sourceManagers.includes("youtube")) source.add("ytsearch").add("ytmsearch");
3093
+ return typeof src === "string" && source.has(src);
3094
+ }
3072
3095
  };
3073
3096
 
3074
3097
  // src/structures/NodeLink.ts
@@ -6027,7 +6050,7 @@ var Player = class {
6027
6050
  );
6028
6051
  if (this.queue.current || this.queue.tracks.length) {
6029
6052
  const trackSources = new Set(
6030
- [this.queue.current, ...this.queue.tracks].map((track) => track.info.sourceName)
6053
+ [this.queue.current, ...this.queue.tracks].map((track) => track?.info?.sourceName).filter(Boolean)
6031
6054
  );
6032
6055
  const missingSources = [...trackSources].filter(
6033
6056
  (source) => !updateNode.info?.sourceManagers.includes(source)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lavalink-client",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients. - Supports NodeLink@v3 too.",
5
5
  "keywords": [
6
6
  "advanced",