lavalink-client 2.7.4 → 2.7.6

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/dist/index.mjs CHANGED
@@ -44,6 +44,9 @@ var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
44
44
  DebugEvents2["FailedToConnectToNodes"] = "FailedToConnectToNodes";
45
45
  DebugEvents2["NoAudioDebug"] = "NoAudioDebug";
46
46
  DebugEvents2["PlayerAutoReconnect"] = "PlayerAutoReconnect";
47
+ DebugEvents2["PlayerDestroyFail"] = "PlayerDestroyFail";
48
+ DebugEvents2["PlayerChangeNodeFailNoEligibleNode"] = "PlayerChangeNodeFailNoEligibleNode";
49
+ DebugEvents2["PlayerChangeNodeFail"] = "PlayerChangeNodeFail";
47
50
  return DebugEvents2;
48
51
  })(DebugEvents || {});
49
52
  var DestroyReasons = /* @__PURE__ */ ((DestroyReasons2) => {
@@ -687,7 +690,7 @@ var ManagerUtils = class {
687
690
  }
688
691
  validateQueryString(node, queryString, sourceString) {
689
692
  if (!node.info) throw new Error("No Lavalink Node was provided");
690
- if (!node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
693
+ if (this.LavalinkManager.options?.autoChecks?.sourcesValidations && !node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
691
694
  if (!queryString.trim().length) throw new Error(`Query string is empty, please provide a valid query string.`);
692
695
  if (sourceString === "speak" && queryString.length > 100) throw new Error(`Query is speak, which is limited to 100 characters.`);
693
696
  if (this.LavalinkManager.options?.linksBlacklist?.length > 0) {
@@ -716,6 +719,7 @@ var ManagerUtils = class {
716
719
  throw new Error(`Query string contains a link / word which isn't whitelisted.`);
717
720
  }
718
721
  }
722
+ if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
719
723
  if ((SourceLinksRegexes.YoutubeMusicRegex.test(queryString) || SourceLinksRegexes.YoutubeRegex.test(queryString)) && !node.info?.sourceManagers?.includes("youtube")) {
720
724
  throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'youtube' enabled");
721
725
  }
@@ -799,6 +803,7 @@ var ManagerUtils = class {
799
803
  const source = DefaultSources[sourceString.toLowerCase().trim()];
800
804
  if (!source) throw new Error(`Lavalink Node SearchQuerySource: '${sourceString}' is not available`);
801
805
  if (!node.info) throw new Error("Lavalink Node does not have any info cached yet, not ready yet!");
806
+ if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
802
807
  if (source === "amsearch" && !node.info?.sourceManagers?.includes("applemusic")) {
803
808
  throw new Error("Lavalink Node has not 'applemusic' enabled, which is required to have 'amsearch' work");
804
809
  }
@@ -820,7 +825,7 @@ var ManagerUtils = class {
820
825
  if (source === "scsearch" && !node.info?.sourceManagers?.includes("soundcloud")) {
821
826
  throw new Error("Lavalink Node has not 'soundcloud' enabled, which is required to have 'scsearch' work");
822
827
  }
823
- if (source === "speak" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
828
+ if (source === "speak" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
824
829
  throw new Error("Lavalink Node has not 'speak' enabled, which is required to have 'speak' work");
825
830
  }
826
831
  if (source === "tdsearch" && !node.info?.sourceManagers?.includes("tidal")) {
@@ -829,7 +834,7 @@ var ManagerUtils = class {
829
834
  if (source === "tdrec" && !node.info?.sourceManagers?.includes("tidal")) {
830
835
  throw new Error("Lavalink Node has not 'tidal' enabled, which is required to have 'tdrec' work");
831
836
  }
832
- if (source === "tts" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
837
+ if (source === "tts" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
833
838
  throw new Error("Lavalink Node has not 'tts' enabled, which is required to have 'tts' work");
834
839
  }
835
840
  if (source === "ftts" && !(node.info?.sourceManagers?.includes("ftts") || node.info?.sourceManagers?.includes("flowery-tts") || node.info?.sourceManagers?.includes("flowerytts"))) {
@@ -838,7 +843,7 @@ var ManagerUtils = class {
838
843
  if (source === "ymsearch" && !node.info?.sourceManagers?.includes("yandexmusic")) {
839
844
  throw new Error("Lavalink Node has not 'yandexmusic' enabled, which is required to have 'ymsearch' work");
840
845
  }
841
- if (source === "ytmsearch" && !node.info.sourceManagers?.includes("youtube")) {
846
+ if (source === "ytmsearch" && !node.info?.sourceManagers?.includes("youtube")) {
842
847
  throw new Error("Lavalink Node has not 'youtube' enabled, which is required to have 'ytmsearch' work");
843
848
  }
844
849
  if (source === "ytsearch" && !node.info?.sourceManagers?.includes("youtube")) {
@@ -981,9 +986,6 @@ function safeStringify(obj, padding = 0) {
981
986
  var LavalinkNode = class {
982
987
  heartBeatPingTimestamp = 0;
983
988
  heartBeatPongTimestamp = 0;
984
- get heartBeatPing() {
985
- return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
986
- }
987
989
  heartBeatInterval;
988
990
  pingTimeout;
989
991
  isAlive = false;
@@ -1007,6 +1009,17 @@ var LavalinkNode = class {
1007
1009
  used: 0
1008
1010
  },
1009
1011
  uptime: 0,
1012
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
1013
+ detailedStats: {
1014
+ api: {
1015
+ requests: {},
1016
+ errors: {}
1017
+ },
1018
+ sources: {},
1019
+ playback: {
1020
+ events: {}
1021
+ }
1022
+ },
1010
1023
  frameStats: {
1011
1024
  deficit: 0,
1012
1025
  nulled: 0,
@@ -1031,6 +1044,68 @@ var LavalinkNode = class {
1031
1044
  socket = null;
1032
1045
  /** Version of what the Lavalink Server should be */
1033
1046
  version = "v4";
1047
+ /**
1048
+ * Returns the LavalinkManager of the Node
1049
+ */
1050
+ get _LManager() {
1051
+ return this.NodeManager.LavalinkManager;
1052
+ }
1053
+ /**
1054
+ * Returns the Heartbeat Ping of the Node
1055
+ */
1056
+ get heartBeatPing() {
1057
+ return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
1058
+ }
1059
+ /**
1060
+ * Returns wether the plugin validations are enabled or not
1061
+ */
1062
+ get _checkForPlugins() {
1063
+ return !!this._LManager.options?.autoChecks?.pluginValidations;
1064
+ }
1065
+ /**
1066
+ * Returns wether the source validations are enabled or not
1067
+ */
1068
+ get _checkForSources() {
1069
+ return !!this._LManager.options?.autoChecks?.sourcesValidations;
1070
+ }
1071
+ /**
1072
+ * Emits a debug event to the LavalinkManager
1073
+ * @param name name of the event
1074
+ * @param eventData event data
1075
+ */
1076
+ _emitDebugEvent(name, eventData) {
1077
+ if (!this._LManager.options?.advancedOptions?.enableDebugEvents) return;
1078
+ this._LManager.emit("debug", name, eventData);
1079
+ }
1080
+ /**
1081
+ * Returns if connected to the Node.
1082
+ *
1083
+ * @example
1084
+ * ```ts
1085
+ * const isConnected = player.node.connected;
1086
+ * console.log("node is connected: ", isConnected ? "yes" : "no")
1087
+ * ```
1088
+ */
1089
+ get connected() {
1090
+ return this.socket && this.socket.readyState === WebSocket.OPEN;
1091
+ }
1092
+ /**
1093
+ * Returns the current ConnectionStatus
1094
+ *
1095
+ * @example
1096
+ * ```ts
1097
+ * try {
1098
+ * const statusOfConnection = player.node.connectionStatus;
1099
+ * console.log("node's connection status is:", statusOfConnection)
1100
+ * } catch (error) {
1101
+ * console.error("no socket available?", error)
1102
+ * }
1103
+ * ```
1104
+ */
1105
+ get connectionStatus() {
1106
+ if (!this.socket) throw new Error("no websocket was initialized yet");
1107
+ return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
1108
+ }
1034
1109
  /**
1035
1110
  * Create a new Node
1036
1111
  * @param options Lavalink Node Options
@@ -1120,10 +1195,10 @@ var LavalinkNode = class {
1120
1195
  * ```
1121
1196
  */
1122
1197
  async search(query, requestUser, throwOnEmpty = false) {
1123
- const Query = this.NodeManager.LavalinkManager.utils.transformQuery(query);
1124
- this.NodeManager.LavalinkManager.utils.validateQueryString(this, Query.query, Query.source);
1125
- if (Query.source) this.NodeManager.LavalinkManager.utils.validateSourceString(this, Query.source);
1126
- if (["bcsearch", "bandcamp"].includes(Query.source) && !this.info.sourceManagers.includes("bandcamp")) {
1198
+ const Query = this._LManager.utils.transformQuery(query);
1199
+ this._LManager.utils.validateQueryString(this, Query.query, Query.source);
1200
+ if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
1201
+ if (["bcsearch", "bandcamp"].includes(Query.source) && this._LManager.options?.autoChecks?.sourcesValidations && !this.info.sourceManagers.includes("bandcamp")) {
1127
1202
  throw new Error("Bandcamp Search only works on the player (lavaplayer version < 2.2.0!");
1128
1203
  }
1129
1204
  const requestUrl = new URL(`${this.restAddress}/loadtracks`);
@@ -1142,13 +1217,11 @@ var LavalinkNode = class {
1142
1217
  });
1143
1218
  const resTracks = res.loadType === "playlist" ? res.data?.tracks : res.loadType === "track" ? [res.data] : res.loadType === "search" ? Array.isArray(res.data) ? res.data : [res.data] : [];
1144
1219
  if (throwOnEmpty === true && (res.loadType === "empty" || !resTracks.length)) {
1145
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1146
- this.NodeManager.LavalinkManager.emit("debug", "SearchNothingFound" /* SearchNothingFound */, {
1147
- state: "warn",
1148
- message: `Search found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
1149
- functionLayer: "(LavalinkNode > node | player) > search()"
1150
- });
1151
- }
1220
+ this._emitDebugEvent("SearchNothingFound" /* SearchNothingFound */, {
1221
+ state: "warn",
1222
+ message: `Search found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
1223
+ functionLayer: "(LavalinkNode > node | player) > search()"
1224
+ });
1152
1225
  throw new Error("Nothing found");
1153
1226
  }
1154
1227
  return {
@@ -1161,10 +1234,10 @@ var LavalinkNode = class {
1161
1234
  author: res.data.info?.author || res.data.pluginInfo?.author || null,
1162
1235
  thumbnail: res.data.info?.artworkUrl || res.data.pluginInfo?.artworkUrl || (typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? resTracks[res.data?.info?.selectedTrack]?.info?.artworkUrl || resTracks[res.data?.info?.selectedTrack]?.info?.pluginInfo?.artworkUrl : null) || null,
1163
1236
  uri: res.data.info?.url || res.data.info?.uri || res.data.info?.link || res.data.pluginInfo?.url || res.data.pluginInfo?.uri || res.data.pluginInfo?.link || null,
1164
- selectedTrack: typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? this.NodeManager.LavalinkManager.utils.buildTrack(resTracks[res.data?.info?.selectedTrack], requestUser) : null,
1237
+ selectedTrack: typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? this._LManager.utils.buildTrack(resTracks[res.data?.info?.selectedTrack], requestUser) : null,
1165
1238
  duration: resTracks.length ? resTracks.reduce((acc, cur) => acc + (cur?.info?.duration || cur?.info?.length || 0), 0) : 0
1166
1239
  } : null,
1167
- tracks: resTracks.length ? resTracks.map((t) => this.NodeManager.LavalinkManager.utils.buildTrack(t, requestUser)) : []
1240
+ tracks: resTracks.length ? resTracks.map((t) => this._LManager.utils.buildTrack(t, requestUser)) : []
1168
1241
  };
1169
1242
  }
1170
1243
  /**
@@ -1181,29 +1254,27 @@ var LavalinkNode = class {
1181
1254
  * ```
1182
1255
  */
1183
1256
  async lavaSearch(query, requestUser, throwOnEmpty = false) {
1184
- const Query = this.NodeManager.LavalinkManager.utils.transformLavaSearchQuery(query);
1185
- if (Query.source) this.NodeManager.LavalinkManager.utils.validateSourceString(this, Query.source);
1257
+ const Query = this._LManager.utils.transformLavaSearchQuery(query);
1258
+ if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
1186
1259
  if (/^https?:\/\//.test(Query.query)) return this.search({ query: Query.query, source: Query.source }, requestUser);
1187
1260
  if (!["spsearch", "sprec", "amsearch", "dzsearch", "dzisrc", "ytmsearch", "ytsearch"].includes(Query.source)) throw new SyntaxError(`Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`);
1188
- if (!this.info.plugins.find((v) => v.name === "lavasearch-plugin")) throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
1189
- if (!this.info.plugins.find((v) => v.name === "lavasrc-plugin")) throw new RangeError(`there is no lavasrc-plugin available in the lavalink node: ${this.id}`);
1261
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasearch-plugin")) throw new RangeError(`there is no lavasearch-plugin available in the lavalink node: ${this.id}`);
1262
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin")) throw new RangeError(`there is no lavasrc-plugin available in the lavalink node: ${this.id}`);
1190
1263
  const { response } = await this.rawRequest(`/loadsearch?query=${Query.source ? `${Query.source}:` : ""}${encodeURIComponent(Query.query)}${Query.types?.length ? `&types=${Query.types.join(",")}` : ""}`);
1191
1264
  const res = response.status === 204 ? {} : await response.json();
1192
1265
  if (throwOnEmpty === true && !Object.entries(res).flat().filter(Boolean).length) {
1193
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1194
- this.NodeManager.LavalinkManager.emit("debug", "LavaSearchNothingFound" /* LavaSearchNothingFound */, {
1195
- state: "warn",
1196
- message: `LavaSearch found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
1197
- functionLayer: "(LavalinkNode > node | player) > lavaSearch()"
1198
- });
1199
- }
1266
+ this._emitDebugEvent("LavaSearchNothingFound" /* LavaSearchNothingFound */, {
1267
+ state: "warn",
1268
+ message: `LavaSearch found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
1269
+ functionLayer: "(LavalinkNode > node | player) > lavaSearch()"
1270
+ });
1200
1271
  throw new Error("Nothing found");
1201
1272
  }
1202
1273
  return {
1203
- tracks: res.tracks?.map((v) => this.NodeManager.LavalinkManager.utils.buildTrack(v, requestUser)) || [],
1204
- albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.NodeManager.LavalinkManager.utils.buildTrack(v2, requestUser)) })) || [],
1205
- artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.NodeManager.LavalinkManager.utils.buildTrack(v2, requestUser)) })) || [],
1206
- playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.NodeManager.LavalinkManager.utils.buildTrack(v2, requestUser)) })) || [],
1274
+ tracks: res.tracks?.map((v) => this._LManager.utils.buildTrack(v, requestUser)) || [],
1275
+ albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
1276
+ artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
1277
+ playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
1207
1278
  texts: res.texts?.map((v) => ({ text: v.text, pluginInfo: v?.plugin || v.pluginInfo })) || [],
1208
1279
  pluginInfo: res.pluginInfo || res?.plugin
1209
1280
  };
@@ -1232,13 +1303,11 @@ var LavalinkNode = class {
1232
1303
  r.path = url.pathname + url.search;
1233
1304
  }
1234
1305
  });
1235
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1236
- this.NodeManager.LavalinkManager.emit("debug", "PlayerUpdateSuccess" /* PlayerUpdateSuccess */, {
1237
- state: "log",
1238
- message: `Player get's updated with following payload :: ${safeStringify(data.playerOptions, 3)}`,
1239
- functionLayer: "LavalinkNode > node > updatePlayer()"
1240
- });
1241
- }
1306
+ this._emitDebugEvent("PlayerUpdateSuccess" /* PlayerUpdateSuccess */, {
1307
+ state: "log",
1308
+ message: `Player get's updated with following payload :: ${safeStringify(data.playerOptions, 3)}`,
1309
+ functionLayer: "LavalinkNode > node > updatePlayer()"
1310
+ });
1242
1311
  this.syncPlayerData({}, res);
1243
1312
  return res;
1244
1313
  }
@@ -1274,19 +1343,17 @@ var LavalinkNode = class {
1274
1343
  */
1275
1344
  connect(sessionId) {
1276
1345
  if (this.connected) {
1277
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1278
- this.NodeManager.LavalinkManager.emit("debug", "TryingConnectWhileConnected" /* TryingConnectWhileConnected */, {
1279
- state: "warn",
1280
- message: `Tryed to connect to node, but it's already connected!`,
1281
- functionLayer: "LavalinkNode > node > connect()"
1282
- });
1283
- }
1346
+ this._emitDebugEvent("TryingConnectWhileConnected" /* TryingConnectWhileConnected */, {
1347
+ state: "warn",
1348
+ message: `Tryed to connect to node, but it's already connected!`,
1349
+ functionLayer: "LavalinkNode > node > connect()"
1350
+ });
1284
1351
  return;
1285
1352
  }
1286
1353
  const headers = {
1287
1354
  Authorization: this.options.authorization,
1288
- "User-Id": this.NodeManager.LavalinkManager.options.client.id,
1289
- "Client-Name": this.NodeManager.LavalinkManager.options.client.username || "Lavalink-Client"
1355
+ "User-Id": this._LManager.options.client.id,
1356
+ "Client-Name": this._LManager.options.client.username || "Lavalink-Client"
1290
1357
  };
1291
1358
  if (typeof this.options.sessionId === "string" || typeof sessionId === "string") {
1292
1359
  headers["Session-Id"] = this.options.sessionId || sessionId;
@@ -1299,34 +1366,27 @@ var LavalinkNode = class {
1299
1366
  this.socket.on("error", this.error.bind(this));
1300
1367
  }
1301
1368
  heartBeat() {
1302
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1303
- this.NodeManager.LavalinkManager.emit("debug", "HeartBeatTriggered" /* HeartBeatTriggered */, {
1304
- state: "log",
1305
- message: `Node Socket Heartbeat triggered, resetting old Timeout to 65000ms (should happen every 60s due to /stats event)`,
1306
- functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat()"
1307
- });
1308
- }
1369
+ this._emitDebugEvent("HeartBeatTriggered" /* HeartBeatTriggered */, {
1370
+ state: "log",
1371
+ message: `Node Socket Heartbeat triggered, resetting old Timeout to 65000ms (should happen every 60s due to /stats event)`,
1372
+ functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat()"
1373
+ });
1309
1374
  this.resetAckTimeouts(false, true);
1310
1375
  if (this.pingTimeout) clearTimeout(this.pingTimeout);
1311
1376
  this.pingTimeout = setTimeout(() => {
1312
1377
  this.pingTimeout = null;
1313
1378
  if (!this.socket) {
1314
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1315
- this.NodeManager.LavalinkManager.emit("debug", "NoSocketOnDestroy" /* NoSocketOnDestroy */, {
1316
- state: "error",
1317
- message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
1318
- functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
1319
- });
1320
- }
1321
- return;
1322
- }
1323
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1324
- this.NodeManager.LavalinkManager.emit("debug", "SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
1325
- state: "warn",
1326
- message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
1379
+ return this._emitDebugEvent("NoSocketOnDestroy" /* NoSocketOnDestroy */, {
1380
+ state: "error",
1381
+ message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
1327
1382
  functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
1328
1383
  });
1329
1384
  }
1385
+ this._emitDebugEvent("SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
1386
+ state: "warn",
1387
+ message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
1388
+ functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
1389
+ });
1330
1390
  this.isAlive = false;
1331
1391
  this.socket.terminate();
1332
1392
  }, 65e3);
@@ -1362,71 +1422,75 @@ var LavalinkNode = class {
1362
1422
  */
1363
1423
  destroy(destroyReason, deleteNode = true, movePlayers = false) {
1364
1424
  this.reconnectionState = "IDLE" /* IDLE */;
1365
- const players = this.NodeManager.LavalinkManager.players.filter((p) => p.node.id === this.id);
1366
- if (players.size) {
1367
- const enableDebugEvents = this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents;
1368
- const handlePlayerOperations = () => {
1369
- if (movePlayers) {
1370
- const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
1371
- if (nodeToMove) {
1372
- return Promise.allSettled(Array.from(players.values()).map(
1373
- (player) => player.changeNode(nodeToMove.options.id).catch((error) => {
1374
- if (enableDebugEvents) {
1375
- console.error(`Node > destroy() Failed to move player ${player.guildId}: ${error.message}`);
1376
- }
1377
- return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
1378
- if (enableDebugEvents) {
1379
- console.error(`Node > destroy() Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`);
1380
- }
1381
- });
1382
- })
1383
- ));
1384
- } else {
1385
- return Promise.allSettled(Array.from(players.values()).map(
1386
- (player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
1387
- if (enableDebugEvents) {
1388
- console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
1389
- }
1390
- })
1391
- ));
1392
- }
1393
- } else {
1394
- return Promise.allSettled(Array.from(players.values()).map(
1395
- (player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
1396
- if (enableDebugEvents) {
1397
- console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
1398
- }
1399
- })
1400
- ));
1401
- }
1402
- };
1403
- handlePlayerOperations().finally(() => {
1404
- this.socket?.close(1e3, "Node-Destroy");
1405
- this.socket?.removeAllListeners();
1406
- this.socket = null;
1407
- this.resetReconnectionAttempts();
1408
- if (deleteNode) {
1409
- this.NodeManager.emit("destroy", this, destroyReason);
1410
- this.NodeManager.nodes.delete(this.id);
1411
- this.resetAckTimeouts(true, true);
1412
- } else {
1413
- this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
1414
- }
1415
- });
1416
- } else {
1425
+ const players = this._LManager.players.filter((p) => p.node.id === this.id);
1426
+ if (!players?.size) {
1417
1427
  this.socket?.close(1e3, "Node-Destroy");
1418
1428
  this.socket?.removeAllListeners();
1419
1429
  this.socket = null;
1420
1430
  this.resetReconnectionAttempts();
1421
- if (deleteNode) {
1422
- this.NodeManager.emit("destroy", this, destroyReason);
1423
- this.NodeManager.nodes.delete(this.id);
1424
- this.resetAckTimeouts(true, true);
1425
- } else {
1426
- this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
1427
- }
1431
+ if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
1432
+ ;
1433
+ this.NodeManager.emit("destroy", this, destroyReason);
1434
+ this.NodeManager.nodes.delete(this.id);
1435
+ this.resetAckTimeouts(true, true);
1436
+ return;
1428
1437
  }
1429
- return;
1438
+ const handlePlayerOperations = () => {
1439
+ if (!movePlayers) {
1440
+ return Promise.allSettled(Array.from(players.values()).map(
1441
+ (player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
1442
+ this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
1443
+ state: "error",
1444
+ message: `Failed to destroy player ${player.guildId}: ${error.message}`,
1445
+ error,
1446
+ functionLayer: "Node > destroy() > movePlayers"
1447
+ });
1448
+ })
1449
+ ));
1450
+ }
1451
+ const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
1452
+ if (!nodeToMove) {
1453
+ return Promise.allSettled(Array.from(players.values()).map(
1454
+ (player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
1455
+ this._emitDebugEvent("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */, {
1456
+ state: "error",
1457
+ message: `Failed to destroy player ${player.guildId}: ${error.message}`,
1458
+ error,
1459
+ functionLayer: "Node > destroy() > movePlayers"
1460
+ });
1461
+ })
1462
+ ));
1463
+ }
1464
+ return Promise.allSettled(Array.from(players.values()).map(
1465
+ (player) => player.changeNode(nodeToMove.options.id).catch((error) => {
1466
+ this._emitDebugEvent("PlayerChangeNodeFail" /* PlayerChangeNodeFail */, {
1467
+ state: "error",
1468
+ message: `Failed to move player ${player.guildId}: ${error.message}`,
1469
+ error,
1470
+ functionLayer: "Node > destroy() > movePlayers"
1471
+ });
1472
+ return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
1473
+ this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
1474
+ state: "error",
1475
+ message: `Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`,
1476
+ error: destroyError,
1477
+ functionLayer: "Node > destroy() > movePlayers"
1478
+ });
1479
+ });
1480
+ })
1481
+ ));
1482
+ };
1483
+ return void handlePlayerOperations().finally(() => {
1484
+ this.socket?.close(1e3, "Node-Destroy");
1485
+ this.socket?.removeAllListeners();
1486
+ this.socket = null;
1487
+ this.resetReconnectionAttempts();
1488
+ if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
1489
+ this.NodeManager.emit("destroy", this, destroyReason);
1490
+ this.NodeManager.nodes.delete(this.id);
1491
+ this.resetAckTimeouts(true, true);
1492
+ return;
1493
+ });
1430
1494
  }
