lavalink-client 2.7.4 → 2.7.5
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.d.mts +78 -26
- package/dist/index.d.ts +78 -26
- package/dist/index.js +532 -559
- package/dist/index.mjs +532 -559
- package/package.json +78 -78
package/dist/index.js
CHANGED
|
@@ -105,6 +105,9 @@ var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
|
|
|
105
105
|
DebugEvents2["FailedToConnectToNodes"] = "FailedToConnectToNodes";
|
|
106
106
|
DebugEvents2["NoAudioDebug"] = "NoAudioDebug";
|
|
107
107
|
DebugEvents2["PlayerAutoReconnect"] = "PlayerAutoReconnect";
|
|
108
|
+
DebugEvents2["PlayerDestroyFail"] = "PlayerDestroyFail";
|
|
109
|
+
DebugEvents2["PlayerChangeNodeFailNoEligibleNode"] = "PlayerChangeNodeFailNoEligibleNode";
|
|
110
|
+
DebugEvents2["PlayerChangeNodeFail"] = "PlayerChangeNodeFail";
|
|
108
111
|
return DebugEvents2;
|
|
109
112
|
})(DebugEvents || {});
|
|
110
113
|
var DestroyReasons = /* @__PURE__ */ ((DestroyReasons2) => {
|
|
@@ -748,7 +751,7 @@ var ManagerUtils = class {
|
|
|
748
751
|
}
|
|
749
752
|
validateQueryString(node, queryString, sourceString) {
|
|
750
753
|
if (!node.info) throw new Error("No Lavalink Node was provided");
|
|
751
|
-
if (!node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
|
|
754
|
+
if (this.LavalinkManager.options?.autoChecks?.sourcesValidations && !node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
|
|
752
755
|
if (!queryString.trim().length) throw new Error(`Query string is empty, please provide a valid query string.`);
|
|
753
756
|
if (sourceString === "speak" && queryString.length > 100) throw new Error(`Query is speak, which is limited to 100 characters.`);
|
|
754
757
|
if (this.LavalinkManager.options?.linksBlacklist?.length > 0) {
|
|
@@ -777,6 +780,7 @@ var ManagerUtils = class {
|
|
|
777
780
|
throw new Error(`Query string contains a link / word which isn't whitelisted.`);
|
|
778
781
|
}
|
|
779
782
|
}
|
|
783
|
+
if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
|
|
780
784
|
if ((SourceLinksRegexes.YoutubeMusicRegex.test(queryString) || SourceLinksRegexes.YoutubeRegex.test(queryString)) && !node.info?.sourceManagers?.includes("youtube")) {
|
|
781
785
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'youtube' enabled");
|
|
782
786
|
}
|
|
@@ -860,6 +864,7 @@ var ManagerUtils = class {
|
|
|
860
864
|
const source = DefaultSources[sourceString.toLowerCase().trim()];
|
|
861
865
|
if (!source) throw new Error(`Lavalink Node SearchQuerySource: '${sourceString}' is not available`);
|
|
862
866
|
if (!node.info) throw new Error("Lavalink Node does not have any info cached yet, not ready yet!");
|
|
867
|
+
if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
|
|
863
868
|
if (source === "amsearch" && !node.info?.sourceManagers?.includes("applemusic")) {
|
|
864
869
|
throw new Error("Lavalink Node has not 'applemusic' enabled, which is required to have 'amsearch' work");
|
|
865
870
|
}
|
|
@@ -881,7 +886,7 @@ var ManagerUtils = class {
|
|
|
881
886
|
if (source === "scsearch" && !node.info?.sourceManagers?.includes("soundcloud")) {
|
|
882
887
|
throw new Error("Lavalink Node has not 'soundcloud' enabled, which is required to have 'scsearch' work");
|
|
883
888
|
}
|
|
884
|
-
if (source === "speak" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
|
|
889
|
+
if (source === "speak" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
|
|
885
890
|
throw new Error("Lavalink Node has not 'speak' enabled, which is required to have 'speak' work");
|
|
886
891
|
}
|
|
887
892
|
if (source === "tdsearch" && !node.info?.sourceManagers?.includes("tidal")) {
|
|
@@ -890,7 +895,7 @@ var ManagerUtils = class {
|
|
|
890
895
|
if (source === "tdrec" && !node.info?.sourceManagers?.includes("tidal")) {
|
|
891
896
|
throw new Error("Lavalink Node has not 'tidal' enabled, which is required to have 'tdrec' work");
|
|
892
897
|
}
|
|
893
|
-
if (source === "tts" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
|
|
898
|
+
if (source === "tts" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
|
|
894
899
|
throw new Error("Lavalink Node has not 'tts' enabled, which is required to have 'tts' work");
|
|
895
900
|
}
|
|
896
901
|
if (source === "ftts" && !(node.info?.sourceManagers?.includes("ftts") || node.info?.sourceManagers?.includes("flowery-tts") || node.info?.sourceManagers?.includes("flowerytts"))) {
|
|
@@ -899,7 +904,7 @@ var ManagerUtils = class {
|
|
|
899
904
|
if (source === "ymsearch" && !node.info?.sourceManagers?.includes("yandexmusic")) {
|
|
900
905
|
throw new Error("Lavalink Node has not 'yandexmusic' enabled, which is required to have 'ymsearch' work");
|
|
901
906
|
}
|
|
902
|
-
if (source === "ytmsearch" && !node.info
|
|
907
|
+
if (source === "ytmsearch" && !node.info?.sourceManagers?.includes("youtube")) {
|
|
903
908
|
throw new Error("Lavalink Node has not 'youtube' enabled, which is required to have 'ytmsearch' work");
|
|
904
909
|
}
|
|
905
910
|
if (source === "ytsearch" && !node.info?.sourceManagers?.includes("youtube")) {
|
|
@@ -1042,9 +1047,6 @@ function safeStringify(obj, padding = 0) {
|
|
|
1042
1047
|
var LavalinkNode = class {
|
|
1043
1048
|
heartBeatPingTimestamp = 0;
|
|
1044
1049
|
heartBeatPongTimestamp = 0;
|
|
1045
|
-
get heartBeatPing() {
|
|
1046
|
-
return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
|
|
1047
|
-
}
|
|
1048
1050
|
heartBeatInterval;
|
|
1049
1051
|
pingTimeout;
|
|
1050
1052
|
isAlive = false;
|
|
@@ -1092,6 +1094,68 @@ var LavalinkNode = class {
|
|
|
1092
1094
|
socket = null;
|
|
1093
1095
|
/** Version of what the Lavalink Server should be */
|
|
1094
1096
|
version = "v4";
|
|
1097
|
+
/**
|
|
1098
|
+
* Returns the LavalinkManager of the Node
|
|
1099
|
+
*/
|
|
1100
|
+
get _LManager() {
|
|
1101
|
+
return this.NodeManager.LavalinkManager;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Returns the Heartbeat Ping of the Node
|
|
1105
|
+
*/
|
|
1106
|
+
get heartBeatPing() {
|
|
1107
|
+
return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Returns wether the plugin validations are enabled or not
|
|
1111
|
+
*/
|
|
1112
|
+
get _checkForPlugins() {
|
|
1113
|
+
return !!this._LManager.options?.autoChecks?.pluginValidations;
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
* Returns wether the source validations are enabled or not
|
|
1117
|
+
*/
|
|
1118
|
+
get _checkForSources() {
|
|
1119
|
+
return !!this._LManager.options?.autoChecks?.sourcesValidations;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Emits a debug event to the LavalinkManager
|
|
1123
|
+
* @param name name of the event
|
|
1124
|
+
* @param eventData event data
|
|
1125
|
+
*/
|
|
1126
|
+
_emitDebugEvent(name, eventData) {
|
|
1127
|
+
if (!this._LManager.options?.advancedOptions?.enableDebugEvents) return;
|
|
1128
|
+
this._LManager.emit("debug", name, eventData);
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Returns if connected to the Node.
|
|
1132
|
+
*
|
|
1133
|
+
* @example
|
|
1134
|
+
* ```ts
|
|
1135
|
+
* const isConnected = player.node.connected;
|
|
1136
|
+
* console.log("node is connected: ", isConnected ? "yes" : "no")
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
get connected() {
|
|
1140
|
+
return this.socket && this.socket.readyState === import_ws.default.OPEN;
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Returns the current ConnectionStatus
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* ```ts
|
|
1147
|
+
* try {
|
|
1148
|
+
* const statusOfConnection = player.node.connectionStatus;
|
|
1149
|
+
* console.log("node's connection status is:", statusOfConnection)
|
|
1150
|
+
* } catch (error) {
|
|
1151
|
+
* console.error("no socket available?", error)
|
|
1152
|
+
* }
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
get connectionStatus() {
|
|
1156
|
+
if (!this.socket) throw new Error("no websocket was initialized yet");
|
|
1157
|
+
return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
|
|
1158
|
+
}
|
|
1095
1159
|
/**
|
|
1096
1160
|
* Create a new Node
|
|
1097
1161
|
* @param options Lavalink Node Options
|
|
@@ -1181,10 +1245,10 @@ var LavalinkNode = class {
|
|
|
1181
1245
|
* ```
|
|
1182
1246
|
*/
|
|
1183
1247
|
async search(query, requestUser, throwOnEmpty = false) {
|
|
1184
|
-
const Query = this.
|
|
1185
|
-
this.
|
|
1186
|
-
if (Query.source) this.
|
|
1187
|
-
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.info.sourceManagers.includes("bandcamp")) {
|
|
1248
|
+
const Query = this._LManager.utils.transformQuery(query);
|
|
1249
|
+
this._LManager.utils.validateQueryString(this, Query.query, Query.source);
|
|
1250
|
+
if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
|
|
1251
|
+
if (["bcsearch", "bandcamp"].includes(Query.source) && this._LManager.options?.autoChecks?.sourcesValidations && !this.info.sourceManagers.includes("bandcamp")) {
|
|
1188
1252
|
throw new Error("Bandcamp Search only works on the player (lavaplayer version < 2.2.0!");
|
|
1189
1253
|
}
|
|
1190
1254
|
const requestUrl = new URL(`${this.restAddress}/loadtracks`);
|
|
@@ -1203,13 +1267,11 @@ var LavalinkNode = class {
|
|
|
1203
1267
|
});
|
|
1204
1268
|
const resTracks = res.loadType === "playlist" ? res.data?.tracks : res.loadType === "track" ? [res.data] : res.loadType === "search" ? Array.isArray(res.data) ? res.data : [res.data] : [];
|
|
1205
1269
|
if (throwOnEmpty === true && (res.loadType === "empty" || !resTracks.length)) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1270
|
+
this._emitDebugEvent("SearchNothingFound" /* SearchNothingFound */, {
|
|
1271
|
+
state: "warn",
|
|
1272
|
+
message: `Search found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
|
|
1273
|
+
functionLayer: "(LavalinkNode > node | player) > search()"
|
|
1274
|
+
});
|
|
1213
1275
|
throw new Error("Nothing found");
|
|
1214
1276
|
}
|
|
1215
1277
|
return {
|
|
@@ -1222,10 +1284,10 @@ var LavalinkNode = class {
|
|
|
1222
1284
|
author: res.data.info?.author || res.data.pluginInfo?.author || null,
|
|
1223
1285
|
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,
|
|
1224
1286
|
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,
|
|
1225
|
-
selectedTrack: typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? this.
|
|
1287
|
+
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,
|
|
1226
1288
|
duration: resTracks.length ? resTracks.reduce((acc, cur) => acc + (cur?.info?.duration || cur?.info?.length || 0), 0) : 0
|
|
1227
1289
|
} : null,
|
|
1228
|
-
tracks: resTracks.length ? resTracks.map((t) => this.
|
|
1290
|
+
tracks: resTracks.length ? resTracks.map((t) => this._LManager.utils.buildTrack(t, requestUser)) : []
|
|
1229
1291
|
};
|
|
1230
1292
|
}
|
|
1231
1293
|
/**
|
|
@@ -1242,29 +1304,27 @@ var LavalinkNode = class {
|
|
|
1242
1304
|
* ```
|
|
1243
1305
|
*/
|
|
1244
1306
|
async lavaSearch(query, requestUser, throwOnEmpty = false) {
|
|
1245
|
-
const Query = this.
|
|
1246
|
-
if (Query.source) this.
|
|
1307
|
+
const Query = this._LManager.utils.transformLavaSearchQuery(query);
|
|
1308
|
+
if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
|
|
1247
1309
|
if (/^https?:\/\//.test(Query.query)) return this.search({ query: Query.query, source: Query.source }, requestUser);
|
|
1248
1310
|
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"`);
|
|
1249
|
-
if (!this.info
|
|
1250
|
-
if (!this.info
|
|
1311
|
+
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}`);
|
|
1312
|
+
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}`);
|
|
1251
1313
|
const { response } = await this.rawRequest(`/loadsearch?query=${Query.source ? `${Query.source}:` : ""}${encodeURIComponent(Query.query)}${Query.types?.length ? `&types=${Query.types.join(",")}` : ""}`);
|
|
1252
1314
|
const res = response.status === 204 ? {} : await response.json();
|
|
1253
1315
|
if (throwOnEmpty === true && !Object.entries(res).flat().filter(Boolean).length) {
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1316
|
+
this._emitDebugEvent("LavaSearchNothingFound" /* LavaSearchNothingFound */, {
|
|
1317
|
+
state: "warn",
|
|
1318
|
+
message: `LavaSearch found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
|
|
1319
|
+
functionLayer: "(LavalinkNode > node | player) > lavaSearch()"
|
|
1320
|
+
});
|
|
1261
1321
|
throw new Error("Nothing found");
|
|
1262
1322
|
}
|
|
1263
1323
|
return {
|
|
1264
|
-
tracks: res.tracks?.map((v) => this.
|
|
1265
|
-
albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1266
|
-
artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1267
|
-
playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1324
|
+
tracks: res.tracks?.map((v) => this._LManager.utils.buildTrack(v, requestUser)) || [],
|
|
1325
|
+
albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1326
|
+
artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1327
|
+
playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1268
1328
|
texts: res.texts?.map((v) => ({ text: v.text, pluginInfo: v?.plugin || v.pluginInfo })) || [],
|
|
1269
1329
|
pluginInfo: res.pluginInfo || res?.plugin
|
|
1270
1330
|
};
|
|
@@ -1293,13 +1353,11 @@ var LavalinkNode = class {
|
|
|
1293
1353
|
r.path = url.pathname + url.search;
|
|
1294
1354
|
}
|
|
1295
1355
|
});
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1356
|
+
this._emitDebugEvent("PlayerUpdateSuccess" /* PlayerUpdateSuccess */, {
|
|
1357
|
+
state: "log",
|
|
1358
|
+
message: `Player get's updated with following payload :: ${safeStringify(data.playerOptions, 3)}`,
|
|
1359
|
+
functionLayer: "LavalinkNode > node > updatePlayer()"
|
|
1360
|
+
});
|
|
1303
1361
|
this.syncPlayerData({}, res);
|
|
1304
1362
|
return res;
|
|
1305
1363
|
}
|
|
@@ -1335,19 +1393,17 @@ var LavalinkNode = class {
|
|
|
1335
1393
|
*/
|
|
1336
1394
|
connect(sessionId) {
|
|
1337
1395
|
if (this.connected) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
});
|
|
1344
|
-
}
|
|
1396
|
+
this._emitDebugEvent("TryingConnectWhileConnected" /* TryingConnectWhileConnected */, {
|
|
1397
|
+
state: "warn",
|
|
1398
|
+
message: `Tryed to connect to node, but it's already connected!`,
|
|
1399
|
+
functionLayer: "LavalinkNode > node > connect()"
|
|
1400
|
+
});
|
|
1345
1401
|
return;
|
|
1346
1402
|
}
|
|
1347
1403
|
const headers = {
|
|
1348
1404
|
Authorization: this.options.authorization,
|
|
1349
|
-
"User-Id": this.
|
|
1350
|
-
"Client-Name": this.
|
|
1405
|
+
"User-Id": this._LManager.options.client.id,
|
|
1406
|
+
"Client-Name": this._LManager.options.client.username || "Lavalink-Client"
|
|
1351
1407
|
};
|
|
1352
1408
|
if (typeof this.options.sessionId === "string" || typeof sessionId === "string") {
|
|
1353
1409
|
headers["Session-Id"] = this.options.sessionId || sessionId;
|
|
@@ -1360,34 +1416,27 @@ var LavalinkNode = class {
|
|
|
1360
1416
|
this.socket.on("error", this.error.bind(this));
|
|
1361
1417
|
}
|
|
1362
1418
|
heartBeat() {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
});
|
|
1369
|
-
}
|
|
1419
|
+
this._emitDebugEvent("HeartBeatTriggered" /* HeartBeatTriggered */, {
|
|
1420
|
+
state: "log",
|
|
1421
|
+
message: `Node Socket Heartbeat triggered, resetting old Timeout to 65000ms (should happen every 60s due to /stats event)`,
|
|
1422
|
+
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat()"
|
|
1423
|
+
});
|
|
1370
1424
|
this.resetAckTimeouts(false, true);
|
|
1371
1425
|
if (this.pingTimeout) clearTimeout(this.pingTimeout);
|
|
1372
1426
|
this.pingTimeout = setTimeout(() => {
|
|
1373
1427
|
this.pingTimeout = null;
|
|
1374
1428
|
if (!this.socket) {
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
|
|
1379
|
-
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
1385
|
-
this.NodeManager.LavalinkManager.emit("debug", "SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
|
|
1386
|
-
state: "warn",
|
|
1387
|
-
message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
|
|
1429
|
+
return this._emitDebugEvent("NoSocketOnDestroy" /* NoSocketOnDestroy */, {
|
|
1430
|
+
state: "error",
|
|
1431
|
+
message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
|
|
1388
1432
|
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1389
1433
|
});
|
|
1390
1434
|
}
|
|
1435
|
+
this._emitDebugEvent("SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
|
|
1436
|
+
state: "warn",
|
|
1437
|
+
message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
|
|
1438
|
+
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1439
|
+
});
|
|
1391
1440
|
this.isAlive = false;
|
|
1392
1441
|
this.socket.terminate();
|
|
1393
1442
|
}, 65e3);
|
|
@@ -1423,71 +1472,75 @@ var LavalinkNode = class {
|
|
|
1423
1472
|
*/
|
|
1424
1473
|
destroy(destroyReason, deleteNode = true, movePlayers = false) {
|
|
1425
1474
|
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1426
|
-
const players = this.
|
|
1427
|
-
if (players
|
|
1428
|
-
const enableDebugEvents = this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents;
|
|
1429
|
-
const handlePlayerOperations = () => {
|
|
1430
|
-
if (movePlayers) {
|
|
1431
|
-
const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
|
|
1432
|
-
if (nodeToMove) {
|
|
1433
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1434
|
-
(player) => player.changeNode(nodeToMove.options.id).catch((error) => {
|
|
1435
|
-
if (enableDebugEvents) {
|
|
1436
|
-
console.error(`Node > destroy() Failed to move player ${player.guildId}: ${error.message}`);
|
|
1437
|
-
}
|
|
1438
|
-
return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
|
|
1439
|
-
if (enableDebugEvents) {
|
|
1440
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`);
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
})
|
|
1444
|
-
));
|
|
1445
|
-
} else {
|
|
1446
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1447
|
-
(player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
|
|
1448
|
-
if (enableDebugEvents) {
|
|
1449
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
|
|
1450
|
-
}
|
|
1451
|
-
})
|
|
1452
|
-
));
|
|
1453
|
-
}
|
|
1454
|
-
} else {
|
|
1455
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1456
|
-
(player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
|
|
1457
|
-
if (enableDebugEvents) {
|
|
1458
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
|
|
1459
|
-
}
|
|
1460
|
-
})
|
|
1461
|
-
));
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1464
|
-
handlePlayerOperations().finally(() => {
|
|
1465
|
-
this.socket?.close(1e3, "Node-Destroy");
|
|
1466
|
-
this.socket?.removeAllListeners();
|
|
1467
|
-
this.socket = null;
|
|
1468
|
-
this.resetReconnectionAttempts();
|
|
1469
|
-
if (deleteNode) {
|
|
1470
|
-
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1471
|
-
this.NodeManager.nodes.delete(this.id);
|
|
1472
|
-
this.resetAckTimeouts(true, true);
|
|
1473
|
-
} else {
|
|
1474
|
-
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1475
|
-
}
|
|
1476
|
-
});
|
|
1477
|
-
} else {
|
|
1475
|
+
const players = this._LManager.players.filter((p) => p.node.id === this.id);
|
|
1476
|
+
if (!players?.size) {
|
|
1478
1477
|
this.socket?.close(1e3, "Node-Destroy");
|
|
1479
1478
|
this.socket?.removeAllListeners();
|
|
1480
1479
|
this.socket = null;
|
|
1481
1480
|
this.resetReconnectionAttempts();
|
|
1482
|
-
if (deleteNode) {
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
}
|
|
1481
|
+
if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1482
|
+
;
|
|
1483
|
+
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1484
|
+
this.NodeManager.nodes.delete(this.id);
|
|
1485
|
+
this.resetAckTimeouts(true, true);
|
|
1486
|
+
return;
|
|
1489
1487
|
}
|
|
1490
|
-
|
|
1488
|
+
const handlePlayerOperations = () => {
|
|
1489
|
+
if (!movePlayers) {
|
|
1490
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1491
|
+
(player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
|
|
1492
|
+
this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
|
|
1493
|
+
state: "error",
|
|
1494
|
+
message: `Failed to destroy player ${player.guildId}: ${error.message}`,
|
|
1495
|
+
error,
|
|
1496
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1497
|
+
});
|
|
1498
|
+
})
|
|
1499
|
+
));
|
|
1500
|
+
}
|
|
1501
|
+
const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
|
|
1502
|
+
if (!nodeToMove) {
|
|
1503
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1504
|
+
(player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
|
|
1505
|
+
this._emitDebugEvent("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */, {
|
|
1506
|
+
state: "error",
|
|
1507
|
+
message: `Failed to destroy player ${player.guildId}: ${error.message}`,
|
|
1508
|
+
error,
|
|
1509
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1510
|
+
});
|
|
1511
|
+
})
|
|
1512
|
+
));
|
|
1513
|
+
}
|
|
1514
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1515
|
+
(player) => player.changeNode(nodeToMove.options.id).catch((error) => {
|
|
1516
|
+
this._emitDebugEvent("PlayerChangeNodeFail" /* PlayerChangeNodeFail */, {
|
|
1517
|
+
state: "error",
|
|
1518
|
+
message: `Failed to move player ${player.guildId}: ${error.message}`,
|
|
1519
|
+
error,
|
|
1520
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1521
|
+
});
|
|
1522
|
+
return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
|
|
1523
|
+
this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
|
|
1524
|
+
state: "error",
|
|
1525
|
+
message: `Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`,
|
|
1526
|
+
error: destroyError,
|
|
1527
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1528
|
+
});
|
|
1529
|
+
});
|
|
1530
|
+
})
|
|
1531
|
+
));
|
|
1532
|
+
};
|
|
1533
|
+
return void handlePlayerOperations().finally(() => {
|
|
1534
|
+
this.socket?.close(1e3, "Node-Destroy");
|
|
1535
|
+
this.socket?.removeAllListeners();
|
|
1536
|
+
this.socket = null;
|
|
1537
|
+
this.resetReconnectionAttempts();
|
|
1538
|
+
if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1539
|
+
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1540
|
+
this.NodeManager.nodes.delete(this.id);
|
|
1541
|
+
this.resetAckTimeouts(true, true);
|
|
1542
|
+
return;
|
|
1543
|
+
});
|
|
1491
1544
|
}
|
|
1492
1545
|
/**
|
|
1493
1546
|
* Disconnects the Node-Connection (Websocket)
|
|
@@ -1510,35 +1563,6 @@ var LavalinkNode = class {
|
|
|
1510
1563
|
this.resetReconnectionAttempts();
|
|
1511
1564
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
|
|
1512
1565
|
}
|
|
1513
|
-
/**
|
|
1514
|
-
* Returns if connected to the Node.
|
|
1515
|
-
*
|
|
1516
|
-
* @example
|
|
1517
|
-
* ```ts
|
|
1518
|
-
* const isConnected = player.node.connected;
|
|
1519
|
-
* console.log("node is connected: ", isConnected ? "yes" : "no")
|
|
1520
|
-
* ```
|
|
1521
|
-
*/
|
|
1522
|
-
get connected() {
|
|
1523
|
-
return this.socket && this.socket.readyState === import_ws.default.OPEN;
|
|
1524
|
-
}
|
|
1525
|
-
/**
|
|
1526
|
-
* Returns the current ConnectionStatus
|
|
1527
|
-
*
|
|
1528
|
-
* @example
|
|
1529
|
-
* ```ts
|
|
1530
|
-
* try {
|
|
1531
|
-
* const statusOfConnection = player.node.connectionStatus;
|
|
1532
|
-
* console.log("node's connection status is:", statusOfConnection)
|
|
1533
|
-
* } catch (error) {
|
|
1534
|
-
* console.error("no socket available?", error)
|
|
1535
|
-
* }
|
|
1536
|
-
* ```
|
|
1537
|
-
*/
|
|
1538
|
-
get connectionStatus() {
|
|
1539
|
-
if (!this.socket) throw new Error("no websocket was initialized yet");
|
|
1540
|
-
return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
|
|
1541
|
-
}
|
|
1542
1566
|
/**
|
|
1543
1567
|
* Gets all Players of a Node
|
|
1544
1568
|
* @returns array of players inside of lavalink
|
|
@@ -1612,7 +1636,7 @@ var LavalinkNode = class {
|
|
|
1612
1636
|
*/
|
|
1613
1637
|
singleTrack: async (encoded, requester) => {
|
|
1614
1638
|
if (!encoded) throw new SyntaxError("No encoded (Base64 string) was provided");
|
|
1615
|
-
return this.
|
|
1639
|
+
return this._LManager.utils?.buildTrack(await this.request(`/decodetrack?encodedTrack=${encodeURIComponent(encoded.replace(/\s/g, ""))}`), requester);
|
|
1616
1640
|
},
|
|
1617
1641
|
/**
|
|
1618
1642
|
* Decodes multiple tracks into their info
|
|
@@ -1633,7 +1657,7 @@ var LavalinkNode = class {
|
|
|
1633
1657
|
r.method = "POST";
|
|
1634
1658
|
r.body = safeStringify(encodeds);
|
|
1635
1659
|
r.headers["Content-Type"] = "application/json";
|
|
1636
|
-
}).then((r) => r.map((track) => this.
|
|
1660
|
+
}).then((r) => r.map((track) => this._LManager.utils.buildTrack(track, requester)));
|
|
1637
1661
|
}
|
|
1638
1662
|
};
|
|
1639
1663
|
lyrics = {
|
|
@@ -1652,8 +1676,8 @@ var LavalinkNode = class {
|
|
|
1652
1676
|
*/
|
|
1653
1677
|
get: async (track, skipTrackSource = false) => {
|
|
1654
1678
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1655
|
-
if (!this.info
|
|
1656
|
-
if (!this.info
|
|
1679
|
+
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}`);
|
|
1680
|
+
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}`);
|
|
1657
1681
|
const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
|
|
1658
1682
|
return await this.request(url);
|
|
1659
1683
|
},
|
|
@@ -1672,8 +1696,8 @@ var LavalinkNode = class {
|
|
|
1672
1696
|
*/
|
|
1673
1697
|
getCurrent: async (guildId, skipTrackSource = false) => {
|
|
1674
1698
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1675
|
-
if (!this.info
|
|
1676
|
-
if (!this.info
|
|
1699
|
+
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}`);
|
|
1700
|
+
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}`);
|
|
1677
1701
|
const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
|
|
1678
1702
|
return await this.request(url);
|
|
1679
1703
|
},
|
|
@@ -1691,7 +1715,7 @@ var LavalinkNode = class {
|
|
|
1691
1715
|
*/
|
|
1692
1716
|
subscribe: async (guildId) => {
|
|
1693
1717
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1694
|
-
if (!this.info
|
|
1718
|
+
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}`);
|
|
1695
1719
|
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
|
|
1696
1720
|
options.method = "POST";
|
|
1697
1721
|
});
|
|
@@ -1710,7 +1734,7 @@ var LavalinkNode = class {
|
|
|
1710
1734
|
*/
|
|
1711
1735
|
unsubscribe: async (guildId) => {
|
|
1712
1736
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1713
|
-
if (!this.info
|
|
1737
|
+
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}`);
|
|
1714
1738
|
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
|
|
1715
1739
|
options.method = "DELETE";
|
|
1716
1740
|
});
|
|
@@ -1824,7 +1848,7 @@ var LavalinkNode = class {
|
|
|
1824
1848
|
*/
|
|
1825
1849
|
syncPlayerData(data, res) {
|
|
1826
1850
|
if (typeof data === "object" && typeof data?.guildId === "string" && typeof data.playerOptions === "object" && Object.keys(data.playerOptions).length > 0) {
|
|
1827
|
-
const player = this.
|
|
1851
|
+
const player = this._LManager.getPlayer(data.guildId);
|
|
1828
1852
|
if (!player) return;
|
|
1829
1853
|
if (typeof data.playerOptions.paused !== "undefined") {
|
|
1830
1854
|
player.paused = data.playerOptions.paused;
|
|
@@ -1836,8 +1860,8 @@ var LavalinkNode = class {
|
|
|
1836
1860
|
}
|
|
1837
1861
|
if (typeof data.playerOptions.voice !== "undefined") player.voice = data.playerOptions.voice;
|
|
1838
1862
|
if (typeof data.playerOptions.volume !== "undefined") {
|
|
1839
|
-
if (this.
|
|
1840
|
-
player.volume = Math.round(data.playerOptions.volume / this.
|
|
1863
|
+
if (this._LManager.options.playerOptions.volumeDecrementer) {
|
|
1864
|
+
player.volume = Math.round(data.playerOptions.volume / this._LManager.options.playerOptions.volumeDecrementer);
|
|
1841
1865
|
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
1842
1866
|
} else {
|
|
1843
1867
|
player.volume = Math.round(data.playerOptions.volume);
|
|
@@ -1861,7 +1885,7 @@ var LavalinkNode = class {
|
|
|
1861
1885
|
}
|
|
1862
1886
|
}
|
|
1863
1887
|
if (res?.guildId === "string" && typeof res?.voice !== "undefined") {
|
|
1864
|
-
const player = this.
|
|
1888
|
+
const player = this._LManager.getPlayer(data.guildId);
|
|
1865
1889
|
if (!player) return;
|
|
1866
1890
|
if (typeof res?.voice?.connected === "boolean" && res.voice.connected === false) {
|
|
1867
1891
|
player.destroy("LavalinkNoVoice" /* LavalinkNoVoice */);
|
|
@@ -1994,7 +2018,7 @@ var LavalinkNode = class {
|
|
|
1994
2018
|
}
|
|
1995
2019
|
} catch (e) {
|
|
1996
2020
|
if (this.NodeManager?.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
|
|
1997
|
-
this.
|
|
2021
|
+
this._LManager.emit("debug", "SocketCleanupError" /* SocketCleanupError */, {
|
|
1998
2022
|
state: "warn",
|
|
1999
2023
|
message: `An error occurred during socket cleanup in close() (likely a race condition): ${e.message}`,
|
|
2000
2024
|
functionLayer: "LavalinkNode > close()"
|
|
@@ -2010,9 +2034,9 @@ var LavalinkNode = class {
|
|
|
2010
2034
|
this.reconnect();
|
|
2011
2035
|
}
|
|
2012
2036
|
}
|
|
2013
|
-
this.
|
|
2014
|
-
if (!this.
|
|
2015
|
-
if (this.
|
|
2037
|
+
this._LManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
2038
|
+
if (!this._LManager.options.autoMove) return p.playing = false;
|
|
2039
|
+
if (this._LManager.options.autoMove) {
|
|
2016
2040
|
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
2017
2041
|
return p.playing = false;
|
|
2018
2042
|
p.moveNode();
|
|
@@ -2053,17 +2077,12 @@ var LavalinkNode = class {
|
|
|
2053
2077
|
break;
|
|
2054
2078
|
case "playerUpdate":
|
|
2055
2079
|
{
|
|
2056
|
-
const player = this.
|
|
2057
|
-
if (!player) {
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2063
|
-
});
|
|
2064
|
-
}
|
|
2065
|
-
return;
|
|
2066
|
-
}
|
|
2080
|
+
const player = this._LManager.getPlayer(payload.guildId);
|
|
2081
|
+
if (!player) return this._emitDebugEvent("PlayerUpdateNoPlayer" /* PlayerUpdateNoPlayer */, {
|
|
2082
|
+
state: "error",
|
|
2083
|
+
message: `PlayerUpdate Event Triggered, but no player found of payload.guildId: ${payload.guildId}`,
|
|
2084
|
+
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2085
|
+
});
|
|
2067
2086
|
const oldPlayer = player?.toJSON();
|
|
2068
2087
|
player.lastPositionChange = Date.now();
|
|
2069
2088
|
player.lastPosition = payload.state.position || 0;
|
|
@@ -2072,16 +2091,14 @@ var LavalinkNode = class {
|
|
|
2072
2091
|
if (!player.createdTimeStamp && payload.state.time) player.createdTimeStamp = payload.state.time;
|
|
2073
2092
|
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && (0, import_path.isAbsolute)(player.queue.current?.info?.uri))) {
|
|
2074
2093
|
player.filterManager.filterUpdatedState = false;
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
});
|
|
2081
|
-
}
|
|
2094
|
+
this._emitDebugEvent("PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
|
|
2095
|
+
state: "log",
|
|
2096
|
+
message: `Fixing FilterState on "${player.guildId}" because player.options.instaUpdateFiltersFix === true`,
|
|
2097
|
+
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2098
|
+
});
|
|
2082
2099
|
await player.seek(player.position);
|
|
2083
2100
|
}
|
|
2084
|
-
this.
|
|
2101
|
+
this._LManager.emit("playerUpdate", oldPlayer, player);
|
|
2085
2102
|
}
|
|
2086
2103
|
break;
|
|
2087
2104
|
case "event":
|
|
@@ -2095,14 +2112,12 @@ var LavalinkNode = class {
|
|
|
2095
2112
|
try {
|
|
2096
2113
|
this.NodeManager.emit("resumed", this, payload, await this.fetchAllPlayers());
|
|
2097
2114
|
} catch (e) {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
});
|
|
2105
|
-
}
|
|
2115
|
+
this._emitDebugEvent("ResumingFetchingError" /* ResumingFetchingError */, {
|
|
2116
|
+
state: "error",
|
|
2117
|
+
message: `Failed to fetch players for resumed event, falling back without players array`,
|
|
2118
|
+
error: e,
|
|
2119
|
+
functionLayer: "LavalinkNode > nodeEvent > resumed"
|
|
2120
|
+
});
|
|
2106
2121
|
this.NodeManager.emit("resumed", this, payload, []);
|
|
2107
2122
|
}
|
|
2108
2123
|
}
|
|
@@ -2115,7 +2130,7 @@ var LavalinkNode = class {
|
|
|
2115
2130
|
/** @private middleware util function for handling all kind of events from websocket */
|
|
2116
2131
|
async handleEvent(payload) {
|
|
2117
2132
|
if (!payload?.guildId) return;
|
|
2118
|
-
const player = this.
|
|
2133
|
+
const player = this._LManager.getPlayer(payload.guildId);
|
|
2119
2134
|
if (!player) return;
|
|
2120
2135
|
switch (payload.type) {
|
|
2121
2136
|
case "TrackStartEvent":
|
|
@@ -2161,7 +2176,7 @@ var LavalinkNode = class {
|
|
|
2161
2176
|
return;
|
|
2162
2177
|
}
|
|
2163
2178
|
getTrackOfPayload(payload) {
|
|
2164
|
-
return "track" in payload ? this.
|
|
2179
|
+
return "track" in payload ? this._LManager.utils.buildTrack(payload.track, void 0) : null;
|
|
2165
2180
|
}
|
|
2166
2181
|
/** @private util function for handling trackStart event */
|
|
2167
2182
|
async trackStart(player, track, payload) {
|
|
@@ -2169,31 +2184,26 @@ var LavalinkNode = class {
|
|
|
2169
2184
|
player.playing = true;
|
|
2170
2185
|
player.paused = false;
|
|
2171
2186
|
}
|
|
2172
|
-
if (this.
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
});
|
|
2179
|
-
}
|
|
2180
|
-
return;
|
|
2187
|
+
if (this._LManager.options?.emitNewSongsOnly === true && player.queue.previous[0]?.info?.identifier === track?.info?.identifier) {
|
|
2188
|
+
return this._emitDebugEvent("TrackStartNewSongsOnly" /* TrackStartNewSongsOnly */, {
|
|
2189
|
+
state: "log",
|
|
2190
|
+
message: `TrackStart not Emitting, because playing the previous song again.`,
|
|
2191
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2192
|
+
});
|
|
2181
2193
|
}
|
|
2182
2194
|
if (!player.queue.current) {
|
|
2183
2195
|
player.queue.current = this.getTrackOfPayload(payload);
|
|
2184
2196
|
if (player.queue.current) {
|
|
2185
2197
|
await player.queue.utils.save();
|
|
2186
2198
|
} else {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
});
|
|
2193
|
-
}
|
|
2199
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2200
|
+
state: "warn",
|
|
2201
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2202
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2203
|
+
});
|
|
2194
2204
|
}
|
|
2195
2205
|
}
|
|
2196
|
-
this.
|
|
2206
|
+
this._LManager.emit("trackStart", player, player.queue.current, payload);
|
|
2197
2207
|
return;
|
|
2198
2208
|
}
|
|
2199
2209
|
/** @private util function for handling trackEnd event */
|
|
@@ -2201,14 +2211,12 @@ var LavalinkNode = class {
|
|
|
2201
2211
|
if (player.get("internal_nodeChanging") === true) return;
|
|
2202
2212
|
const trackToUse = track || this.getTrackOfPayload(payload);
|
|
2203
2213
|
if (payload.reason === "replaced") {
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}
|
|
2211
|
-
this.NodeManager.LavalinkManager.emit("trackEnd", player, trackToUse, payload);
|
|
2214
|
+
this._emitDebugEvent("TrackEndReplaced" /* TrackEndReplaced */, {
|
|
2215
|
+
state: "warn",
|
|
2216
|
+
message: `TrackEnd Event does not handle any playback, because the track was replaced.`,
|
|
2217
|
+
functionLayer: "LavalinkNode > trackEnd()"
|
|
2218
|
+
});
|
|
2219
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2212
2220
|
return;
|
|
2213
2221
|
}
|
|
2214
2222
|
if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) return this.queueEnd(player, track, payload);
|
|
@@ -2216,8 +2224,8 @@ var LavalinkNode = class {
|
|
|
2216
2224
|
if (player.get("internal_destroystatus") === true) return;
|
|
2217
2225
|
await queueTrackEnd(player);
|
|
2218
2226
|
if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
|
|
2219
|
-
this.
|
|
2220
|
-
if (this.
|
|
2227
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2228
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2221
2229
|
player.play({ noReplace: true });
|
|
2222
2230
|
}
|
|
2223
2231
|
return;
|
|
@@ -2230,30 +2238,28 @@ var LavalinkNode = class {
|
|
|
2230
2238
|
}
|
|
2231
2239
|
if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
|
|
2232
2240
|
player.set("internal_skipped", false);
|
|
2233
|
-
this.
|
|
2234
|
-
if (this.
|
|
2241
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2242
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2235
2243
|
player.play({ noReplace: true });
|
|
2236
2244
|
}
|
|
2237
2245
|
return;
|
|
2238
2246
|
}
|
|
2239
2247
|
/** @private util function for handling trackStuck event */
|
|
2240
2248
|
async trackStuck(player, track, payload) {
|
|
2241
|
-
if (this.
|
|
2242
|
-
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.
|
|
2249
|
+
if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
|
|
2250
|
+
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
|
|
2243
2251
|
player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
|
|
2244
|
-
if (oldTimestamps.length > this.
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
+
if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
|
|
2253
|
+
this._emitDebugEvent("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */, {
|
|
2254
|
+
state: "log",
|
|
2255
|
+
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}"`,
|
|
2256
|
+
functionLayer: "LavalinkNode > trackStuck()"
|
|
2257
|
+
});
|
|
2252
2258
|
player.destroy("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */);
|
|
2253
2259
|
return;
|
|
2254
2260
|
}
|
|
2255
2261
|
}
|
|
2256
|
-
this.
|
|
2262
|
+
this._LManager.emit("trackStuck", player, track || this.getTrackOfPayload(payload), payload);
|
|
2257
2263
|
if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) {
|
|
2258
2264
|
try {
|
|
2259
2265
|
await player.node.updatePlayer({ guildId: player.guildId, playerOptions: { track: { encoded: null } } });
|
|
@@ -2266,54 +2272,52 @@ var LavalinkNode = class {
|
|
|
2266
2272
|
if (!player.queue.current) {
|
|
2267
2273
|
return this.queueEnd(player, track || this.getTrackOfPayload(payload), payload);
|
|
2268
2274
|
}
|
|
2269
|
-
if (this.
|
|
2275
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2270
2276
|
player.play({ track: player.queue.current, noReplace: false });
|
|
2271
2277
|
}
|
|
2272
2278
|
return;
|
|
2273
2279
|
}
|
|
2274
2280
|
/** @private util function for handling trackError event */
|
|
2275
2281
|
async trackError(player, track, payload) {
|
|
2276
|
-
if (this.
|
|
2277
|
-
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.
|
|
2282
|
+
if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
|
|
2283
|
+
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
|
|
2278
2284
|
player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
|
|
2279
|
-
if (oldTimestamps.length > this.
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
});
|
|
2286
|
-
}
|
|
2285
|
+
if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
|
|
2286
|
+
this._emitDebugEvent("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */, {
|
|
2287
|
+
state: "log",
|
|
2288
|
+
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}"`,
|
|
2289
|
+
functionLayer: "LavalinkNode > trackError()"
|
|
2290
|
+
});
|
|
2287
2291
|
player.destroy("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */);
|
|
2288
2292
|
return;
|
|
2289
2293
|
}
|
|
2290
2294
|
}
|
|
2291
|
-
this.
|
|
2295
|
+
this._LManager.emit("trackError", player, track || this.getTrackOfPayload(payload), payload);
|
|
2292
2296
|
return;
|
|
2293
2297
|
}
|
|
2294
2298
|
/** @private util function for handling socketClosed event */
|
|
2295
2299
|
socketClosed(player, payload) {
|
|
2296
|
-
this.
|
|
2300
|
+
this._LManager.emit("playerSocketClosed", player, payload);
|
|
2297
2301
|
return;
|
|
2298
2302
|
}
|
|
2299
2303
|
/** @private util function for handling SponsorBlock Segmentloaded event */
|
|
2300
2304
|
SponsorBlockSegmentLoaded(player, track, payload) {
|
|
2301
|
-
this.
|
|
2305
|
+
this._LManager.emit("SegmentsLoaded", player, track || this.getTrackOfPayload(payload), payload);
|
|
2302
2306
|
return;
|
|
2303
2307
|
}
|
|
2304
2308
|
/** @private util function for handling SponsorBlock SegmentSkipped event */
|
|
2305
2309
|
SponsorBlockSegmentSkipped(player, track, payload) {
|
|
2306
|
-
this.
|
|
2310
|
+
this._LManager.emit("SegmentSkipped", player, track || this.getTrackOfPayload(payload), payload);
|
|
2307
2311
|
return;
|
|
2308
2312
|
}
|
|
2309
2313
|
/** @private util function for handling SponsorBlock Chaptersloaded event */
|
|
2310
2314
|
SponsorBlockChaptersLoaded(player, track, payload) {
|
|
2311
|
-
this.
|
|
2315
|
+
this._LManager.emit("ChaptersLoaded", player, track || this.getTrackOfPayload(payload), payload);
|
|
2312
2316
|
return;
|
|
2313
2317
|
}
|
|
2314
2318
|
/** @private util function for handling SponsorBlock Chaptersstarted event */
|
|
2315
2319
|
SponsorBlockChapterStarted(player, track, payload) {
|
|
2316
|
-
this.
|
|
2320
|
+
this._LManager.emit("ChapterStarted", player, track || this.getTrackOfPayload(payload), payload);
|
|
2317
2321
|
return;
|
|
2318
2322
|
}
|
|
2319
2323
|
/**
|
|
@@ -2328,7 +2332,7 @@ var LavalinkNode = class {
|
|
|
2328
2332
|
* ```
|
|
2329
2333
|
*/
|
|
2330
2334
|
async getSponsorBlock(player) {
|
|
2331
|
-
if (!this.info
|
|
2335
|
+
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}`);
|
|
2332
2336
|
return await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`);
|
|
2333
2337
|
}
|
|
2334
2338
|
/**
|
|
@@ -2343,7 +2347,7 @@ var LavalinkNode = class {
|
|
|
2343
2347
|
* ```
|
|
2344
2348
|
*/
|
|
2345
2349
|
async setSponsorBlock(player, segments = ["sponsor", "selfpromo"]) {
|
|
2346
|
-
if (!this.info
|
|
2350
|
+
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}`);
|
|
2347
2351
|
if (!segments.length) throw new RangeError("No Segments provided. Did you ment to use 'deleteSponsorBlock'?");
|
|
2348
2352
|
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(", ")}`);
|
|
2349
2353
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
|
|
@@ -2352,13 +2356,11 @@ var LavalinkNode = class {
|
|
|
2352
2356
|
r.body = safeStringify(segments.map((v) => v.toLowerCase()));
|
|
2353
2357
|
});
|
|
2354
2358
|
player.set("internal_sponsorBlockCategories", segments.map((v) => v.toLowerCase()));
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2359
|
+
this._emitDebugEvent("SetSponsorBlock" /* SetSponsorBlock */, {
|
|
2360
|
+
state: "log",
|
|
2361
|
+
message: `SponsorBlock was set for Player: ${player.guildId} to: ${segments.map((v) => `'${v.toLowerCase()}'`).join(", ")}`,
|
|
2362
|
+
functionLayer: "LavalinkNode > setSponsorBlock()"
|
|
2363
|
+
});
|
|
2362
2364
|
return;
|
|
2363
2365
|
}
|
|
2364
2366
|
/**
|
|
@@ -2373,18 +2375,16 @@ var LavalinkNode = class {
|
|
|
2373
2375
|
* ```
|
|
2374
2376
|
*/
|
|
2375
2377
|
async deleteSponsorBlock(player) {
|
|
2376
|
-
if (!this.info
|
|
2378
|
+
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}`);
|
|
2377
2379
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
|
|
2378
2380
|
r.method = "DELETE";
|
|
2379
2381
|
});
|
|
2380
2382
|
player.set("internal_sponsorBlockCategories", []);
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
});
|
|
2387
|
-
}
|
|
2383
|
+
this._emitDebugEvent("DeleteSponsorBlock" /* DeleteSponsorBlock */, {
|
|
2384
|
+
state: "log",
|
|
2385
|
+
message: `SponsorBlock was deleted for Player: ${player.guildId}`,
|
|
2386
|
+
functionLayer: "LavalinkNode > deleteSponsorBlock()"
|
|
2387
|
+
});
|
|
2388
2388
|
return;
|
|
2389
2389
|
}
|
|
2390
2390
|
/** private util function for handling the queue end event */
|
|
@@ -2393,46 +2393,38 @@ var LavalinkNode = class {
|
|
|
2393
2393
|
player.queue.current = null;
|
|
2394
2394
|
player.playing = false;
|
|
2395
2395
|
player.set("internal_stopPlaying", void 0);
|
|
2396
|
-
|
|
2397
|
-
|
|
2396
|
+
this._emitDebugEvent("QueueEnded" /* QueueEnded */, {
|
|
2397
|
+
state: "log",
|
|
2398
|
+
message: `Queue Ended because no more Tracks were in the Queue, due to EventName: "${payload.type}"`,
|
|
2399
|
+
functionLayer: "LavalinkNode > queueEnd()"
|
|
2400
|
+
});
|
|
2401
|
+
if (typeof this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
|
|
2402
|
+
this._emitDebugEvent("AutoplayExecution" /* AutoplayExecution */, {
|
|
2398
2403
|
state: "log",
|
|
2399
|
-
message: `
|
|
2400
|
-
functionLayer: "LavalinkNode > queueEnd()"
|
|
2404
|
+
message: `Now Triggering Autoplay.`,
|
|
2405
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2401
2406
|
});
|
|
2402
|
-
}
|
|
2403
|
-
if (typeof this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
|
|
2404
|
-
if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
2405
|
-
this.NodeManager.LavalinkManager.emit("debug", "AutoplayExecution" /* AutoplayExecution */, {
|
|
2406
|
-
state: "log",
|
|
2407
|
-
message: `Now Triggering Autoplay.`,
|
|
2408
|
-
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2409
|
-
});
|
|
2410
|
-
}
|
|
2411
2407
|
const previousAutoplayTime = player.get("internal_previousautoplay");
|
|
2412
2408
|
const duration = previousAutoplayTime ? Date.now() - previousAutoplayTime : 0;
|
|
2413
|
-
if (!duration || duration > this.
|
|
2414
|
-
await this.
|
|
2409
|
+
if (!duration || duration > this._LManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
|
|
2410
|
+
await this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
|
|
2415
2411
|
player.set("internal_previousautoplay", Date.now());
|
|
2416
2412
|
if (player.queue.tracks.length > 0) await queueTrackEnd(player);
|
|
2417
|
-
else
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
if (
|
|
2425
|
-
|
|
2426
|
-
if (this.NodeManager.LavalinkManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
|
|
2427
|
-
}
|
|
2413
|
+
else this._emitDebugEvent("AutoplayNoSongsAdded" /* AutoplayNoSongsAdded */, {
|
|
2414
|
+
state: "warn",
|
|
2415
|
+
message: `Autoplay was triggered but no songs were added to the queue.`,
|
|
2416
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
if (player.queue.current) {
|
|
2420
|
+
if (payload.type === "TrackEndEvent") this._LManager.emit("trackEnd", player, track, payload);
|
|
2421
|
+
if (this._LManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
|
|
2428
2422
|
} else {
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
});
|
|
2435
|
-
}
|
|
2423
|
+
this._emitDebugEvent("AutoplayThresholdSpamLimiter" /* AutoplayThresholdSpamLimiter */, {
|
|
2424
|
+
state: "warn",
|
|
2425
|
+
message: `Autoplay was triggered after the previousautoplay too early. Threshold is: ${this._LManager.options.playerOptions.minAutoPlayMs}ms and the Duration was ${duration}ms`,
|
|
2426
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2427
|
+
});
|
|
2436
2428
|
}
|
|
2437
2429
|
}
|
|
2438
2430
|
player.set("internal_skipped", false);
|
|
@@ -2445,31 +2437,29 @@ var LavalinkNode = class {
|
|
|
2445
2437
|
if (payload?.reason !== "stopped") {
|
|
2446
2438
|
await player.queue.utils.save();
|
|
2447
2439
|
}
|
|
2448
|
-
if (typeof this.
|
|
2449
|
-
if (this.
|
|
2440
|
+
if (typeof this._LManager.options.playerOptions?.onEmptyQueue?.destroyAfterMs === "number" && !isNaN(this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs) && this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs >= 0) {
|
|
2441
|
+
if (this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs === 0) {
|
|
2450
2442
|
player.destroy("QueueEmpty" /* QueueEmpty */);
|
|
2451
2443
|
return;
|
|
2452
2444
|
} else {
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
}
|
|
2460
|
-
this.NodeManager.LavalinkManager.emit("playerQueueEmptyStart", player, this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
|
|
2445
|
+
this._emitDebugEvent("TriggerQueueEmptyInterval" /* TriggerQueueEmptyInterval */, {
|
|
2446
|
+
state: "log",
|
|
2447
|
+
message: `Trigger Queue Empty Interval was Triggered because playerOptions.onEmptyQueue.destroyAfterMs is set to ${this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs}ms`,
|
|
2448
|
+
functionLayer: "LavalinkNode > queueEnd() > destroyAfterMs"
|
|
2449
|
+
});
|
|
2450
|
+
this._LManager.emit("playerQueueEmptyStart", player, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
|
|
2461
2451
|
if (player.get("internal_queueempty")) clearTimeout(player.get("internal_queueempty"));
|
|
2462
2452
|
player.set("internal_queueempty", setTimeout(() => {
|
|
2463
2453
|
player.set("internal_queueempty", void 0);
|
|
2464
2454
|
if (player.queue.current) {
|
|
2465
|
-
return this.
|
|
2455
|
+
return this._LManager.emit("playerQueueEmptyCancel", player);
|
|
2466
2456
|
}
|
|
2467
|
-
this.
|
|
2457
|
+
this._LManager.emit("playerQueueEmptyEnd", player);
|
|
2468
2458
|
player.destroy("QueueEmpty" /* QueueEmpty */);
|
|
2469
|
-
}, this.
|
|
2459
|
+
}, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs));
|
|
2470
2460
|
}
|
|
2471
2461
|
}
|
|
2472
|
-
this.
|
|
2462
|
+
this._LManager.emit("queueEnd", player, track, payload);
|
|
2473
2463
|
return;
|
|
2474
2464
|
}
|
|
2475
2465
|
/**
|
|
@@ -2485,16 +2475,14 @@ var LavalinkNode = class {
|
|
|
2485
2475
|
if (player.queue.current) {
|
|
2486
2476
|
await player.queue.utils.save();
|
|
2487
2477
|
} else {
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
});
|
|
2494
|
-
}
|
|
2478
|
+
this._emitDebugEvent("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
|
+
});
|
|
2495
2483
|
}
|
|
2496
2484
|
}
|
|
2497
|
-
this.
|
|
2485
|
+
this._LManager.emit("LyricsLine", player, track, payload);
|
|
2498
2486
|
return;
|
|
2499
2487
|
}
|
|
2500
2488
|
/**
|
|
@@ -2510,16 +2498,14 @@ var LavalinkNode = class {
|
|
|
2510
2498
|
if (player.queue.current) {
|
|
2511
2499
|
await player.queue.utils.save();
|
|
2512
2500
|
} else {
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
});
|
|
2519
|
-
}
|
|
2501
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2502
|
+
state: "warn",
|
|
2503
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2504
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2505
|
+
});
|
|
2520
2506
|
}
|
|
2521
2507
|
}
|
|
2522
|
-
this.
|
|
2508
|
+
this._LManager.emit("LyricsFound", player, track, payload);
|
|
2523
2509
|
return;
|
|
2524
2510
|
}
|
|
2525
2511
|
/**
|
|
@@ -2535,16 +2521,14 @@ var LavalinkNode = class {
|
|
|
2535
2521
|
if (player.queue.current) {
|
|
2536
2522
|
await player.queue.utils.save();
|
|
2537
2523
|
} else {
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
});
|
|
2544
|
-
}
|
|
2524
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2525
|
+
state: "warn",
|
|
2526
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2527
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2528
|
+
});
|
|
2545
2529
|
}
|
|
2546
2530
|
}
|
|
2547
|
-
this.
|
|
2531
|
+
this._LManager.emit("LyricsNotFound", player, track, payload);
|
|
2548
2532
|
return;
|
|
2549
2533
|
}
|
|
2550
2534
|
};
|
|
@@ -2906,6 +2890,21 @@ var FilterManager = class {
|
|
|
2906
2890
|
data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2907
2891
|
/** The Player assigned to this Filter Manager */
|
|
2908
2892
|
player;
|
|
2893
|
+
get _LManager() {
|
|
2894
|
+
return this.player.LavalinkManager;
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Returns wether the plugin validations are enabled or not
|
|
2898
|
+
*/
|
|
2899
|
+
get _checkForPlugins() {
|
|
2900
|
+
return !!this._LManager.options?.autoChecks?.pluginValidations;
|
|
2901
|
+
}
|
|
2902
|
+
/**
|
|
2903
|
+
* Returns wether the source validations are enabled or not
|
|
2904
|
+
*/
|
|
2905
|
+
get _checkForSources() {
|
|
2906
|
+
return !!this._LManager.options?.autoChecks?.sourcesValidations;
|
|
2907
|
+
}
|
|
2909
2908
|
/** The Constructor for the FilterManager */
|
|
2910
2909
|
constructor(player) {
|
|
2911
2910
|
this.player = player;
|
|
@@ -2942,13 +2941,13 @@ var FilterManager = class {
|
|
|
2942
2941
|
if (!this.filters.karaoke) delete sendData.karaoke;
|
|
2943
2942
|
if (!this.filters.rotation) delete sendData.rotation;
|
|
2944
2943
|
if (this.filters.audioOutput === "stereo") delete sendData.channelMix;
|
|
2945
|
-
if (Object.values(this.data.timescale).every((v) => v === 1)) delete sendData.timescale;
|
|
2944
|
+
if (Object.values(this.data.timescale ?? {}).every((v) => v === 1)) delete sendData.timescale;
|
|
2946
2945
|
if (!this.player.node.sessionId) throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
2947
2946
|
sendData.equalizer = [...this.equalizerBands];
|
|
2948
2947
|
if (sendData.equalizer.length === 0) delete sendData.equalizer;
|
|
2949
2948
|
for (const key of Object.keys(sendData)) {
|
|
2950
2949
|
if (key === "pluginFilters") {
|
|
2951
|
-
} else if (this.
|
|
2950
|
+
} else if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.(key)) delete sendData[key];
|
|
2952
2951
|
}
|
|
2953
2952
|
const now = performance.now();
|
|
2954
2953
|
if (this.player.options.instaUpdateFiltersFix === true) this.filterUpdatedState = true;
|
|
@@ -3088,7 +3087,7 @@ var FilterManager = class {
|
|
|
3088
3087
|
* ```
|
|
3089
3088
|
*/
|
|
3090
3089
|
async setAudioOutput(type) {
|
|
3091
|
-
if (this.
|
|
3090
|
+
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)");
|
|
3092
3091
|
if (!type || !audioOutputsData[type]) throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
3093
3092
|
this.data = this.data ?? {};
|
|
3094
3093
|
this.data.channelMix = audioOutputsData[type];
|
|
@@ -3108,7 +3107,7 @@ var FilterManager = class {
|
|
|
3108
3107
|
* ```
|
|
3109
3108
|
*/
|
|
3110
3109
|
async setSpeed(speed = 1) {
|
|
3111
|
-
if (this.
|
|
3110
|
+
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)");
|
|
3112
3111
|
this.data = this.data ?? {};
|
|
3113
3112
|
this.filters.nightcore = false;
|
|
3114
3113
|
this.filters.vaporwave = false;
|
|
@@ -3129,7 +3128,7 @@ var FilterManager = class {
|
|
|
3129
3128
|
* ```
|
|
3130
3129
|
*/
|
|
3131
3130
|
async setPitch(pitch = 1) {
|
|
3132
|
-
if (this.
|
|
3131
|
+
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)");
|
|
3133
3132
|
this.data = this.data ?? {};
|
|
3134
3133
|
this.filters.nightcore = false;
|
|
3135
3134
|
this.filters.vaporwave = false;
|
|
@@ -3150,7 +3149,7 @@ var FilterManager = class {
|
|
|
3150
3149
|
* ```
|
|
3151
3150
|
*/
|
|
3152
3151
|
async setRate(rate = 1) {
|
|
3153
|
-
if (this.
|
|
3152
|
+
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)");
|
|
3154
3153
|
this.data = this.data ?? {};
|
|
3155
3154
|
this.filters.nightcore = false;
|
|
3156
3155
|
this.filters.vaporwave = false;
|
|
@@ -3174,7 +3173,7 @@ var FilterManager = class {
|
|
|
3174
3173
|
* ```
|
|
3175
3174
|
*/
|
|
3176
3175
|
async toggleRotation(rotationHz = 0.2) {
|
|
3177
|
-
if (this.
|
|
3176
|
+
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)");
|
|
3178
3177
|
this.data = this.data ?? {};
|
|
3179
3178
|
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3180
3179
|
this.filters.rotation = !this.filters.rotation;
|
|
@@ -3197,7 +3196,7 @@ var FilterManager = class {
|
|
|
3197
3196
|
* ```
|
|
3198
3197
|
*/
|
|
3199
3198
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3200
|
-
if (this.
|
|
3199
|
+
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)");
|
|
3201
3200
|
this.data = this.data ?? {};
|
|
3202
3201
|
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3203
3202
|
this.filters.vibrato = !this.filters.vibrato;
|
|
@@ -3220,7 +3219,7 @@ var FilterManager = class {
|
|
|
3220
3219
|
* ```
|
|
3221
3220
|
*/
|
|
3222
3221
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3223
|
-
if (this.
|
|
3222
|
+
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)");
|
|
3224
3223
|
this.data = this.data ?? {};
|
|
3225
3224
|
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3226
3225
|
this.filters.tremolo = !this.filters.tremolo;
|
|
@@ -3242,7 +3241,7 @@ var FilterManager = class {
|
|
|
3242
3241
|
* ```
|
|
3243
3242
|
*/
|
|
3244
3243
|
async toggleLowPass(smoothing = 20) {
|
|
3245
|
-
if (this.
|
|
3244
|
+
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)");
|
|
3246
3245
|
this.data = this.data ?? {};
|
|
3247
3246
|
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3248
3247
|
this.filters.lowPass = !this.filters.lowPass;
|
|
@@ -3269,8 +3268,8 @@ var FilterManager = class {
|
|
|
3269
3268
|
* ```
|
|
3270
3269
|
*/
|
|
3271
3270
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3272
|
-
if (this.
|
|
3273
|
-
if (this.
|
|
3271
|
+
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");
|
|
3272
|
+
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)");
|
|
3274
3273
|
this.data = this.data ?? {};
|
|
3275
3274
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3276
3275
|
if (this.filters.lavalinkLavaDspxPlugin.lowPass) delete this.data.pluginFilters["low-pass"];
|
|
@@ -3295,8 +3294,8 @@ var FilterManager = class {
|
|
|
3295
3294
|
* ```
|
|
3296
3295
|
*/
|
|
3297
3296
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3298
|
-
if (this.
|
|
3299
|
-
if (this.
|
|
3297
|
+
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");
|
|
3298
|
+
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)");
|
|
3300
3299
|
this.data = this.data ?? {};
|
|
3301
3300
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3302
3301
|
if (this.filters.lavalinkLavaDspxPlugin.highPass) delete this.data.pluginFilters["high-pass"];
|
|
@@ -3321,8 +3320,8 @@ var FilterManager = class {
|
|
|
3321
3320
|
* ```
|
|
3322
3321
|
*/
|
|
3323
3322
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3324
|
-
if (this.
|
|
3325
|
-
if (this.
|
|
3323
|
+
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");
|
|
3324
|
+
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)");
|
|
3326
3325
|
this.data = this.data ?? {};
|
|
3327
3326
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3328
3327
|
if (this.filters.lavalinkLavaDspxPlugin.normalization) delete this.data.pluginFilters.normalization;
|
|
@@ -3347,8 +3346,8 @@ var FilterManager = class {
|
|
|
3347
3346
|
* ```
|
|
3348
3347
|
*/
|
|
3349
3348
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3350
|
-
if (this.
|
|
3351
|
-
if (this.
|
|
3349
|
+
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");
|
|
3350
|
+
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)");
|
|
3352
3351
|
this.data = this.data ?? {};
|
|
3353
3352
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3354
3353
|
if (this.filters.lavalinkLavaDspxPlugin.echo) delete this.data.pluginFilters.echo;
|
|
@@ -3378,8 +3377,8 @@ var FilterManager = class {
|
|
|
3378
3377
|
* ```
|
|
3379
3378
|
*/
|
|
3380
3379
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3381
|
-
if (this.
|
|
3382
|
-
if (this.
|
|
3380
|
+
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");
|
|
3381
|
+
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!)");
|
|
3383
3382
|
this.data = this.data ?? {};
|
|
3384
3383
|
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3385
3384
|
this.data.pluginFilters = {
|
|
@@ -3409,8 +3408,8 @@ var FilterManager = class {
|
|
|
3409
3408
|
* ```
|
|
3410
3409
|
*/
|
|
3411
3410
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3412
|
-
if (this.
|
|
3413
|
-
if (this.
|
|
3411
|
+
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");
|
|
3412
|
+
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!)");
|
|
3414
3413
|
this.data = this.data ?? {};
|
|
3415
3414
|
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3416
3415
|
this.data.pluginFilters = {
|
|
@@ -3442,7 +3441,7 @@ var FilterManager = class {
|
|
|
3442
3441
|
* ```
|
|
3443
3442
|
*/
|
|
3444
3443
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3445
|
-
if (this.
|
|
3444
|
+
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)");
|
|
3446
3445
|
this.data = this.data ?? {};
|
|
3447
3446
|
this.data.timescale = this.filters.nightcore ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3448
3447
|
this.filters.nightcore = !this.filters.nightcore;
|
|
@@ -3468,7 +3467,7 @@ var FilterManager = class {
|
|
|
3468
3467
|
* ```
|
|
3469
3468
|
*/
|
|
3470
3469
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3471
|
-
if (this.
|
|
3470
|
+
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)");
|
|
3472
3471
|
this.data = this.data ?? {};
|
|
3473
3472
|
this.data.timescale = this.filters.vaporwave ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3474
3473
|
this.filters.vaporwave = !this.filters.vaporwave;
|
|
@@ -3495,7 +3494,7 @@ var FilterManager = class {
|
|
|
3495
3494
|
* ```
|
|
3496
3495
|
*/
|
|
3497
3496
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3498
|
-
if (this.
|
|
3497
|
+
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)");
|
|
3499
3498
|
this.data = this.data ?? {};
|
|
3500
3499
|
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3501
3500
|
this.filters.karaoke = !this.filters.karaoke;
|
|
@@ -4012,6 +4011,15 @@ var Player = class {
|
|
|
4012
4011
|
};
|
|
4013
4012
|
/** Custom data for the player */
|
|
4014
4013
|
data = {};
|
|
4014
|
+
/**
|
|
4015
|
+
* Emits a debug event to the LavalinkManager
|
|
4016
|
+
* @param name name of the event
|
|
4017
|
+
* @param eventData event data
|
|
4018
|
+
*/
|
|
4019
|
+
_emitDebugEvent(name, eventData) {
|
|
4020
|
+
if (!this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) return;
|
|
4021
|
+
this.LavalinkManager.emit("debug", name, eventData);
|
|
4022
|
+
}
|
|
4015
4023
|
/**
|
|
4016
4024
|
* Create a new Player
|
|
4017
4025
|
* @param options
|
|
@@ -4027,8 +4035,8 @@ var Player = class {
|
|
|
4027
4035
|
this.textChannelId = this.options.textChannelId || null;
|
|
4028
4036
|
this.node = typeof this.options.node === "string" ? this.LavalinkManager.nodeManager.nodes.get(this.options.node) : this.options.node;
|
|
4029
4037
|
if (!this.node || typeof this.node.request !== "function") {
|
|
4030
|
-
if (typeof this.options.node === "string"
|
|
4031
|
-
this.
|
|
4038
|
+
if (typeof this.options.node === "string") {
|
|
4039
|
+
this._emitDebugEvent("PlayerCreateNodeNotFound" /* PlayerCreateNodeNotFound */, {
|
|
4032
4040
|
state: "warn",
|
|
4033
4041
|
message: `Player was created with provided node Id: ${this.options.node}, but no node with that Id was found.`,
|
|
4034
4042
|
functionLayer: "Player > constructor()"
|
|
@@ -4085,13 +4093,11 @@ var Player = class {
|
|
|
4085
4093
|
*/
|
|
4086
4094
|
async play(options = {}) {
|
|
4087
4095
|
if (this.get("internal_queueempty")) {
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
});
|
|
4094
|
-
}
|
|
4096
|
+
this._emitDebugEvent("PlayerPlayQueueEmptyTimeoutClear" /* PlayerPlayQueueEmptyTimeoutClear */, {
|
|
4097
|
+
state: "log",
|
|
4098
|
+
message: `Player was called to play something, while there was a queueEmpty Timeout set, clearing the timeout.`,
|
|
4099
|
+
functionLayer: "Player > play()"
|
|
4100
|
+
});
|
|
4095
4101
|
this.LavalinkManager.emit("playerQueueEmptyCancel", this);
|
|
4096
4102
|
clearTimeout(this.get("internal_queueempty"));
|
|
4097
4103
|
this.set("internal_queueempty", void 0);
|
|
@@ -4101,14 +4107,12 @@ var Player = class {
|
|
|
4101
4107
|
try {
|
|
4102
4108
|
await options.clientTrack.resolve(this);
|
|
4103
4109
|
} catch (error) {
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
});
|
|
4111
|
-
}
|
|
4110
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
|
|
4111
|
+
state: "error",
|
|
4112
|
+
error,
|
|
4113
|
+
message: `Player Play was called with clientTrack, Song is unresolved, but couldn't resolve it`,
|
|
4114
|
+
functionLayer: "Player > play() > resolve currentTrack"
|
|
4115
|
+
});
|
|
4112
4116
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
4113
4117
|
if (options && "clientTrack" in options) delete options.clientTrack;
|
|
4114
4118
|
if (options && "track" in options) delete options.track;
|
|
@@ -4145,13 +4149,11 @@ var Player = class {
|
|
|
4145
4149
|
...options.track.userData
|
|
4146
4150
|
}
|
|
4147
4151
|
}).filter((v) => typeof v[1] !== "undefined"));
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
});
|
|
4154
|
-
}
|
|
4152
|
+
this._emitDebugEvent("PlayerPlayWithTrackReplace" /* PlayerPlayWithTrackReplace */, {
|
|
4153
|
+
state: "log",
|
|
4154
|
+
message: `Player was called to play something, with a specific track provided. Replacing the current Track and resolving the track on trackStart Event.`,
|
|
4155
|
+
functionLayer: "Player > play()"
|
|
4156
|
+
});
|
|
4155
4157
|
return this.node.updatePlayer({
|
|
4156
4158
|
guildId: this.guildId,
|
|
4157
4159
|
noReplace: false,
|
|
@@ -4168,13 +4170,11 @@ var Player = class {
|
|
|
4168
4170
|
}
|
|
4169
4171
|
if (!this.queue.current && this.queue.tracks.length) await queueTrackEnd(this);
|
|
4170
4172
|
if (this.queue.current && this.LavalinkManager.utils.isUnresolvedTrack(this.queue.current)) {
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
});
|
|
4177
|
-
}
|
|
4173
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrack" /* PlayerPlayUnresolvedTrack */, {
|
|
4174
|
+
state: "log",
|
|
4175
|
+
message: `Player Play was called, current Queue Song is unresolved, resolving the track.`,
|
|
4176
|
+
functionLayer: "Player > play()"
|
|
4177
|
+
});
|
|
4178
4178
|
try {
|
|
4179
4179
|
await this.queue.current.resolve(this);
|
|
4180
4180
|
if (typeof options.track?.userData === "object" && this.queue.current) this.queue.current.userData = {
|
|
@@ -4183,14 +4183,12 @@ var Player = class {
|
|
|
4183
4183
|
...options.track?.userData
|
|
4184
4184
|
};
|
|
4185
4185
|
} catch (error) {
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
});
|
|
4193
|
-
}
|
|
4186
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
|
|
4187
|
+
state: "error",
|
|
4188
|
+
error,
|
|
4189
|
+
message: `Player Play was called, current Queue Song is unresolved, but couldn't resolve it`,
|
|
4190
|
+
functionLayer: "Player > play() > resolve currentTrack"
|
|
4191
|
+
});
|
|
4194
4192
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
4195
4193
|
if (options && "clientTrack" in options) delete options.clientTrack;
|
|
4196
4194
|
if (options && "track" in options) delete options.track;
|
|
@@ -4251,13 +4249,11 @@ var Player = class {
|
|
|
4251
4249
|
), 1e3), 0));
|
|
4252
4250
|
const now = performance.now();
|
|
4253
4251
|
if (this.LavalinkManager.options.playerOptions.applyVolumeAsFilter) {
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
});
|
|
4260
|
-
}
|
|
4252
|
+
this._emitDebugEvent("PlayerVolumeAsFilter" /* PlayerVolumeAsFilter */, {
|
|
4253
|
+
state: "log",
|
|
4254
|
+
message: `Player Volume was set as a Filter, because LavalinkManager option "playerOptions.applyVolumeAsFilter" is true`,
|
|
4255
|
+
functionLayer: "Player > setVolume()"
|
|
4256
|
+
});
|
|
4261
4257
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume: this.lavalinkVolume / 100 } } });
|
|
4262
4258
|
} else {
|
|
4263
4259
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume: this.lavalinkVolume } });
|
|
@@ -4302,13 +4298,11 @@ var Player = class {
|
|
|
4302
4298
|
async search(query, requestUser, throwOnEmpty = false) {
|
|
4303
4299
|
const Query = this.LavalinkManager.utils.transformQuery(query);
|
|
4304
4300
|
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info?.sourceManagers.includes("bandcamp")) {
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
});
|
|
4311
|
-
}
|
|
4301
|
+
this._emitDebugEvent("BandcampSearchLokalEngine" /* BandcampSearchLokalEngine */, {
|
|
4302
|
+
state: "log",
|
|
4303
|
+
message: `Player.search was called with a Bandcamp Query, but no bandcamp search was enabled on lavalink, searching with the custom Search Engine.`,
|
|
4304
|
+
functionLayer: "Player > search()"
|
|
4305
|
+
});
|
|
4312
4306
|
return await bandCampSearch(this, Query.query, requestUser);
|
|
4313
4307
|
}
|
|
4314
4308
|
return this.node.search(Query, requestUser, throwOnEmpty);
|
|
@@ -4460,13 +4454,11 @@ var Player = class {
|
|
|
4460
4454
|
this.set("internal_queueempty", void 0);
|
|
4461
4455
|
}
|
|
4462
4456
|
if (this.get("internal_destroystatus") === true) {
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
});
|
|
4469
|
-
}
|
|
4457
|
+
this._emitDebugEvent("PlayerDestroyingSomewhereElse" /* PlayerDestroyingSomewhereElse */, {
|
|
4458
|
+
state: "warn",
|
|
4459
|
+
message: `Player is already destroying somewhere else..`,
|
|
4460
|
+
functionLayer: "Player > destroy()"
|
|
4461
|
+
});
|
|
4470
4462
|
if (this.LavalinkManager.options.advancedOptions?.debugOptions.playerDestroy.debugLog) console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Already destroying somewhere else..`);
|
|
4471
4463
|
return;
|
|
4472
4464
|
}
|
|
@@ -4559,17 +4551,15 @@ var Player = class {
|
|
|
4559
4551
|
const missingSources = [...trackSources].filter(
|
|
4560
4552
|
(source) => !updateNode.info?.sourceManagers.includes(source)
|
|
4561
4553
|
);
|
|
4562
|
-
if (missingSources.length)
|
|
4554
|
+
if (this.LavalinkManager.options.autoChecks?.sourcesValidations && missingSources.length)
|
|
4563
4555
|
throw new RangeError(`Sources missing for Node ${updateNode.id}: ${missingSources.join(", ")}`);
|
|
4564
4556
|
}
|
|
4565
4557
|
}
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
});
|
|
4572
|
-
}
|
|
4558
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4559
|
+
state: "log",
|
|
4560
|
+
message: `Player.changeNode() was executed, trying to change from "${this.node.id}" to "${updateNode.id}"`,
|
|
4561
|
+
functionLayer: "Player > changeNode()"
|
|
4562
|
+
});
|
|
4573
4563
|
const data = this.toJSON();
|
|
4574
4564
|
const currentTrack = this.queue.current;
|
|
4575
4565
|
if (!this.voice.endpoint || !this.voice.sessionId || !this.voice.token)
|
|
@@ -4580,30 +4570,26 @@ var Player = class {
|
|
|
4580
4570
|
const now = performance.now();
|
|
4581
4571
|
try {
|
|
4582
4572
|
await this.connect();
|
|
4583
|
-
const hasSponsorBlock = this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
|
|
4573
|
+
const hasSponsorBlock = !this.LavalinkManager.options?.autoChecks?.pluginValidations || this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
|
|
4584
4574
|
if (hasSponsorBlock) {
|
|
4585
4575
|
const sponsorBlockCategories = this.get("internal_sponsorBlockCategories");
|
|
4586
4576
|
if (Array.isArray(sponsorBlockCategories) && sponsorBlockCategories.length) {
|
|
4587
4577
|
await this.setSponsorBlock(sponsorBlockCategories).catch((error) => {
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
});
|
|
4595
|
-
}
|
|
4578
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4579
|
+
state: "error",
|
|
4580
|
+
error,
|
|
4581
|
+
message: `Player > changeNode() Unable to set SponsorBlock Segments`,
|
|
4582
|
+
functionLayer: "Player > changeNode()"
|
|
4583
|
+
});
|
|
4596
4584
|
});
|
|
4597
4585
|
} else {
|
|
4598
4586
|
await this.setSponsorBlock().catch((error) => {
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
});
|
|
4606
|
-
}
|
|
4587
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4588
|
+
state: "error",
|
|
4589
|
+
error,
|
|
4590
|
+
message: `Player > changeNode() Unable to set SponsorBlock Segments`,
|
|
4591
|
+
functionLayer: "Player > changeNode()"
|
|
4592
|
+
});
|
|
4607
4593
|
});
|
|
4608
4594
|
}
|
|
4609
4595
|
}
|
|
@@ -4628,14 +4614,12 @@ var Player = class {
|
|
|
4628
4614
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
4629
4615
|
return this.node.id;
|
|
4630
4616
|
} catch (error) {
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
});
|
|
4638
|
-
}
|
|
4617
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4618
|
+
state: "error",
|
|
4619
|
+
error,
|
|
4620
|
+
message: `Player.changeNode() execution failed`,
|
|
4621
|
+
functionLayer: "Player > changeNode()"
|
|
4622
|
+
});
|
|
4639
4623
|
throw new Error(`Failed to change the node: ${error}`);
|
|
4640
4624
|
} finally {
|
|
4641
4625
|
this.set("internal_nodeChanging", void 0);
|
|
@@ -4761,6 +4745,10 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4761
4745
|
id: options?.client?.id,
|
|
4762
4746
|
username: options?.client?.username ?? "lavalink-client"
|
|
4763
4747
|
},
|
|
4748
|
+
autoChecks: {
|
|
4749
|
+
sourcesValidations: options?.autoChecks?.sourcesValidations ?? true,
|
|
4750
|
+
pluginValidations: options?.autoChecks?.pluginValidations ?? true
|
|
4751
|
+
},
|
|
4764
4752
|
sendToShard: options?.sendToShard,
|
|
4765
4753
|
autoMove: options?.autoMove ?? false,
|
|
4766
4754
|
nodes: options?.nodes,
|
|
@@ -4824,6 +4812,8 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4824
4812
|
if (options?.autoSkipOnResolveError && typeof options?.autoSkipOnResolveError !== "boolean") throw new SyntaxError("ManagerOption.autoSkipOnResolveError must be either false | true aka boolean");
|
|
4825
4813
|
if (options?.emitNewSongsOnly && typeof options?.emitNewSongsOnly !== "boolean") throw new SyntaxError("ManagerOption.emitNewSongsOnly must be either false | true aka boolean");
|
|
4826
4814
|
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");
|
|
4815
|
+
if (typeof options?.autoChecks?.sourcesValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.sourcesValidations must be either false | true aka boolean");
|
|
4816
|
+
if (typeof options?.autoChecks?.pluginValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.pluginValidations must be either false | true aka boolean");
|
|
4827
4817
|
if (options?.queueOptions?.queueStore) {
|
|
4828
4818
|
const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(options?.queueOptions?.queueStore));
|
|
4829
4819
|
const requiredKeys = ["get", "set", "stringify", "parse", "delete"];
|
|
@@ -4836,6 +4826,15 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4836
4826
|
}
|
|
4837
4827
|
if (typeof options?.queueOptions?.maxPreviousTracks !== "number" || options?.queueOptions?.maxPreviousTracks < 0) options.queueOptions.maxPreviousTracks = 25;
|
|
4838
4828
|
}
|
|
4829
|
+
/**
|
|
4830
|
+
* Emits a debug event to the LavalinkManager
|
|
4831
|
+
* @param name name of the event
|
|
4832
|
+
* @param eventData event data
|
|
4833
|
+
*/
|
|
4834
|
+
_emitDebugEvent(name, eventData) {
|
|
4835
|
+
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
4836
|
+
this.emit("debug", name, eventData);
|
|
4837
|
+
}
|
|
4839
4838
|
/**
|
|
4840
4839
|
* Create the Lavalink Manager
|
|
4841
4840
|
* @param options
|
|
@@ -4985,13 +4984,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4985
4984
|
if (!oldPlayer) return;
|
|
4986
4985
|
if (typeof oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
4987
4986
|
if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError) throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${safeStringify(oldPlayer.toJSON?.())}`);
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
});
|
|
4994
|
-
}
|
|
4987
|
+
this._emitDebugEvent("PlayerDeleteInsteadOfDestroy" /* PlayerDeleteInsteadOfDestroy */, {
|
|
4988
|
+
state: "warn",
|
|
4989
|
+
message: "Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player",
|
|
4990
|
+
functionLayer: "LavalinkManager > deletePlayer()"
|
|
4991
|
+
});
|
|
4995
4992
|
}
|
|
4996
4993
|
return this.players.delete(guildId);
|
|
4997
4994
|
}
|
|
@@ -5039,13 +5036,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5039
5036
|
}
|
|
5040
5037
|
}
|
|
5041
5038
|
if (success > 0) this.initiated = true;
|
|
5042
|
-
else
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
});
|
|
5048
|
-
}
|
|
5039
|
+
else this._emitDebugEvent("FailedToConnectToNodes" /* FailedToConnectToNodes */, {
|
|
5040
|
+
state: "error",
|
|
5041
|
+
message: "Failed to connect to at least 1 Node",
|
|
5042
|
+
functionLayer: "LavalinkManager > init()"
|
|
5043
|
+
});
|
|
5049
5044
|
return this;
|
|
5050
5045
|
}
|
|
5051
5046
|
/**
|
|
@@ -5065,24 +5060,20 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5065
5060
|
*/
|
|
5066
5061
|
async sendRawData(data) {
|
|
5067
5062
|
if (!this.initiated) {
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
});
|
|
5074
|
-
}
|
|
5063
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5064
|
+
state: "log",
|
|
5065
|
+
message: "Manager is not initated yet",
|
|
5066
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5067
|
+
});
|
|
5075
5068
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet");
|
|
5076
5069
|
return;
|
|
5077
5070
|
}
|
|
5078
5071
|
if (!("t" in data)) {
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
});
|
|
5085
|
-
}
|
|
5072
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5073
|
+
state: "error",
|
|
5074
|
+
message: "No 't' in payload-data of the raw event:",
|
|
5075
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5076
|
+
});
|
|
5086
5077
|
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);
|
|
5087
5078
|
return;
|
|
5088
5079
|
}
|
|
@@ -5095,47 +5086,39 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5095
5086
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
5096
5087
|
const update = "d" in data ? data.d : data;
|
|
5097
5088
|
if (!update) {
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
});
|
|
5104
|
-
}
|
|
5089
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5090
|
+
state: "warn",
|
|
5091
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
5092
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5093
|
+
});
|
|
5105
5094
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no update data found in payload:", data);
|
|
5106
5095
|
return;
|
|
5107
5096
|
}
|
|
5108
5097
|
if (!("token" in update) && !("session_id" in update)) {
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
});
|
|
5115
|
-
}
|
|
5098
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5099
|
+
state: "error",
|
|
5100
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
5101
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5102
|
+
});
|
|
5116
5103
|
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);
|
|
5117
5104
|
return;
|
|
5118
5105
|
}
|
|
5119
5106
|
const player = this.getPlayer(update.guild_id);
|
|
5120
5107
|
if (!player) {
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
});
|
|
5127
|
-
}
|
|
5108
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5109
|
+
state: "warn",
|
|
5110
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
5111
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5112
|
+
});
|
|
5128
5113
|
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);
|
|
5129
5114
|
return;
|
|
5130
5115
|
}
|
|
5131
5116
|
if (player.get("internal_destroystatus") === true) {
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
});
|
|
5138
|
-
}
|
|
5117
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5118
|
+
state: "warn",
|
|
5119
|
+
message: `Player is in a destroying state. can't signal the voice states`,
|
|
5120
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5121
|
+
});
|
|
5139
5122
|
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");
|
|
5140
5123
|
return;
|
|
5141
5124
|
}
|
|
@@ -5160,13 +5143,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5160
5143
|
}
|
|
5161
5144
|
}
|
|
5162
5145
|
});
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
});
|
|
5169
|
-
}
|
|
5146
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5147
|
+
state: "log",
|
|
5148
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
5149
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5150
|
+
});
|
|
5170
5151
|
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 });
|
|
5171
5152
|
}
|
|
5172
5153
|
return;
|
|
@@ -5175,13 +5156,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5175
5156
|
if (update.user_id && player.voiceChannelId) {
|
|
5176
5157
|
this.emit(update.channel_id === player.voiceChannelId ? "playerVoiceJoin" : "playerVoiceLeave", player, update.user_id);
|
|
5177
5158
|
}
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
});
|
|
5184
|
-
}
|
|
5159
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5160
|
+
state: "warn",
|
|
5161
|
+
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}"`,
|
|
5162
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5163
|
+
});
|
|
5185
5164
|
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);
|
|
5186
5165
|
return;
|
|
5187
5166
|
}
|
|
@@ -5189,13 +5168,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5189
5168
|
if (player.voiceChannelId !== update.channel_id) this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
5190
5169
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
5191
5170
|
if (!player.voice.sessionId) {
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
});
|
|
5198
|
-
}
|
|
5171
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5172
|
+
state: "warn",
|
|
5173
|
+
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
5174
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5175
|
+
});
|
|
5199
5176
|
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)}`);
|
|
5200
5177
|
}
|
|
5201
5178
|
player.voiceChannelId = update.channel_id;
|
|
@@ -5226,13 +5203,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5226
5203
|
try {
|
|
5227
5204
|
const previousPosition = player.position;
|
|
5228
5205
|
const previousPaused = player.paused;
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
});
|
|
5235
|
-
}
|
|
5206
|
+
this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
|
|
5207
|
+
state: "log",
|
|
5208
|
+
message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
|
|
5209
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5210
|
+
});
|
|
5236
5211
|
if (!autoReconnectOnlyWithTracks || autoReconnectOnlyWithTracks && (player.queue.current || player.queue.tracks.length)) {
|
|
5237
5212
|
await player.connect();
|
|
5238
5213
|
}
|
|
@@ -5242,13 +5217,11 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5242
5217
|
if (player.queue.tracks.length) {
|
|
5243
5218
|
return void await player.play({ paused: previousPaused });
|
|
5244
5219
|
}
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
});
|
|
5251
|
-
}
|
|
5220
|
+
this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
|
|
5221
|
+
state: "log",
|
|
5222
|
+
message: `Auto reconnected, but nothing to play`,
|
|
5223
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5224
|
+
});
|
|
5252
5225
|
return;
|
|
5253
5226
|
} catch (e) {
|
|
5254
5227
|
console.error(e);
|