1431
1495
  /**
1432
1496
  * Disconnects the Node-Connection (Websocket)
@@ -1449,35 +1513,6 @@ var LavalinkNode = class {
1449
1513
  this.resetReconnectionAttempts();
1450
1514
  this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
1451
1515
  }
1452
- /**
1453
- * Returns if connected to the Node.
1454
- *
1455
- * @example
1456
- * ```ts
1457
- * const isConnected = player.node.connected;
1458
- * console.log("node is connected: ", isConnected ? "yes" : "no")
1459
- * ```
1460
- */
1461
- get connected() {
1462
- return this.socket && this.socket.readyState === WebSocket.OPEN;
1463
- }
1464
- /**
1465
- * Returns the current ConnectionStatus
1466
- *
1467
- * @example
1468
- * ```ts
1469
- * try {
1470
- * const statusOfConnection = player.node.connectionStatus;
1471
- * console.log("node's connection status is:", statusOfConnection)
1472
- * } catch (error) {
1473
- * console.error("no socket available?", error)
1474
- * }
1475
- * ```
1476
- */
1477
- get connectionStatus() {
1478
- if (!this.socket) throw new Error("no websocket was initialized yet");
1479
- return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
1480
- }
1481
1516
  /**
1482
1517
  * Gets all Players of a Node
1483
1518
  * @returns array of players inside of lavalink
@@ -1551,7 +1586,7 @@ var LavalinkNode = class {
1551
1586
  */
1552
1587
  singleTrack: async (encoded, requester) => {
1553
1588
  if (!encoded) throw new SyntaxError("No encoded (Base64 string) was provided");
1554
- return this.NodeManager.LavalinkManager.utils?.buildTrack(await this.request(`/decodetrack?encodedTrack=${encodeURIComponent(encoded.replace(/\s/g, ""))}`), requester);
1589
+ return this._LManager.utils?.buildTrack(await this.request(`/decodetrack?encodedTrack=${encodeURIComponent(encoded.replace(/\s/g, ""))}`), requester);
1555
1590
  },
1556
1591
  /**
1557
1592
  * Decodes multiple tracks into their info
@@ -1572,7 +1607,7 @@ var LavalinkNode = class {
1572
1607
  r.method = "POST";
1573
1608
  r.body = safeStringify(encodeds);
1574
1609
  r.headers["Content-Type"] = "application/json";
1575
- }).then((r) => r.map((track) => this.NodeManager.LavalinkManager.utils.buildTrack(track, requester)));
1610
+ }).then((r) => r.map((track) => this._LManager.utils.buildTrack(track, requester)));
1576
1611
  }
1577
1612
  };
1578
1613
  lyrics = {
@@ -1591,8 +1626,8 @@ var LavalinkNode = class {
1591
1626
  */
1592
1627
  get: async (track, skipTrackSource = false) => {
1593
1628
  if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
1594
- if (!this.info.plugins.find((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1595
- if (!this.info.plugins.find((v) => v.name === "lavasrc-plugin") && !this.info.plugins.find((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
1629
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1630
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin") && this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
1596
1631
  const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
1597
1632
  return await this.request(url);
1598
1633
  },
@@ -1611,8 +1646,8 @@ var LavalinkNode = class {
1611
1646
  */
1612
1647
  getCurrent: async (guildId, skipTrackSource = false) => {
1613
1648
  if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
1614
- if (!this.info.plugins.find((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1615
- if (!this.info.plugins.find((v) => v.name === "lavasrc-plugin") && !this.info.plugins.find((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
1649
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1650
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin") && this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
1616
1651
  const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
1617
1652
  return await this.request(url);
1618
1653
  },
@@ -1630,7 +1665,7 @@ var LavalinkNode = class {
1630
1665
  */
1631
1666
  subscribe: async (guildId) => {
1632
1667
  if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
1633
- if (!this.info.plugins.find((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1668
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1634
1669
  return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
1635
1670
  options.method = "POST";
1636
1671
  });
@@ -1649,7 +1684,7 @@ var LavalinkNode = class {
1649
1684
  */
1650
1685
  unsubscribe: async (guildId) => {
1651
1686
  if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
1652
- if (!this.info.plugins.find((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1687
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
1653
1688
  return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
1654
1689
  options.method = "DELETE";
1655
1690
  });
@@ -1667,6 +1702,19 @@ var LavalinkNode = class {
1667
1702
  async fetchStats() {
1668
1703
  return await this.request(`/stats`);
1669
1704
  }
1705
+ /**
1706
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
1707
+ * @returns the connection metrics of the node
1708
+ *
1709
+ * @example
1710
+ * ```ts
1711
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
1712
+ * ```
1713
+ */
1714
+ async fetchConnectionMetrics() {
1715
+ if (this.info && !this.info.isNodelink) throw new Error("There is no Information about wether you are using NodeLink instead of Lavalink, so this function won't work");
1716
+ return await this.request(`/connection`);
1717
+ }
1670
1718
  /**
1671
1719
  * Request Lavalink version.
1672
1720
  * @returns the current used lavalink version
@@ -1763,7 +1811,7 @@ var LavalinkNode = class {
1763
1811
  */
1764
1812
  syncPlayerData(data, res) {
1765
1813
  if (typeof data === "object" && typeof data?.guildId === "string" && typeof data.playerOptions === "object" && Object.keys(data.playerOptions).length > 0) {
1766
- const player = this.NodeManager.LavalinkManager.getPlayer(data.guildId);
1814
+ const player = this._LManager.getPlayer(data.guildId);
1767
1815
  if (!player) return;
1768
1816
  if (typeof data.playerOptions.paused !== "undefined") {
1769
1817
  player.paused = data.playerOptions.paused;
@@ -1775,8 +1823,8 @@ var LavalinkNode = class {
1775
1823
  }
1776
1824
  if (typeof data.playerOptions.voice !== "undefined") player.voice = data.playerOptions.voice;
1777
1825
  if (typeof data.playerOptions.volume !== "undefined") {
1778
- if (this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer) {
1779
- player.volume = Math.round(data.playerOptions.volume / this.NodeManager.LavalinkManager.options.playerOptions.volumeDecrementer);
1826
+ if (this._LManager.options.playerOptions.volumeDecrementer) {
1827
+ player.volume = Math.round(data.playerOptions.volume / this._LManager.options.playerOptions.volumeDecrementer);
1780
1828
  player.lavalinkVolume = Math.round(data.playerOptions.volume);
1781
1829
  } else {
1782
1830
  player.volume = Math.round(data.playerOptions.volume);
@@ -1800,7 +1848,7 @@ var LavalinkNode = class {
1800
1848
  }
1801
1849
  }
1802
1850
  if (res?.guildId === "string" && typeof res?.voice !== "undefined") {
1803
- const player = this.NodeManager.LavalinkManager.getPlayer(data.guildId);
1851
+ const player = this._LManager.getPlayer(data.guildId);
1804
1852
  if (!player) return;
1805
1853
  if (typeof res?.voice?.connected === "boolean" && res.voice.connected === false) {
1806
1854
  player.destroy("LavalinkNoVoice" /* LavalinkNoVoice */);
@@ -1921,6 +1969,7 @@ var LavalinkNode = class {
1921
1969
  const errorString = `Lavalink Node (${this.restAddress}) does not provide any /${this.version}/info`;
1922
1970
  throw new Error(errorString);
1923
1971
  }
1972
+ this.info.isNodelink = !!this.info.isNodelink;
1924
1973
  this.NodeManager.emit("connect", this);
1925
1974
  }
1926
1975
  /** @private util function for handling closing events from websocket */
@@ -1933,7 +1982,7 @@ var LavalinkNode = class {
1933
1982
  }
1934
1983
  } catch (e) {
1935
1984
  if (this.NodeManager?.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
1936
- this.NodeManager.LavalinkManager.emit("debug", "SocketCleanupError" /* SocketCleanupError */, {
1985
+ this._LManager.emit("debug", "SocketCleanupError" /* SocketCleanupError */, {
1937
1986
  state: "warn",
1938
1987
  message: `An error occurred during socket cleanup in close() (likely a race condition): ${e.message}`,
1939
1988
  functionLayer: "LavalinkNode > close()"
@@ -1949,9 +1998,9 @@ var LavalinkNode = class {
1949
1998
  this.reconnect();
1950
1999
  }
1951
2000
  }
1952
- this.NodeManager.LavalinkManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
1953
- if (!this.NodeManager.LavalinkManager.options.autoMove) return p.playing = false;
1954
- if (this.NodeManager.LavalinkManager.options.autoMove) {
2001
+ this._LManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
2002
+ if (!this._LManager.options.autoMove) return p.playing = false;
2003
+ if (this._LManager.options.autoMove) {
1955
2004
  if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
1956
2005
  return p.playing = false;
1957
2006
  p.moveNode();
@@ -1992,17 +2041,12 @@ var LavalinkNode = class {
1992
2041
  break;
1993
2042
  case "playerUpdate":
1994
2043
  {
1995
- const player = this.NodeManager.LavalinkManager.getPlayer(payload.guildId);
1996
- if (!player) {
1997
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
1998
- this.NodeManager.LavalinkManager.emit("debug", "PlayerUpdateNoPlayer" /* PlayerUpdateNoPlayer */, {
1999
- state: "error",
2000
- message: `PlayerUpdate Event Triggered, but no player found of payload.guildId: ${payload.guildId}`,
2001
- functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
2002
- });
2003
- }
2004
- return;
2005
- }
2044
+ const player = this._LManager.getPlayer(payload.guildId);
2045
+ if (!player) return this._emitDebugEvent("PlayerUpdateNoPlayer" /* PlayerUpdateNoPlayer */, {
2046
+ state: "error",
2047
+ message: `PlayerUpdate Event Triggered, but no player found of payload.guildId: ${payload.guildId}`,
2048
+ functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
2049
+ });
2006
2050
  const oldPlayer = player?.toJSON();
2007
2051
  player.lastPositionChange = Date.now();
2008
2052
  player.lastPosition = payload.state.position || 0;
@@ -2011,16 +2055,14 @@ var LavalinkNode = class {
2011
2055
  if (!player.createdTimeStamp && payload.state.time) player.createdTimeStamp = payload.state.time;
2012
2056
  if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && isAbsolute(player.queue.current?.info?.uri))) {
2013
2057
  player.filterManager.filterUpdatedState = false;
2014
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2015
- this.NodeManager.LavalinkManager.emit("debug", "PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
2016
- state: "log",
2017
- message: `Fixing FilterState on "${player.guildId}" because player.options.instaUpdateFiltersFix === true`,
2018
- functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
2019
- });
2020
- }
2058
+ this._emitDebugEvent("PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
2059
+ state: "log",
2060
+ message: `Fixing FilterState on "${player.guildId}" because player.options.instaUpdateFiltersFix === true`,
2061
+ functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
2062
+ });
2021
2063
  await player.seek(player.position);
2022
2064
  }
2023
- this.NodeManager.LavalinkManager.emit("playerUpdate", oldPlayer, player);
2065
+ this._LManager.emit("playerUpdate", oldPlayer, player);
2024
2066
  }
2025
2067
  break;
2026
2068
  case "event":
@@ -2034,14 +2076,12 @@ var LavalinkNode = class {
2034
2076
  try {
2035
2077
  this.NodeManager.emit("resumed", this, payload, await this.fetchAllPlayers());
2036
2078
  } catch (e) {
2037
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2038
- this.NodeManager.LavalinkManager.emit("debug", "ResumingFetchingError" /* ResumingFetchingError */, {
2039
- state: "error",
2040
- message: `Failed to fetch players for resumed event, falling back without players array`,
2041
- error: e,
2042
- functionLayer: "LavalinkNode > nodeEvent > resumed"
2043
- });
2044
- }
2079
+ this._emitDebugEvent("ResumingFetchingError" /* ResumingFetchingError */, {
2080
+ state: "error",
2081
+ message: `Failed to fetch players for resumed event, falling back without players array`,
2082
+ error: e,
2083
+ functionLayer: "LavalinkNode > nodeEvent > resumed"
2084
+ });
2045
2085
  this.NodeManager.emit("resumed", this, payload, []);
2046
2086
  }
2047
2087
  }
@@ -2054,7 +2094,7 @@ var LavalinkNode = class {
2054
2094
  /** @private middleware util function for handling all kind of events from websocket */
2055
2095
  async handleEvent(payload) {
2056
2096
  if (!payload?.guildId) return;
2057
- const player = this.NodeManager.LavalinkManager.getPlayer(payload.guildId);
2097
+ const player = this._LManager.getPlayer(payload.guildId);
2058
2098
  if (!player) return;
2059
2099
  switch (payload.type) {
2060
2100
  case "TrackStartEvent":
@@ -2100,7 +2140,7 @@ var LavalinkNode = class {
2100
2140
  return;
2101
2141
  }
2102
2142
  getTrackOfPayload(payload) {
2103
- return "track" in payload ? this.NodeManager.LavalinkManager.utils.buildTrack(payload.track, void 0) : null;
2143
+ return "track" in payload ? this._LManager.utils.buildTrack(payload.track, void 0) : null;
2104
2144
  }
2105
2145
  /** @private util function for handling trackStart event */
2106
2146
  async trackStart(player, track, payload) {
@@ -2108,31 +2148,26 @@ var LavalinkNode = class {
2108
2148
  player.playing = true;
2109
2149
  player.paused = false;
2110
2150
  }
2111
- if (this.NodeManager.LavalinkManager.options?.emitNewSongsOnly === true && player.queue.previous[0]?.info?.identifier === track?.info?.identifier) {
2112
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2113
- this.NodeManager.LavalinkManager.emit("debug", "TrackStartNewSongsOnly" /* TrackStartNewSongsOnly */, {
2114
- state: "log",
2115
- message: `TrackStart not Emitting, because playing the previous song again.`,
2116
- functionLayer: "LavalinkNode > trackStart()"
2117
- });
2118
- }
2119
- return;
2151
+ if (this._LManager.options?.emitNewSongsOnly === true && player.queue.previous[0]?.info?.identifier === track?.info?.identifier) {
2152
+ return this._emitDebugEvent("TrackStartNewSongsOnly" /* TrackStartNewSongsOnly */, {
2153
+ state: "log",
2154
+ message: `TrackStart not Emitting, because playing the previous song again.`,
2155
+ functionLayer: "LavalinkNode > trackStart()"
2156
+ });
2120
2157
  }
2121
2158
  if (!player.queue.current) {
2122
2159
  player.queue.current = this.getTrackOfPayload(payload);
2123
2160
  if (player.queue.current) {
2124
2161
  await player.queue.utils.save();
2125
2162
  } else {
2126
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2127
- this.NodeManager.LavalinkManager.emit("debug", "TrackStartNoTrack" /* TrackStartNoTrack */, {
2128
- state: "warn",
2129
- message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2130
- functionLayer: "LavalinkNode > trackStart()"
2131
- });
2132
- }
2163
+ this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
2164
+ state: "warn",
2165
+ message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2166
+ functionLayer: "LavalinkNode > trackStart()"
2167
+ });
2133
2168
  }
2134
2169
  }
2135
- this.NodeManager.LavalinkManager.emit("trackStart", player, player.queue.current, payload);
2170
+ this._LManager.emit("trackStart", player, player.queue.current, payload);
2136
2171
  return;
2137
2172
  }
2138
2173
  /** @private util function for handling trackEnd event */
@@ -2140,14 +2175,12 @@ var LavalinkNode = class {
2140
2175
  if (player.get("internal_nodeChanging") === true) return;
2141
2176
  const trackToUse = track || this.getTrackOfPayload(payload);
2142
2177
  if (payload.reason === "replaced") {
2143
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2144
- this.NodeManager.LavalinkManager.emit("debug", "TrackEndReplaced" /* TrackEndReplaced */, {
2145
- state: "warn",
2146
- message: `TrackEnd Event does not handle any playback, because the track was replaced.`,
2147
- functionLayer: "LavalinkNode > trackEnd()"
2148
- });
2149
- }
2150
- this.NodeManager.LavalinkManager.emit("trackEnd", player, trackToUse, payload);
2178
+ this._emitDebugEvent("TrackEndReplaced" /* TrackEndReplaced */, {
2179
+ state: "warn",
2180
+ message: `TrackEnd Event does not handle any playback, because the track was replaced.`,
2181
+ functionLayer: "LavalinkNode > trackEnd()"
2182
+ });
2183
+ this._LManager.emit("trackEnd", player, trackToUse, payload);
2151
2184
  return;
2152
2185
  }
2153
2186
  if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) return this.queueEnd(player, track, payload);
@@ -2155,8 +2188,8 @@ var LavalinkNode = class {
2155
2188
  if (player.get("internal_destroystatus") === true) return;
2156
2189
  await queueTrackEnd(player);
2157
2190
  if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
2158
- this.NodeManager.LavalinkManager.emit("trackEnd", player, trackToUse, payload);
2159
- if (this.NodeManager.LavalinkManager.options.autoSkip && player.queue.current) {
2191
+ this._LManager.emit("trackEnd", player, trackToUse, payload);
2192
+ if (this._LManager.options.autoSkip && player.queue.current) {
2160
2193
  player.play({ noReplace: true });
2161
2194
  }
2162
2195
  return;
@@ -2169,30 +2202,28 @@ var LavalinkNode = class {
2169
2202
  }
2170
2203
  if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
2171
2204
  player.set("internal_skipped", false);
2172
- this.NodeManager.LavalinkManager.emit("trackEnd", player, trackToUse, payload);
2173
- if (this.NodeManager.LavalinkManager.options.autoSkip && player.queue.current) {
2205
+ this._LManager.emit("trackEnd", player, trackToUse, payload);
2206
+ if (this._LManager.options.autoSkip && player.queue.current) {
2174
2207
  player.play({ noReplace: true });
2175
2208
  }
2176
2209
  return;
2177
2210
  }
2178
2211
  /** @private util function for handling trackStuck event */
2179
2212
  async trackStuck(player, track, payload) {
2180
- if (this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
2181
- const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold);
2213
+ if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
2214
+ const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
2182
2215
  player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
2183
- if (oldTimestamps.length > this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
2184
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2185
- this.NodeManager.LavalinkManager.emit("debug", "TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */, {
2186
- state: "log",
2187
- message: `trackStuck Event was triggered too often within a given threshold (LavalinkManager.options.playerOptions.maxErrorsPerTime). Threshold: "${this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold}ms", maxAmount: "${this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount}"`,
2188
- functionLayer: "LavalinkNode > trackStuck()"
2189
- });
2190
- }
2216
+ if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
2217
+ this._emitDebugEvent("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */, {
2218
+ state: "log",
2219
+ message: `trackStuck Event was triggered too often within a given threshold (LavalinkManager.options.playerOptions.maxErrorsPerTime). Threshold: "${this._LManager.options.playerOptions.maxErrorsPerTime?.threshold}ms", maxAmount: "${this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount}"`,
2220
+ functionLayer: "LavalinkNode > trackStuck()"
2221
+ });
2191
2222
  player.destroy("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */);
2192
2223
  return;
2193
2224
  }
2194
2225
  }
2195
- this.NodeManager.LavalinkManager.emit("trackStuck", player, track || this.getTrackOfPayload(payload), payload);
2226
+ this._LManager.emit("trackStuck", player, track || this.getTrackOfPayload(payload), payload);
2196
2227
  if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) {
2197
2228
  try {
2198
2229
  await player.node.updatePlayer({ guildId: player.guildId, playerOptions: { track: { encoded: null } } });
@@ -2205,54 +2236,52 @@ var LavalinkNode = class {
2205
2236
  if (!player.queue.current) {
2206
2237
  return this.queueEnd(player, track || this.getTrackOfPayload(payload), payload);
2207
2238
  }
2208
- if (this.NodeManager.LavalinkManager.options.autoSkip && player.queue.current) {
2239
+ if (this._LManager.options.autoSkip && player.queue.current) {
2209
2240
  player.play({ track: player.queue.current, noReplace: false });
2210
2241
  }
2211
2242
  return;
2212
2243
  }
2213
2244
  /** @private util function for handling trackError event */
2214
2245
  async trackError(player, track, payload) {
2215
- if (this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
2216
- const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold);
2246
+ if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
2247
+ const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
2217
2248
  player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
2218
- if (oldTimestamps.length > this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
2219
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2220
- this.NodeManager.LavalinkManager.emit("debug", "TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */, {
2221
- state: "log",
2222
- message: `TrackError Event was triggered too often within a given threshold (LavalinkManager.options.playerOptions.maxErrorsPerTime). Threshold: "${this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.threshold}ms", maxAmount: "${this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime?.maxAmount}"`,
2223
- functionLayer: "LavalinkNode > trackError()"
2224
- });
2225
- }
2249
+ if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
2250
+ this._emitDebugEvent("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */, {
2251
+ state: "log",
2252
+ message: `TrackError Event was triggered too often within a given threshold (LavalinkManager.options.playerOptions.maxErrorsPerTime). Threshold: "${this._LManager.options.playerOptions.maxErrorsPerTime?.threshold}ms", maxAmount: "${this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount}"`,
2253
+ functionLayer: "LavalinkNode > trackError()"
2254
+ });
2226
2255
  player.destroy("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */);
2227
2256
  return;
2228
2257
  }
2229
2258
  }
2230
- this.NodeManager.LavalinkManager.emit("trackError", player, track || this.getTrackOfPayload(payload), payload);
2259
+ this._LManager.emit("trackError", player, track || this.getTrackOfPayload(payload), payload);
2231
2260
  return;
2232
2261
  }
2233
2262
  /** @private util function for handling socketClosed event */
2234
2263
  socketClosed(player, payload) {
2235
- this.NodeManager.LavalinkManager.emit("playerSocketClosed", player, payload);
2264
+ this._LManager.emit("playerSocketClosed", player, payload);
2236
2265
  return;
2237
2266
  }
2238
2267
  /** @private util function for handling SponsorBlock Segmentloaded event */
2239
2268
  SponsorBlockSegmentLoaded(player, track, payload) {
2240
- this.NodeManager.LavalinkManager.emit("SegmentsLoaded", player, track || this.getTrackOfPayload(payload), payload);
2269
+ this._LManager.emit("SegmentsLoaded", player, track || this.getTrackOfPayload(payload), payload);
2241
2270
  return;
2242
2271
  }
2243
2272
  /** @private util function for handling SponsorBlock SegmentSkipped event */
2244
2273
  SponsorBlockSegmentSkipped(player, track, payload) {
2245
- this.NodeManager.LavalinkManager.emit("SegmentSkipped", player, track || this.getTrackOfPayload(payload), payload);
2274
+ this._LManager.emit("SegmentSkipped", player, track || this.getTrackOfPayload(payload), payload);
2246
2275
  return;
2247
2276
  }
2248
2277
  /** @private util function for handling SponsorBlock Chaptersloaded event */
2249
2278
  SponsorBlockChaptersLoaded(player, track, payload) {
2250
- this.NodeManager.LavalinkManager.emit("ChaptersLoaded", player, track || this.getTrackOfPayload(payload), payload);
2279
+ this._LManager.emit("ChaptersLoaded", player, track || this.getTrackOfPayload(payload), payload);
2251
2280
  return;
2252
2281
  }
2253
2282
  /** @private util function for handling SponsorBlock Chaptersstarted event */
2254
2283
  SponsorBlockChapterStarted(player, track, payload) {
2255
- this.NodeManager.LavalinkManager.emit("ChapterStarted", player, track || this.getTrackOfPayload(payload), payload);
2284
+ this._LManager.emit("ChapterStarted", player, track || this.getTrackOfPayload(payload), payload);
2256
2285
  return;
2257
2286
  }
2258
2287
  /**
@@ -2267,7 +2296,7 @@ var LavalinkNode = class {
2267
2296
  * ```
2268
2297
  */
2269
2298
  async getSponsorBlock(player) {
2270
- if (!this.info.plugins.find((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2299
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2271
2300
  return await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`);
2272
2301
  }
2273
2302
  /**
@@ -2282,7 +2311,7 @@ var LavalinkNode = class {
2282
2311
  * ```
2283
2312
  */
2284
2313
  async setSponsorBlock(player, segments = ["sponsor", "selfpromo"]) {
2285
- if (!this.info.plugins.find((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2314
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2286
2315
  if (!segments.length) throw new RangeError("No Segments provided. Did you ment to use 'deleteSponsorBlock'?");
2287
2316
  if (segments.some((v) => !validSponsorBlocks.includes(v.toLowerCase()))) throw new SyntaxError(`You provided a sponsorblock which isn't valid, valid ones are: ${validSponsorBlocks.map((v) => `'${v}'`).join(", ")}`);
2288
2317
  await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
@@ -2291,13 +2320,11 @@ var LavalinkNode = class {
2291
2320
  r.body = safeStringify(segments.map((v) => v.toLowerCase()));
2292
2321
  });
2293
2322
  player.set("internal_sponsorBlockCategories", segments.map((v) => v.toLowerCase()));
2294
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2295
- this.NodeManager.LavalinkManager.emit("debug", "SetSponsorBlock" /* SetSponsorBlock */, {
2296
- state: "log",
2297
- message: `SponsorBlock was set for Player: ${player.guildId} to: ${segments.map((v) => `'${v.toLowerCase()}'`).join(", ")}`,
2298
- functionLayer: "LavalinkNode > setSponsorBlock()"
2299
- });
2300
- }
2323
+ this._emitDebugEvent("SetSponsorBlock" /* SetSponsorBlock */, {
2324
+ state: "log",
2325
+ message: `SponsorBlock was set for Player: ${player.guildId} to: ${segments.map((v) => `'${v.toLowerCase()}'`).join(", ")}`,
2326
+ functionLayer: "LavalinkNode > setSponsorBlock()"
2327
+ });
2301
2328
  return;
2302
2329
  }
2303
2330
  /**
@@ -2312,18 +2339,16 @@ var LavalinkNode = class {
2312
2339
  * ```
2313
2340
  */
2314
2341
  async deleteSponsorBlock(player) {
2315
- if (!this.info.plugins.find((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2342
+ if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
2316
2343
  await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
2317
2344
  r.method = "DELETE";
2318
2345
  });
2319
2346
  player.set("internal_sponsorBlockCategories", []);
2320
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2321
- this.NodeManager.LavalinkManager.emit("debug", "DeleteSponsorBlock" /* DeleteSponsorBlock */, {
2322
- state: "log",
2323
- message: `SponsorBlock was deleted for Player: ${player.guildId}`,
2324
- functionLayer: "LavalinkNode > deleteSponsorBlock()"
2325
- });
2326
- }
2347
+ this._emitDebugEvent("DeleteSponsorBlock" /* DeleteSponsorBlock */, {
2348
+ state: "log",
2349
+ message: `SponsorBlock was deleted for Player: ${player.guildId}`,
2350
+ functionLayer: "LavalinkNode > deleteSponsorBlock()"
2351
+ });
2327
2352
  return;
2328
2353
  }
2329
2354
  /** private util function for handling the queue end event */
@@ -2332,46 +2357,38 @@ var LavalinkNode = class {
2332
2357
  player.queue.current = null;
2333
2358
  player.playing = false;
2334
2359
  player.set("internal_stopPlaying", void 0);
2335
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2336
- this.NodeManager.LavalinkManager.emit("debug", "QueueEnded" /* QueueEnded */, {
2360
+ this._emitDebugEvent("QueueEnded" /* QueueEnded */, {
2361
+ state: "log",
2362
+ message: `Queue Ended because no more Tracks were in the Queue, due to EventName: "${payload.type}"`,
2363
+ functionLayer: "LavalinkNode > queueEnd()"
2364
+ });
2365
+ if (typeof this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
2366
+ this._emitDebugEvent("AutoplayExecution" /* AutoplayExecution */, {
2337
2367
  state: "log",
2338
- message: `Queue Ended because no more Tracks were in the Queue, due to EventName: "${payload.type}"`,
2339
- functionLayer: "LavalinkNode > queueEnd()"
2368
+ message: `Now Triggering Autoplay.`,
2369
+ functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2340
2370
  });
2341
- }
2342
- if (typeof this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
2343
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2344
- this.NodeManager.LavalinkManager.emit("debug", "AutoplayExecution" /* AutoplayExecution */, {
2345
- state: "log",
2346
- message: `Now Triggering Autoplay.`,
2347
- functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2348
- });
2349
- }
2350
2371
  const previousAutoplayTime = player.get("internal_previousautoplay");
2351
2372
  const duration = previousAutoplayTime ? Date.now() - previousAutoplayTime : 0;
2352
- if (!duration || duration > this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
2353
- await this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
2373
+ if (!duration || duration > this._LManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
2374
+ await this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
2354
2375
  player.set("internal_previousautoplay", Date.now());
2355
2376
  if (player.queue.tracks.length > 0) await queueTrackEnd(player);
2356
- else if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2357
- this.NodeManager.LavalinkManager.emit("debug", "AutoplayNoSongsAdded" /* AutoplayNoSongsAdded */, {
2358
- state: "warn",
2359
- message: `Autoplay was triggered but no songs were added to the queue.`,
2360
- functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2361
- });
2362
- }
2363
- if (player.queue.current) {
2364
- if (payload.type === "TrackEndEvent") this.NodeManager.LavalinkManager.emit("trackEnd", player, track, payload);
2365
- if (this.NodeManager.LavalinkManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
2366
- }
2377
+ else this._emitDebugEvent("AutoplayNoSongsAdded" /* AutoplayNoSongsAdded */, {
2378
+ state: "warn",
2379
+ message: `Autoplay was triggered but no songs were added to the queue.`,
2380
+ functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2381
+ });
2382
+ }
2383
+ if (player.queue.current) {
2384
+ if (payload.type === "TrackEndEvent") this._LManager.emit("trackEnd", player, track, payload);
2385
+ if (this._LManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
2367
2386
  } else {
2368
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2369
- this.NodeManager.LavalinkManager.emit("debug", "AutoplayThresholdSpamLimiter" /* AutoplayThresholdSpamLimiter */, {
2370
- state: "warn",
2371
- message: `Autoplay was triggered after the previousautoplay too early. Threshold is: ${this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs}ms and the Duration was ${duration}ms`,
2372
- functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2373
- });
2374
- }
2387
+ this._emitDebugEvent("AutoplayThresholdSpamLimiter" /* AutoplayThresholdSpamLimiter */, {
2388
+ state: "warn",
2389
+ message: `Autoplay was triggered after the previousautoplay too early. Threshold is: ${this._LManager.options.playerOptions.minAutoPlayMs}ms and the Duration was ${duration}ms`,
2390
+ functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
2391
+ });
2375
2392
  }
2376
2393
  }
2377
2394
  player.set("internal_skipped", false);
@@ -2384,31 +2401,29 @@ var LavalinkNode = class {
2384
2401
  if (payload?.reason !== "stopped") {
2385
2402
  await player.queue.utils.save();
2386
2403
  }
2387
- if (typeof this.NodeManager.LavalinkManager.options.playerOptions?.onEmptyQueue?.destroyAfterMs === "number" && !isNaN(this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs) && this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs >= 0) {
2388
- if (this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs === 0) {
2404
+ if (typeof this._LManager.options.playerOptions?.onEmptyQueue?.destroyAfterMs === "number" && !isNaN(this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs) && this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs >= 0) {
2405
+ if (this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs === 0) {
2389
2406
  player.destroy("QueueEmpty" /* QueueEmpty */);
2390
2407
  return;
2391
2408
  } else {
2392
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2393
- this.NodeManager.LavalinkManager.emit("debug", "TriggerQueueEmptyInterval" /* TriggerQueueEmptyInterval */, {
2394
- state: "log",
2395
- message: `Trigger Queue Empty Interval was Triggered because playerOptions.onEmptyQueue.destroyAfterMs is set to ${this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs}ms`,
2396
- functionLayer: "LavalinkNode > queueEnd() > destroyAfterMs"
2397
- });
2398
- }
2399
- this.NodeManager.LavalinkManager.emit("playerQueueEmptyStart", player, this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
2409
+ this._emitDebugEvent("TriggerQueueEmptyInterval" /* TriggerQueueEmptyInterval */, {
2410
+ state: "log",
2411
+ message: `Trigger Queue Empty Interval was Triggered because playerOptions.onEmptyQueue.destroyAfterMs is set to ${this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs}ms`,
2412
+ functionLayer: "LavalinkNode > queueEnd() > destroyAfterMs"
2413
+ });
2414
+ this._LManager.emit("playerQueueEmptyStart", player, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
2400
2415
  if (player.get("internal_queueempty")) clearTimeout(player.get("internal_queueempty"));
2401
2416
  player.set("internal_queueempty", setTimeout(() => {
2402
2417
  player.set("internal_queueempty", void 0);
2403
2418
  if (player.queue.current) {
2404
- return this.NodeManager.LavalinkManager.emit("playerQueueEmptyCancel", player);
2419
+ return this._LManager.emit("playerQueueEmptyCancel", player);
2405
2420
  }
2406
- this.NodeManager.LavalinkManager.emit("playerQueueEmptyEnd", player);
2421
+ this._LManager.emit("playerQueueEmptyEnd", player);
2407
2422
  player.destroy("QueueEmpty" /* QueueEmpty */);
2408
- }, this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs));
2423
+ }, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs));
2409
2424
  }
2410
2425
  }
2411
- this.NodeManager.LavalinkManager.emit("queueEnd", player, track, payload);
2426
+ this._LManager.emit("queueEnd", player, track, payload);
2412
2427
  return;
2413
2428
  }
2414
2429
  /**
@@ -2424,16 +2439,14 @@ var LavalinkNode = class {
2424
2439
  if (player.queue.current) {
2425
2440
  await player.queue.utils.save();
2426
2441
  } else {
2427
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2428
- this.NodeManager.LavalinkManager.emit("debug", "TrackStartNoTrack" /* TrackStartNoTrack */, {
2429
- state: "warn",
2430
- message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2431
- functionLayer: "LavalinkNode > trackStart()"
2432
- });
2433
- }
2442
+ this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
2443
+ state: "warn",
2444
+ message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2445
+ functionLayer: "LavalinkNode > trackStart()"
2446
+ });
2434
2447
  }
2435
2448
  }
2436
- this.NodeManager.LavalinkManager.emit("LyricsLine", player, track, payload);
2449
+ this._LManager.emit("LyricsLine", player, track, payload);
2437
2450
  return;
2438
2451
  }
2439
2452
  /**
@@ -2449,16 +2462,14 @@ var LavalinkNode = class {
2449
2462
  if (player.queue.current) {
2450
2463
  await player.queue.utils.save();
2451
2464
  } else {
2452
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2453
- this.NodeManager.LavalinkManager.emit("debug", "TrackStartNoTrack" /* TrackStartNoTrack */, {
2454
- state: "warn",
2455
- message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2456
- functionLayer: "LavalinkNode > trackStart()"
2457
- });
2458
- }
2465
+ this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
2466
+ state: "warn",
2467
+ message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2468
+ functionLayer: "LavalinkNode > trackStart()"
2469
+ });
2459
2470
  }
2460
2471
  }
2461
- this.NodeManager.LavalinkManager.emit("LyricsFound", player, track, payload);
2472
+ this._LManager.emit("LyricsFound", player, track, payload);
2462
2473
  return;
2463
2474
  }
2464
2475
  /**
@@ -2474,16 +2485,14 @@ var LavalinkNode = class {
2474
2485
  if (player.queue.current) {
2475
2486
  await player.queue.utils.save();
2476
2487
  } else {
2477
- if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
2478
- this.NodeManager.LavalinkManager.emit("debug", "TrackStartNoTrack" /* TrackStartNoTrack */, {
2479
- state: "warn",
2480
- message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2481
- functionLayer: "LavalinkNode > trackStart()"
2482
- });
2483
- }
2488
+ this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
2489
+ state: "warn",
2490
+ message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
2491
+ functionLayer: "LavalinkNode > trackStart()"
2492
+ });
2484
2493
  }
2485
2494
  }
2486
- this.NodeManager.LavalinkManager.emit("LyricsNotFound", player, track, payload);
2495
+ this._LManager.emit("LyricsNotFound", player, track, payload);
2487
2496
  return;
2488
2497
  }
2489
2498
  };
@@ -2845,6 +2854,21 @@ var FilterManager = class {
2845
2854
  data = structuredClone(DEFAULT_FILTER_DATAS);
2846
2855
  /** The Player assigned to this Filter Manager */
2847
2856
  player;
2857
+ get _LManager() {
2858
+ return this.player.LavalinkManager;
2859
+ }
2860
+ /**
2861
+ * Returns wether the plugin validations are enabled or not
2862
+ */
2863
+ get _checkForPlugins() {
2864
+ return !!this._LManager.options?.autoChecks?.pluginValidations;
2865
+ }
2866
+ /**
2867
+ * Returns wether the source validations are enabled or not
2868
+ */
2869
+ get _checkForSources() {
2870
+ return !!this._LManager.options?.autoChecks?.sourcesValidations;
2871
+ }
2848
2872
  /** The Constructor for the FilterManager */
2849
2873
  constructor(player) {
2850
2874
  this.player = player;
@@ -2881,13 +2905,13 @@ var FilterManager = class {
2881
2905
  if (!this.filters.karaoke) delete sendData.karaoke;
2882
2906
  if (!this.filters.rotation) delete sendData.rotation;
2883
2907
  if (this.filters.audioOutput === "stereo") delete sendData.channelMix;
2884
- if (Object.values(this.data.timescale).every((v) => v === 1)) delete sendData.timescale;
2908
+ if (Object.values(this.data.timescale ?? {}).every((v) => v === 1)) delete sendData.timescale;
2885
2909
  if (!this.player.node.sessionId) throw new Error("The Lavalink-Node is either not ready or not up to date");
2886
2910
  sendData.equalizer = [...this.equalizerBands];
2887
2911
  if (sendData.equalizer.length === 0) delete sendData.equalizer;
2888
2912
  for (const key of Object.keys(sendData)) {
2889
2913
  if (key === "pluginFilters") {
2890
- } else if (this.player.node.info && !this.player.node.info?.filters?.includes?.(key)) delete sendData[key];
2914
+ } else if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.(key)) delete sendData[key];
2891
2915
  }
2892
2916
  const now = performance.now();
2893
2917
  if (this.player.options.instaUpdateFiltersFix === true) this.filterUpdatedState = true;
@@ -3027,7 +3051,7 @@ var FilterManager = class {
3027
3051
  * ```
3028
3052
  */
3029
3053
  async setAudioOutput(type) {
3030
- if (this.player.node.info && !this.player.node.info?.filters?.includes("channelMix")) throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
3054
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("channelMix")) throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
3031
3055
  if (!type || !audioOutputsData[type]) throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
3032
3056
  this.data = this.data ?? {};
3033
3057
  this.data.channelMix = audioOutputsData[type];
@@ -3047,7 +3071,7 @@ var FilterManager = class {
3047
3071
  * ```
3048
3072
  */
3049
3073
  async setSpeed(speed = 1) {
3050
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3074
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3051
3075
  this.data = this.data ?? {};
3052
3076
  this.filters.nightcore = false;
3053
3077
  this.filters.vaporwave = false;
@@ -3068,7 +3092,7 @@ var FilterManager = class {
3068
3092
  * ```
3069
3093
  */
3070
3094
  async setPitch(pitch = 1) {
3071
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3095
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3072
3096
  this.data = this.data ?? {};
3073
3097
  this.filters.nightcore = false;
3074
3098
  this.filters.vaporwave = false;
@@ -3089,7 +3113,7 @@ var FilterManager = class {
3089
3113
  * ```
3090
3114
  */
3091
3115
  async setRate(rate = 1) {
3092
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3116
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3093
3117
  this.data = this.data ?? {};
3094
3118
  this.filters.nightcore = false;
3095
3119
  this.filters.vaporwave = false;
@@ -3113,7 +3137,7 @@ var FilterManager = class {
3113
3137
  * ```
3114
3138
  */
3115
3139
  async toggleRotation(rotationHz = 0.2) {
3116
- if (this.player.node.info && !this.player.node.info?.filters?.includes("rotation")) throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
3140
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("rotation")) throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
3117
3141
  this.data = this.data ?? {};
3118
3142
  this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
3119
3143
  this.filters.rotation = !this.filters.rotation;
@@ -3136,7 +3160,7 @@ var FilterManager = class {
3136
3160
  * ```
3137
3161
  */
3138
3162
  async toggleVibrato(frequency = 10, depth = 1) {
3139
- if (this.player.node.info && !this.player.node.info?.filters?.includes("vibrato")) throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
3163
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("vibrato")) throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
3140
3164
  this.data = this.data ?? {};
3141
3165
  this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
3142
3166
  this.filters.vibrato = !this.filters.vibrato;
@@ -3159,7 +3183,7 @@ var FilterManager = class {
3159
3183
  * ```
3160
3184
  */
3161
3185
  async toggleTremolo(frequency = 4, depth = 0.8) {
3162
- if (this.player.node.info && !this.player.node.info?.filters?.includes("tremolo")) throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
3186
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("tremolo")) throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
3163
3187
  this.data = this.data ?? {};
3164
3188
  this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
3165
3189
  this.filters.tremolo = !this.filters.tremolo;
@@ -3181,7 +3205,7 @@ var FilterManager = class {
3181
3205
  * ```
3182
3206
  */
3183
3207
  async toggleLowPass(smoothing = 20) {
3184
- if (this.player.node.info && !this.player.node.info?.filters?.includes("lowPass")) throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
3208
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("lowPass")) throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
3185
3209
  this.data = this.data ?? {};
3186
3210
  this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
3187
3211
  this.filters.lowPass = !this.filters.lowPass;
@@ -3208,8 +3232,8 @@ var FilterManager = class {
3208
3232
  * ```
3209
3233
  */
3210
3234
  toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
3211
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3212
- if (this.player.node.info && !this.player.node.info?.filters?.includes("low-pass")) throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
3235
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3236
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("low-pass")) throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
3213
3237
  this.data = this.data ?? {};
3214
3238
  this.data.pluginFilters = this.data.pluginFilters ?? {};
3215
3239
  if (this.filters.lavalinkLavaDspxPlugin.lowPass) delete this.data.pluginFilters["low-pass"];
@@ -3234,8 +3258,8 @@ var FilterManager = class {
3234
3258
  * ```
3235
3259
  */
3236
3260
  toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
3237
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3238
- if (this.player.node.info && !this.player.node.info?.filters?.includes("high-pass")) throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
3261
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3262
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("high-pass")) throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
3239
3263
  this.data = this.data ?? {};
3240
3264
  this.data.pluginFilters = this.data.pluginFilters ?? {};
3241
3265
  if (this.filters.lavalinkLavaDspxPlugin.highPass) delete this.data.pluginFilters["high-pass"];
@@ -3260,8 +3284,8 @@ var FilterManager = class {
3260
3284
  * ```
3261
3285
  */
3262
3286
  toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
3263
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3264
- if (this.player.node.info && !this.player.node.info?.filters?.includes("normalization")) throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
3287
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3288
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("normalization")) throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
3265
3289
  this.data = this.data ?? {};
3266
3290
  this.data.pluginFilters = this.data.pluginFilters ?? {};
3267
3291
  if (this.filters.lavalinkLavaDspxPlugin.normalization) delete this.data.pluginFilters.normalization;
@@ -3286,8 +3310,8 @@ var FilterManager = class {
3286
3310
  * ```
3287
3311
  */
3288
3312
  toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
3289
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3290
- if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
3313
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavadspx-plugin")) throw new Error("Node#Info#plugins does not include the lavadspx plugin");
3314
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
3291
3315
  this.data = this.data ?? {};
3292
3316
  this.data.pluginFilters = this.data.pluginFilters ?? {};
3293
3317
  if (this.filters.lavalinkLavaDspxPlugin.echo) delete this.data.pluginFilters.echo;
@@ -3317,8 +3341,8 @@ var FilterManager = class {
3317
3341
  * ```
3318
3342
  */
3319
3343
  toggleEcho: async (delay = 4, decay = 0.8) => {
3320
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
3321
- if (this.player.node.info && !this.player.node.info?.filters?.includes("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
3344
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
3345
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
3322
3346
  this.data = this.data ?? {};
3323
3347
  const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
3324
3348
  this.data.pluginFilters = {
@@ -3348,8 +3372,8 @@ var FilterManager = class {
3348
3372
  * ```
3349
3373
  */
3350
3374
  toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
3351
- if (this.player.node.info && !this.player.node.info?.plugins?.find((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
3352
- if (this.player.node.info && !this.player.node.info?.filters?.includes("reverb")) throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
3375
+ if (this._checkForPlugins && !this.player?.node?.info?.plugins?.find?.((v) => v.name === "lavalink-filter-plugin")) throw new Error("Node#Info#plugins does not include the lavalink-filter-plugin plugin");
3376
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("reverb")) throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
3353
3377
  this.data = this.data ?? {};
3354
3378
  const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
3355
3379
  this.data.pluginFilters = {
@@ -3381,7 +3405,7 @@ var FilterManager = class {
3381
3405
  * ```
3382
3406
  */
3383
3407
  async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
3384
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3408
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3385
3409
  this.data = this.data ?? {};
3386
3410
  this.data.timescale = this.filters.nightcore ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
3387
3411
  this.filters.nightcore = !this.filters.nightcore;
@@ -3407,7 +3431,7 @@ var FilterManager = class {
3407
3431
  * ```
3408
3432
  */
3409
3433
  async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
3410
- if (this.player.node.info && !this.player.node.info?.filters?.includes("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3434
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
3411
3435
  this.data = this.data ?? {};
3412
3436
  this.data.timescale = this.filters.vaporwave ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
3413
3437
  this.filters.vaporwave = !this.filters.vaporwave;
@@ -3434,7 +3458,7 @@ var FilterManager = class {
3434
3458
  * ```
3435
3459
  */
3436
3460
  async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
3437
- if (this.player.node.info && !this.player.node.info?.filters?.includes("karaoke")) throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
3461
+ if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("karaoke")) throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
3438
3462
  this.data = this.data ?? {};
3439
3463
  this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
3440
3464
  this.filters.karaoke = !this.filters.karaoke;
@@ -3951,6 +3975,15 @@ var Player = class {
3951
3975
  };
3952
3976
  /** Custom data for the player */
3953
3977
  data = {};
3978
+ /**
3979
+ * Emits a debug event to the LavalinkManager
3980
+ * @param name name of the event
3981
+ * @param eventData event data
3982
+ */
3983
+ _emitDebugEvent(name, eventData) {
3984
+ if (!this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) return;
3985
+ this.LavalinkManager.emit("debug", name, eventData);
3986
+ }
3954
3987
  /**
3955
3988
  * Create a new Player
3956
3989
  * @param options
@@ -3966,8 +3999,8 @@ var Player = class {
3966
3999
  this.textChannelId = this.options.textChannelId || null;
3967
4000
  this.node = typeof this.options.node === "string" ? this.LavalinkManager.nodeManager.nodes.get(this.options.node) : this.options.node;
3968
4001
  if (!this.node || typeof this.node.request !== "function") {
3969
- if (typeof this.options.node === "string" && this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
3970
- this.LavalinkManager.emit("debug", "PlayerCreateNodeNotFound" /* PlayerCreateNodeNotFound */, {
4002
+ if (typeof this.options.node === "string") {
4003
+ this._emitDebugEvent("PlayerCreateNodeNotFound" /* PlayerCreateNodeNotFound */, {
3971
4004
  state: "warn",
3972
4005
  message: `Player was created with provided node Id: ${this.options.node}, but no node with that Id was found.`,
3973
4006
  functionLayer: "Player > constructor()"
@@ -4024,13 +4057,11 @@ var Player = class {
4024
4057
  */
4025
4058
  async play(options = {}) {
4026
4059
  if (this.get("internal_queueempty")) {
4027
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4028
- this.LavalinkManager.emit("debug", "PlayerPlayQueueEmptyTimeoutClear" /* PlayerPlayQueueEmptyTimeoutClear */, {
4029
- state: "log",
4030
- message: `Player was called to play something, while there was a queueEmpty Timeout set, clearing the timeout.`,
4031
- functionLayer: "Player > play()"
4032
- });
4033
- }
4060
+ this._emitDebugEvent("PlayerPlayQueueEmptyTimeoutClear" /* PlayerPlayQueueEmptyTimeoutClear */, {
4061
+ state: "log",
4062
+ message: `Player was called to play something, while there was a queueEmpty Timeout set, clearing the timeout.`,
4063
+ functionLayer: "Player > play()"
4064
+ });
4034
4065
  this.LavalinkManager.emit("playerQueueEmptyCancel", this);
4035
4066
  clearTimeout(this.get("internal_queueempty"));
4036
4067
  this.set("internal_queueempty", void 0);
@@ -4040,14 +4071,12 @@ var Player = class {
4040
4071
  try {
4041
4072
  await options.clientTrack.resolve(this);
4042
4073
  } catch (error) {
4043
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4044
- this.LavalinkManager.emit("debug", "PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
4045
- state: "error",
4046
- error,
4047
- message: `Player Play was called with clientTrack, Song is unresolved, but couldn't resolve it`,
4048
- functionLayer: "Player > play() > resolve currentTrack"
4049
- });
4050
- }
4074
+ this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
4075
+ state: "error",
4076
+ error,
4077
+ message: `Player Play was called with clientTrack, Song is unresolved, but couldn't resolve it`,
4078
+ functionLayer: "Player > play() > resolve currentTrack"
4079
+ });
4051
4080
  this.LavalinkManager.emit("trackError", this, this.queue.current, error);
4052
4081
  if (options && "clientTrack" in options) delete options.clientTrack;
4053
4082
  if (options && "track" in options) delete options.track;
@@ -4084,13 +4113,11 @@ var Player = class {
4084
4113
  ...options.track.userData
4085
4114
  }
4086
4115
  }).filter((v) => typeof v[1] !== "undefined"));
4087
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4088
- this.LavalinkManager.emit("debug", "PlayerPlayWithTrackReplace" /* PlayerPlayWithTrackReplace */, {
4089
- state: "log",
4090
- message: `Player was called to play something, with a specific track provided. Replacing the current Track and resolving the track on trackStart Event.`,
4091
- functionLayer: "Player > play()"
4092
- });
4093
- }
4116
+ this._emitDebugEvent("PlayerPlayWithTrackReplace" /* PlayerPlayWithTrackReplace */, {
4117
+ state: "log",
4118
+ message: `Player was called to play something, with a specific track provided. Replacing the current Track and resolving the track on trackStart Event.`,
4119
+ functionLayer: "Player > play()"
4120
+ });
4094
4121
  return this.node.updatePlayer({
4095
4122
  guildId: this.guildId,
4096
4123
  noReplace: false,
@@ -4107,13 +4134,11 @@ var Player = class {
4107
4134
  }
4108
4135
  if (!this.queue.current && this.queue.tracks.length) await queueTrackEnd(this);
4109
4136
  if (this.queue.current && this.LavalinkManager.utils.isUnresolvedTrack(this.queue.current)) {
4110
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4111
- this.LavalinkManager.emit("debug", "PlayerPlayUnresolvedTrack" /* PlayerPlayUnresolvedTrack */, {
4112
- state: "log",
4113
- message: `Player Play was called, current Queue Song is unresolved, resolving the track.`,
4114
- functionLayer: "Player > play()"
4115
- });
4116
- }
4137
+ this._emitDebugEvent("PlayerPlayUnresolvedTrack" /* PlayerPlayUnresolvedTrack */, {
4138
+ state: "log",
4139
+ message: `Player Play was called, current Queue Song is unresolved, resolving the track.`,
4140
+ functionLayer: "Player > play()"
4141
+ });
4117
4142
  try {
4118
4143
  await this.queue.current.resolve(this);
4119
4144
  if (typeof options.track?.userData === "object" && this.queue.current) this.queue.current.userData = {
@@ -4122,14 +4147,12 @@ var Player = class {
4122
4147
  ...options.track?.userData
4123
4148
  };
4124
4149
  } catch (error) {
4125
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4126
- this.LavalinkManager.emit("debug", "PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
4127
- state: "error",
4128
- error,
4129
- message: `Player Play was called, current Queue Song is unresolved, but couldn't resolve it`,
4130
- functionLayer: "Player > play() > resolve currentTrack"
4131
- });
4132
- }
4150
+ this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
4151
+ state: "error",
4152
+ error,
4153
+ message: `Player Play was called, current Queue Song is unresolved, but couldn't resolve it`,
4154
+ functionLayer: "Player > play() > resolve currentTrack"
4155
+ });
4133
4156
  this.LavalinkManager.emit("trackError", this, this.queue.current, error);
4134
4157
  if (options && "clientTrack" in options) delete options.clientTrack;
4135
4158
  if (options && "track" in options) delete options.track;
@@ -4190,13 +4213,11 @@ var Player = class {
4190
4213
  ), 1e3), 0));
4191
4214
  const now = performance.now();
4192
4215
  if (this.LavalinkManager.options.playerOptions.applyVolumeAsFilter) {
4193
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4194
- this.LavalinkManager.emit("debug", "PlayerVolumeAsFilter" /* PlayerVolumeAsFilter */, {
4195
- state: "log",
4196
- message: `Player Volume was set as a Filter, because LavalinkManager option "playerOptions.applyVolumeAsFilter" is true`,
4197
- functionLayer: "Player > setVolume()"
4198
- });
4199
- }
4216
+ this._emitDebugEvent("PlayerVolumeAsFilter" /* PlayerVolumeAsFilter */, {
4217
+ state: "log",
4218
+ message: `Player Volume was set as a Filter, because LavalinkManager option "playerOptions.applyVolumeAsFilter" is true`,
4219
+ functionLayer: "Player > setVolume()"
4220
+ });
4200
4221
  await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume: this.lavalinkVolume / 100 } } });
4201
4222
  } else {
4202
4223
  await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume: this.lavalinkVolume } });
@@ -4241,13 +4262,11 @@ var Player = class {
4241
4262
  async search(query, requestUser, throwOnEmpty = false) {
4242
4263
  const Query = this.LavalinkManager.utils.transformQuery(query);
4243
4264
  if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info?.sourceManagers.includes("bandcamp")) {
4244
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4245
- this.LavalinkManager.emit("debug", "BandcampSearchLokalEngine" /* BandcampSearchLokalEngine */, {
4246
- state: "log",
4247
- message: `Player.search was called with a Bandcamp Query, but no bandcamp search was enabled on lavalink, searching with the custom Search Engine.`,
4248
- functionLayer: "Player > search()"
4249
- });
4250
- }
4265
+ this._emitDebugEvent("BandcampSearchLokalEngine" /* BandcampSearchLokalEngine */, {
4266
+ state: "log",
4267
+ message: `Player.search was called with a Bandcamp Query, but no bandcamp search was enabled on lavalink, searching with the custom Search Engine.`,
4268
+ functionLayer: "Player > search()"
4269
+ });
4251
4270
  return await bandCampSearch(this, Query.query, requestUser);
4252
4271
  }
4253
4272
  return this.node.search(Query, requestUser, throwOnEmpty);
@@ -4399,13 +4418,11 @@ var Player = class {
4399
4418
  this.set("internal_queueempty", void 0);
4400
4419
  }
4401
4420
  if (this.get("internal_destroystatus") === true) {
4402
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4403
- this.LavalinkManager.emit("debug", "PlayerDestroyingSomewhereElse" /* PlayerDestroyingSomewhereElse */, {
4404
- state: "warn",
4405
- message: `Player is already destroying somewhere else..`,
4406
- functionLayer: "Player > destroy()"
4407
- });
4408
- }
4421
+ this._emitDebugEvent("PlayerDestroyingSomewhereElse" /* PlayerDestroyingSomewhereElse */, {
4422
+ state: "warn",
4423
+ message: `Player is already destroying somewhere else..`,
4424
+ functionLayer: "Player > destroy()"
4425
+ });
4409
4426
  if (this.LavalinkManager.options.advancedOptions?.debugOptions.playerDestroy.debugLog) console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Already destroying somewhere else..`);
4410
4427
  return;
4411
4428
  }
@@ -4498,17 +4515,15 @@ var Player = class {
4498
4515
  const missingSources = [...trackSources].filter(
4499
4516
  (source) => !updateNode.info?.sourceManagers.includes(source)
4500
4517
  );
4501
- if (missingSources.length)
4518
+ if (this.LavalinkManager.options.autoChecks?.sourcesValidations && missingSources.length)
4502
4519
  throw new RangeError(`Sources missing for Node ${updateNode.id}: ${missingSources.join(", ")}`);
4503
4520
  }
4504
4521
  }
4505
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4506
- this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, {
4507
- state: "log",
4508
- message: `Player.changeNode() was executed, trying to change from "${this.node.id}" to "${updateNode.id}"`,
4509
- functionLayer: "Player > changeNode()"
4510
- });
4511
- }
4522
+ this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
4523
+ state: "log",
4524
+ message: `Player.changeNode() was executed, trying to change from "${this.node.id}" to "${updateNode.id}"`,
4525
+ functionLayer: "Player > changeNode()"
4526
+ });
4512
4527
  const data = this.toJSON();
4513
4528
  const currentTrack = this.queue.current;
4514
4529
  if (!this.voice.endpoint || !this.voice.sessionId || !this.voice.token)
@@ -4519,30 +4534,26 @@ var Player = class {
4519
4534
  const now = performance.now();
4520
4535
  try {
4521
4536
  await this.connect();
4522
- const hasSponsorBlock = this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
4537
+ const hasSponsorBlock = !this.LavalinkManager.options?.autoChecks?.pluginValidations || this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
4523
4538
  if (hasSponsorBlock) {
4524
4539
  const sponsorBlockCategories = this.get("internal_sponsorBlockCategories");
4525
4540
  if (Array.isArray(sponsorBlockCategories) && sponsorBlockCategories.length) {
4526
4541
  await this.setSponsorBlock(sponsorBlockCategories).catch((error) => {
4527
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4528
- this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, {
4529
- state: "error",
4530
- error,
4531
- message: `Player > changeNode() Unable to set SponsorBlock Segments`,
4532
- functionLayer: "Player > changeNode()"
4533
- });
4534
- }
4542
+ this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
4543
+ state: "error",
4544
+ error,
4545
+ message: `Player > changeNode() Unable to set SponsorBlock Segments`,
4546
+ functionLayer: "Player > changeNode()"
4547
+ });
4535
4548
  });
4536
4549
  } else {
4537
4550
  await this.setSponsorBlock().catch((error) => {
4538
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4539
- this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, {
4540
- state: "error",
4541
- error,
4542
- message: `Player > changeNode() Unable to set SponsorBlock Segments`,
4543
- functionLayer: "Player > changeNode()"
4544
- });
4545
- }
4551
+ this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
4552
+ state: "error",
4553
+ error,
4554
+ message: `Player > changeNode() Unable to set SponsorBlock Segments`,
4555
+ functionLayer: "Player > changeNode()"
4556
+ });
4546
4557
  });
4547
4558
  }
4548
4559
  }
@@ -4567,14 +4578,12 @@ var Player = class {
4567
4578
  this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
4568
4579
  return this.node.id;
4569
4580
  } catch (error) {
4570
- if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
4571
- this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, {
4572
- state: "error",
4573
- error,
4574
- message: `Player.changeNode() execution failed`,
4575
- functionLayer: "Player > changeNode()"
4576
- });
4577
- }
4581
+ this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
4582
+ state: "error",
4583
+ error,
4584
+ message: `Player.changeNode() execution failed`,
4585
+ functionLayer: "Player > changeNode()"
4586
+ });
4578
4587
  throw new Error(`Failed to change the node: ${error}`);
4579
4588
  } finally {
4580
4589
  this.set("internal_nodeChanging", void 0);
@@ -4700,6 +4709,10 @@ var LavalinkManager = class extends EventEmitter2 {
4700
4709
  id: options?.client?.id,
4701
4710
  username: options?.client?.username ?? "lavalink-client"
4702
4711
  },
4712
+ autoChecks: {
4713
+ sourcesValidations: options?.autoChecks?.sourcesValidations ?? true,
4714
+ pluginValidations: options?.autoChecks?.pluginValidations ?? true
4715
+ },
4703
4716
  sendToShard: options?.sendToShard,
4704
4717
  autoMove: options?.autoMove ?? false,
4705
4718
  nodes: options?.nodes,
@@ -4763,6 +4776,8 @@ var LavalinkManager = class extends EventEmitter2 {
4763
4776
  if (options?.autoSkipOnResolveError && typeof options?.autoSkipOnResolveError !== "boolean") throw new SyntaxError("ManagerOption.autoSkipOnResolveError must be either false | true aka boolean");
4764
4777
  if (options?.emitNewSongsOnly && typeof options?.emitNewSongsOnly !== "boolean") throw new SyntaxError("ManagerOption.emitNewSongsOnly must be either false | true aka boolean");
4765
4778
  if (!options?.nodes || !Array.isArray(options?.nodes) || !options?.nodes.every((node) => this.utils.isNodeOptions(node))) throw new SyntaxError("ManagerOption.nodes must be an Array of NodeOptions and is required of at least 1 Node");
4779
+ if (typeof options?.autoChecks?.sourcesValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.sourcesValidations must be either false | true aka boolean");
4780
+ if (typeof options?.autoChecks?.pluginValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.pluginValidations must be either false | true aka boolean");
4766
4781
  if (options?.queueOptions?.queueStore) {
4767
4782
  const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(options?.queueOptions?.queueStore));
4768
4783
  const requiredKeys = ["get", "set", "stringify", "parse", "delete"];
@@ -4775,6 +4790,15 @@ var LavalinkManager = class extends EventEmitter2 {
4775
4790
  }
4776
4791
  if (typeof options?.queueOptions?.maxPreviousTracks !== "number" || options?.queueOptions?.maxPreviousTracks < 0) options.queueOptions.maxPreviousTracks = 25;
4777
4792
  }
4793
+ /**
4794
+ * Emits a debug event to the LavalinkManager
4795
+ * @param name name of the event
4796
+ * @param eventData event data
4797
+ */
4798
+ _emitDebugEvent(name, eventData) {
4799
+ if (!this.options?.advancedOptions?.enableDebugEvents) return;
4800
+ this.emit("debug", name, eventData);
4801
+ }
4778
4802
  /**
4779
4803
  * Create the Lavalink Manager
4780
4804
  * @param options
@@ -4924,13 +4948,11 @@ var LavalinkManager = class extends EventEmitter2 {
4924
4948
  if (!oldPlayer) return;
4925
4949
  if (typeof oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
4926
4950
  if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError) throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${safeStringify(oldPlayer.toJSON?.())}`);
4927
- else if (this.options?.advancedOptions?.enableDebugEvents) {
4928
- this.emit("debug", "PlayerDeleteInsteadOfDestroy" /* PlayerDeleteInsteadOfDestroy */, {
4929
- state: "warn",
4930
- message: "Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player",
4931
- functionLayer: "LavalinkManager > deletePlayer()"
4932
- });
4933
- }
4951
+ this._emitDebugEvent("PlayerDeleteInsteadOfDestroy" /* PlayerDeleteInsteadOfDestroy */, {
4952
+ state: "warn",
4953
+ message: "Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player",
4954
+ functionLayer: "LavalinkManager > deletePlayer()"
4955
+ });
4934
4956
  }
4935
4957
  return this.players.delete(guildId);
4936
4958
  }
@@ -4978,13 +5000,11 @@ var LavalinkManager = class extends EventEmitter2 {
4978
5000
  }
4979
5001
  }
4980
5002
  if (success > 0) this.initiated = true;
4981
- else if (this.options?.advancedOptions?.enableDebugEvents) {
4982
- this.emit("debug", "FailedToConnectToNodes" /* FailedToConnectToNodes */, {
4983
- state: "error",
4984
- message: "Failed to connect to at least 1 Node",
4985
- functionLayer: "LavalinkManager > init()"
4986
- });
4987
- }
5003
+ else this._emitDebugEvent("FailedToConnectToNodes" /* FailedToConnectToNodes */, {
5004
+ state: "error",
5005
+ message: "Failed to connect to at least 1 Node",
5006
+ functionLayer: "LavalinkManager > init()"
5007
+ });
4988
5008
  return this;
4989
5009
  }
4990
5010
  /**
@@ -5004,24 +5024,20 @@ var LavalinkManager = class extends EventEmitter2 {
5004
5024
  */
5005
5025
  async sendRawData(data) {
5006
5026
  if (!this.initiated) {
5007
- if (this.options?.advancedOptions?.enableDebugEvents) {
5008
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5009
- state: "log",
5010
- message: "Manager is not initated yet",
5011
- functionLayer: "LavalinkManager > sendRawData()"
5012
- });
5013
- }
5027
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5028
+ state: "log",
5029
+ message: "Manager is not initated yet",
5030
+ functionLayer: "LavalinkManager > sendRawData()"
5031
+ });
5014
5032
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet");
5015
5033
  return;
5016
5034
  }
5017
5035
  if (!("t" in data)) {
5018
- if (this.options?.advancedOptions?.enableDebugEvents) {
5019
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5020
- state: "error",
5021
- message: "No 't' in payload-data of the raw event:",
5022
- functionLayer: "LavalinkManager > sendRawData()"
5023
- });
5024
- }
5036
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5037
+ state: "error",
5038
+ message: "No 't' in payload-data of the raw event:",
5039
+ functionLayer: "LavalinkManager > sendRawData()"
5040
+ });
5025
5041
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 't' in payload-data of the raw event:", data);
5026
5042
  return;
5027
5043
  }
@@ -5034,47 +5050,39 @@ var LavalinkManager = class extends EventEmitter2 {
5034
5050
  if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
5035
5051
  const update = "d" in data ? data.d : data;
5036
5052
  if (!update) {
5037
- if (this.options?.advancedOptions?.enableDebugEvents) {
5038
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5039
- state: "warn",
5040
- message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
5041
- functionLayer: "LavalinkManager > sendRawData()"
5042
- });
5043
- }
5053
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5054
+ state: "warn",
5055
+ message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
5056
+ functionLayer: "LavalinkManager > sendRawData()"
5057
+ });
5044
5058
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no update data found in payload:", data);
5045
5059
  return;
5046
5060
  }
5047
5061
  if (!("token" in update) && !("session_id" in update)) {
5048
- if (this.options?.advancedOptions?.enableDebugEvents) {
5049
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5050
- state: "error",
5051
- message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
5052
- functionLayer: "LavalinkManager > sendRawData()"
5053
- });
5054
- }
5062
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5063
+ state: "error",
5064
+ message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
5065
+ functionLayer: "LavalinkManager > sendRawData()"
5066
+ });
5055
5067
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 'token' nor 'session_id' found in payload:", data);
5056
5068
  return;
5057
5069
  }
5058
5070
  const player = this.getPlayer(update.guild_id);
5059
5071
  if (!player) {
5060
- if (this.options?.advancedOptions?.enableDebugEvents) {
5061
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5062
- state: "warn",
5063
- message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
5064
- functionLayer: "LavalinkManager > sendRawData()"
5065
- });
5066
- }
5072
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5073
+ state: "warn",
5074
+ message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
5075
+ functionLayer: "LavalinkManager > sendRawData()"
5076
+ });
5067
5077
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, No Lavalink Player found via key: 'guild_id' of update-data:", update);
5068
5078
  return;
5069
5079
  }
5070
5080
  if (player.get("internal_destroystatus") === true) {
5071
- if (this.options?.advancedOptions?.enableDebugEvents) {
5072
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5073
- state: "warn",
5074
- message: `Player is in a destroying state. can't signal the voice states`,
5075
- functionLayer: "LavalinkManager > sendRawData()"
5076
- });
5077
- }
5081
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5082
+ state: "warn",
5083
+ message: `Player is in a destroying state. can't signal the voice states`,
5084
+ functionLayer: "LavalinkManager > sendRawData()"
5085
+ });
5078
5086
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states");
5079
5087
  return;
5080
5088
  }
@@ -5099,13 +5107,11 @@ var LavalinkManager = class extends EventEmitter2 {
5099
5107
  }
5100
5108
  }
5101
5109
  });
5102
- if (this.options?.advancedOptions?.enableDebugEvents) {
5103
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5104
- state: "log",
5105
- message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
5106
- functionLayer: "LavalinkManager > sendRawData()"
5107
- });
5108
- }
5110
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5111
+ state: "log",
5112
+ message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
5113
+ functionLayer: "LavalinkManager > sendRawData()"
5114
+ });
5109
5115
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session", { voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, playerVoice: player.voice, update });
5110
5116
  }
5111
5117
  return;
@@ -5114,13 +5120,11 @@ var LavalinkManager = class extends EventEmitter2 {
5114
5120
  if (update.user_id && player.voiceChannelId) {
5115
5121
  this.emit(update.channel_id === player.voiceChannelId ? "playerVoiceJoin" : "playerVoiceLeave", player, update.user_id);
5116
5122
  }
5117
- if (this.options?.advancedOptions?.enableDebugEvents) {
5118
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5119
- state: "warn",
5120
- message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
5121
- functionLayer: "LavalinkManager > sendRawData()"
5122
- });
5123
- }
5123
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5124
+ state: "warn",
5125
+ message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
5126
+ functionLayer: "LavalinkManager > sendRawData()"
5127
+ });
5124
5128
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, voice update user is not equal to provided client id of the manageroptions#client#id", "user:", update.user_id, "manager client id:", this.options?.client.id);
5125
5129
  return;
5126
5130
  }
@@ -5128,13 +5132,11 @@ var LavalinkManager = class extends EventEmitter2 {
5128
5132
  if (player.voiceChannelId !== update.channel_id) this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
5129
5133
  player.voice.sessionId = update.session_id || player.voice.sessionId;
5130
5134
  if (!player.voice.sessionId) {
5131
- if (this.options?.advancedOptions?.enableDebugEvents) {
5132
- this.emit("debug", "NoAudioDebug" /* NoAudioDebug */, {
5133
- state: "warn",
5134
- message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
5135
- functionLayer: "LavalinkManager > sendRawData()"
5136
- });
5137
- }
5135
+ this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
5136
+ state: "warn",
5137
+ message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
5138
+ functionLayer: "LavalinkManager > sendRawData()"
5139
+ });
5138
5140
  if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug(`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`);
5139
5141
  }
5140
5142
  player.voiceChannelId = update.channel_id;
@@ -5165,13 +5167,11 @@ var LavalinkManager = class extends EventEmitter2 {
5165
5167
  try {
5166
5168
  const previousPosition = player.position;
5167
5169
  const previousPaused = player.paused;
5168
- if (this.options?.advancedOptions?.enableDebugEvents) {
5169
- this.emit("debug", "PlayerAutoReconnect" /* PlayerAutoReconnect */, {
5170
- state: "log",
5171
- message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
5172
- functionLayer: "LavalinkManager > sendRawData()"
5173
- });
5174
- }
5170
+ this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
5171
+ state: "log",
5172
+ message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
5173
+ functionLayer: "LavalinkManager > sendRawData()"
5174
+ });
5175
5175
  if (!autoReconnectOnlyWithTracks || autoReconnectOnlyWithTracks && (player.queue.current || player.queue.tracks.length)) {
5176
5176
  await player.connect();
5177
5177
  }
@@ -5181,13 +5181,11 @@ var LavalinkManager = class extends EventEmitter2 {
5181
5181
  if (player.queue.tracks.length) {
5182
5182
  return void await player.play({ paused: previousPaused });
5183
5183
  }
5184
- if (this.options?.advancedOptions?.enableDebugEvents) {
5185
- this.emit("debug", "PlayerAutoReconnect" /* PlayerAutoReconnect */, {
5186
- state: "log",
5187
- message: `Auto reconnected, but nothing to play`,
5188
- functionLayer: "LavalinkManager > sendRawData()"
5189
- });
5190
- }
5184
+ this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
5185
+ state: "log",
5186
+ message: `Auto reconnected, but nothing to play`,
5187
+ functionLayer: "LavalinkManager > sendRawData()"
5188
+ });
5191
5189
  return;
5192
5190
  } catch (e) {
5193
5191
  console.error(e);