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.mjs
CHANGED
|
@@ -44,6 +44,9 @@ var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
|
|
|
44
44
|
DebugEvents2["FailedToConnectToNodes"] = "FailedToConnectToNodes";
|
|
45
45
|
DebugEvents2["NoAudioDebug"] = "NoAudioDebug";
|
|
46
46
|
DebugEvents2["PlayerAutoReconnect"] = "PlayerAutoReconnect";
|
|
47
|
+
DebugEvents2["PlayerDestroyFail"] = "PlayerDestroyFail";
|
|
48
|
+
DebugEvents2["PlayerChangeNodeFailNoEligibleNode"] = "PlayerChangeNodeFailNoEligibleNode";
|
|
49
|
+
DebugEvents2["PlayerChangeNodeFail"] = "PlayerChangeNodeFail";
|
|
47
50
|
return DebugEvents2;
|
|
48
51
|
})(DebugEvents || {});
|
|
49
52
|
var DestroyReasons = /* @__PURE__ */ ((DestroyReasons2) => {
|
|
@@ -687,7 +690,7 @@ var ManagerUtils = class {
|
|
|
687
690
|
}
|
|
688
691
|
validateQueryString(node, queryString, sourceString) {
|
|
689
692
|
if (!node.info) throw new Error("No Lavalink Node was provided");
|
|
690
|
-
if (!node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
|
|
693
|
+
if (this.LavalinkManager.options?.autoChecks?.sourcesValidations && !node.info.sourceManagers?.length) throw new Error("Lavalink Node, has no sourceManagers enabled");
|
|
691
694
|
if (!queryString.trim().length) throw new Error(`Query string is empty, please provide a valid query string.`);
|
|
692
695
|
if (sourceString === "speak" && queryString.length > 100) throw new Error(`Query is speak, which is limited to 100 characters.`);
|
|
693
696
|
if (this.LavalinkManager.options?.linksBlacklist?.length > 0) {
|
|
@@ -716,6 +719,7 @@ var ManagerUtils = class {
|
|
|
716
719
|
throw new Error(`Query string contains a link / word which isn't whitelisted.`);
|
|
717
720
|
}
|
|
718
721
|
}
|
|
722
|
+
if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
|
|
719
723
|
if ((SourceLinksRegexes.YoutubeMusicRegex.test(queryString) || SourceLinksRegexes.YoutubeRegex.test(queryString)) && !node.info?.sourceManagers?.includes("youtube")) {
|
|
720
724
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'youtube' enabled");
|
|
721
725
|
}
|
|
@@ -799,6 +803,7 @@ var ManagerUtils = class {
|
|
|
799
803
|
const source = DefaultSources[sourceString.toLowerCase().trim()];
|
|
800
804
|
if (!source) throw new Error(`Lavalink Node SearchQuerySource: '${sourceString}' is not available`);
|
|
801
805
|
if (!node.info) throw new Error("Lavalink Node does not have any info cached yet, not ready yet!");
|
|
806
|
+
if (!this.LavalinkManager.options?.autoChecks?.sourcesValidations) return;
|
|
802
807
|
if (source === "amsearch" && !node.info?.sourceManagers?.includes("applemusic")) {
|
|
803
808
|
throw new Error("Lavalink Node has not 'applemusic' enabled, which is required to have 'amsearch' work");
|
|
804
809
|
}
|
|
@@ -820,7 +825,7 @@ var ManagerUtils = class {
|
|
|
820
825
|
if (source === "scsearch" && !node.info?.sourceManagers?.includes("soundcloud")) {
|
|
821
826
|
throw new Error("Lavalink Node has not 'soundcloud' enabled, which is required to have 'scsearch' work");
|
|
822
827
|
}
|
|
823
|
-
if (source === "speak" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
|
|
828
|
+
if (source === "speak" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.DuncteBot_Plugin.toLowerCase()))) {
|
|
824
829
|
throw new Error("Lavalink Node has not 'speak' enabled, which is required to have 'speak' work");
|
|
825
830
|
}
|
|
826
831
|
if (source === "tdsearch" && !node.info?.sourceManagers?.includes("tidal")) {
|
|
@@ -829,7 +834,7 @@ var ManagerUtils = class {
|
|
|
829
834
|
if (source === "tdrec" && !node.info?.sourceManagers?.includes("tidal")) {
|
|
830
835
|
throw new Error("Lavalink Node has not 'tidal' enabled, which is required to have 'tdrec' work");
|
|
831
836
|
}
|
|
832
|
-
if (source === "tts" && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
|
|
837
|
+
if (source === "tts" && this.LavalinkManager.options?.autoChecks?.pluginValidations && !node.info?.plugins?.find((c) => c.name.toLowerCase().includes(LavalinkPlugins.GoogleCloudTTS.toLowerCase()))) {
|
|
833
838
|
throw new Error("Lavalink Node has not 'tts' enabled, which is required to have 'tts' work");
|
|
834
839
|
}
|
|
835
840
|
if (source === "ftts" && !(node.info?.sourceManagers?.includes("ftts") || node.info?.sourceManagers?.includes("flowery-tts") || node.info?.sourceManagers?.includes("flowerytts"))) {
|
|
@@ -838,7 +843,7 @@ var ManagerUtils = class {
|
|
|
838
843
|
if (source === "ymsearch" && !node.info?.sourceManagers?.includes("yandexmusic")) {
|
|
839
844
|
throw new Error("Lavalink Node has not 'yandexmusic' enabled, which is required to have 'ymsearch' work");
|
|
840
845
|
}
|
|
841
|
-
if (source === "ytmsearch" && !node.info
|
|
846
|
+
if (source === "ytmsearch" && !node.info?.sourceManagers?.includes("youtube")) {
|
|
842
847
|
throw new Error("Lavalink Node has not 'youtube' enabled, which is required to have 'ytmsearch' work");
|
|
843
848
|
}
|
|
844
849
|
if (source === "ytsearch" && !node.info?.sourceManagers?.includes("youtube")) {
|
|
@@ -981,9 +986,6 @@ function safeStringify(obj, padding = 0) {
|
|
|
981
986
|
var LavalinkNode = class {
|
|
982
987
|
heartBeatPingTimestamp = 0;
|
|
983
988
|
heartBeatPongTimestamp = 0;
|
|
984
|
-
get heartBeatPing() {
|
|
985
|
-
return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
|
|
986
|
-
}
|
|
987
989
|
heartBeatInterval;
|
|
988
990
|
pingTimeout;
|
|
989
991
|
isAlive = false;
|
|
@@ -1031,6 +1033,68 @@ var LavalinkNode = class {
|
|
|
1031
1033
|
socket = null;
|
|
1032
1034
|
/** Version of what the Lavalink Server should be */
|
|
1033
1035
|
version = "v4";
|
|
1036
|
+
/**
|
|
1037
|
+
* Returns the LavalinkManager of the Node
|
|
1038
|
+
*/
|
|
1039
|
+
get _LManager() {
|
|
1040
|
+
return this.NodeManager.LavalinkManager;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Returns the Heartbeat Ping of the Node
|
|
1044
|
+
*/
|
|
1045
|
+
get heartBeatPing() {
|
|
1046
|
+
return this.heartBeatPongTimestamp - this.heartBeatPingTimestamp;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Returns wether the plugin validations are enabled or not
|
|
1050
|
+
*/
|
|
1051
|
+
get _checkForPlugins() {
|
|
1052
|
+
return !!this._LManager.options?.autoChecks?.pluginValidations;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Returns wether the source validations are enabled or not
|
|
1056
|
+
*/
|
|
1057
|
+
get _checkForSources() {
|
|
1058
|
+
return !!this._LManager.options?.autoChecks?.sourcesValidations;
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Emits a debug event to the LavalinkManager
|
|
1062
|
+
* @param name name of the event
|
|
1063
|
+
* @param eventData event data
|
|
1064
|
+
*/
|
|
1065
|
+
_emitDebugEvent(name, eventData) {
|
|
1066
|
+
if (!this._LManager.options?.advancedOptions?.enableDebugEvents) return;
|
|
1067
|
+
this._LManager.emit("debug", name, eventData);
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Returns if connected to the Node.
|
|
1071
|
+
*
|
|
1072
|
+
* @example
|
|
1073
|
+
* ```ts
|
|
1074
|
+
* const isConnected = player.node.connected;
|
|
1075
|
+
* console.log("node is connected: ", isConnected ? "yes" : "no")
|
|
1076
|
+
* ```
|
|
1077
|
+
*/
|
|
1078
|
+
get connected() {
|
|
1079
|
+
return this.socket && this.socket.readyState === WebSocket.OPEN;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Returns the current ConnectionStatus
|
|
1083
|
+
*
|
|
1084
|
+
* @example
|
|
1085
|
+
* ```ts
|
|
1086
|
+
* try {
|
|
1087
|
+
* const statusOfConnection = player.node.connectionStatus;
|
|
1088
|
+
* console.log("node's connection status is:", statusOfConnection)
|
|
1089
|
+
* } catch (error) {
|
|
1090
|
+
* console.error("no socket available?", error)
|
|
1091
|
+
* }
|
|
1092
|
+
* ```
|
|
1093
|
+
*/
|
|
1094
|
+
get connectionStatus() {
|
|
1095
|
+
if (!this.socket) throw new Error("no websocket was initialized yet");
|
|
1096
|
+
return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
|
|
1097
|
+
}
|
|
1034
1098
|
/**
|
|
1035
1099
|
* Create a new Node
|
|
1036
1100
|
* @param options Lavalink Node Options
|
|
@@ -1120,10 +1184,10 @@ var LavalinkNode = class {
|
|
|
1120
1184
|
* ```
|
|
1121
1185
|
*/
|
|
1122
1186
|
async search(query, requestUser, throwOnEmpty = false) {
|
|
1123
|
-
const Query = this.
|
|
1124
|
-
this.
|
|
1125
|
-
if (Query.source) this.
|
|
1126
|
-
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.info.sourceManagers.includes("bandcamp")) {
|
|
1187
|
+
const Query = this._LManager.utils.transformQuery(query);
|
|
1188
|
+
this._LManager.utils.validateQueryString(this, Query.query, Query.source);
|
|
1189
|
+
if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
|
|
1190
|
+
if (["bcsearch", "bandcamp"].includes(Query.source) && this._LManager.options?.autoChecks?.sourcesValidations && !this.info.sourceManagers.includes("bandcamp")) {
|
|
1127
1191
|
throw new Error("Bandcamp Search only works on the player (lavaplayer version < 2.2.0!");
|
|
1128
1192
|
}
|
|
1129
1193
|
const requestUrl = new URL(`${this.restAddress}/loadtracks`);
|
|
@@ -1142,13 +1206,11 @@ var LavalinkNode = class {
|
|
|
1142
1206
|
});
|
|
1143
1207
|
const resTracks = res.loadType === "playlist" ? res.data?.tracks : res.loadType === "track" ? [res.data] : res.loadType === "search" ? Array.isArray(res.data) ? res.data : [res.data] : [];
|
|
1144
1208
|
if (throwOnEmpty === true && (res.loadType === "empty" || !resTracks.length)) {
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1209
|
+
this._emitDebugEvent("SearchNothingFound" /* SearchNothingFound */, {
|
|
1210
|
+
state: "warn",
|
|
1211
|
+
message: `Search found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
|
|
1212
|
+
functionLayer: "(LavalinkNode > node | player) > search()"
|
|
1213
|
+
});
|
|
1152
1214
|
throw new Error("Nothing found");
|
|
1153
1215
|
}
|
|
1154
1216
|
return {
|
|
@@ -1161,10 +1223,10 @@ var LavalinkNode = class {
|
|
|
1161
1223
|
author: res.data.info?.author || res.data.pluginInfo?.author || null,
|
|
1162
1224
|
thumbnail: res.data.info?.artworkUrl || res.data.pluginInfo?.artworkUrl || (typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? resTracks[res.data?.info?.selectedTrack]?.info?.artworkUrl || resTracks[res.data?.info?.selectedTrack]?.info?.pluginInfo?.artworkUrl : null) || null,
|
|
1163
1225
|
uri: res.data.info?.url || res.data.info?.uri || res.data.info?.link || res.data.pluginInfo?.url || res.data.pluginInfo?.uri || res.data.pluginInfo?.link || null,
|
|
1164
|
-
selectedTrack: typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? this.
|
|
1226
|
+
selectedTrack: typeof res.data?.info?.selectedTrack !== "number" || res.data?.info?.selectedTrack === -1 ? null : resTracks[res.data?.info?.selectedTrack] ? this._LManager.utils.buildTrack(resTracks[res.data?.info?.selectedTrack], requestUser) : null,
|
|
1165
1227
|
duration: resTracks.length ? resTracks.reduce((acc, cur) => acc + (cur?.info?.duration || cur?.info?.length || 0), 0) : 0
|
|
1166
1228
|
} : null,
|
|
1167
|
-
tracks: resTracks.length ? resTracks.map((t) => this.
|
|
1229
|
+
tracks: resTracks.length ? resTracks.map((t) => this._LManager.utils.buildTrack(t, requestUser)) : []
|
|
1168
1230
|
};
|
|
1169
1231
|
}
|
|
1170
1232
|
/**
|
|
@@ -1181,29 +1243,27 @@ var LavalinkNode = class {
|
|
|
1181
1243
|
* ```
|
|
1182
1244
|
*/
|
|
1183
1245
|
async lavaSearch(query, requestUser, throwOnEmpty = false) {
|
|
1184
|
-
const Query = this.
|
|
1185
|
-
if (Query.source) this.
|
|
1246
|
+
const Query = this._LManager.utils.transformLavaSearchQuery(query);
|
|
1247
|
+
if (Query.source) this._LManager.utils.validateSourceString(this, Query.source);
|
|
1186
1248
|
if (/^https?:\/\//.test(Query.query)) return this.search({ query: Query.query, source: Query.source }, requestUser);
|
|
1187
1249
|
if (!["spsearch", "sprec", "amsearch", "dzsearch", "dzisrc", "ytmsearch", "ytsearch"].includes(Query.source)) throw new SyntaxError(`Query.source must be a source from LavaSrc: "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ytmsearch" | "ytsearch"`);
|
|
1188
|
-
if (!this.info
|
|
1189
|
-
if (!this.info
|
|
1250
|
+
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}`);
|
|
1251
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin")) throw new RangeError(`there is no lavasrc-plugin available in the lavalink node: ${this.id}`);
|
|
1190
1252
|
const { response } = await this.rawRequest(`/loadsearch?query=${Query.source ? `${Query.source}:` : ""}${encodeURIComponent(Query.query)}${Query.types?.length ? `&types=${Query.types.join(",")}` : ""}`);
|
|
1191
1253
|
const res = response.status === 204 ? {} : await response.json();
|
|
1192
1254
|
if (throwOnEmpty === true && !Object.entries(res).flat().filter(Boolean).length) {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1255
|
+
this._emitDebugEvent("LavaSearchNothingFound" /* LavaSearchNothingFound */, {
|
|
1256
|
+
state: "warn",
|
|
1257
|
+
message: `LavaSearch found nothing for Request: "${Query.source ? `${Query.source}:` : ""}${Query.query}"`,
|
|
1258
|
+
functionLayer: "(LavalinkNode > node | player) > lavaSearch()"
|
|
1259
|
+
});
|
|
1200
1260
|
throw new Error("Nothing found");
|
|
1201
1261
|
}
|
|
1202
1262
|
return {
|
|
1203
|
-
tracks: res.tracks?.map((v) => this.
|
|
1204
|
-
albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1205
|
-
artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1206
|
-
playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this.
|
|
1263
|
+
tracks: res.tracks?.map((v) => this._LManager.utils.buildTrack(v, requestUser)) || [],
|
|
1264
|
+
albums: res.albums?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1265
|
+
artists: res.artists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1266
|
+
playlists: res.playlists?.map((v) => ({ info: v.info, pluginInfo: v?.plugin || v.pluginInfo, tracks: v.tracks.map((v2) => this._LManager.utils.buildTrack(v2, requestUser)) })) || [],
|
|
1207
1267
|
texts: res.texts?.map((v) => ({ text: v.text, pluginInfo: v?.plugin || v.pluginInfo })) || [],
|
|
1208
1268
|
pluginInfo: res.pluginInfo || res?.plugin
|
|
1209
1269
|
};
|
|
@@ -1232,13 +1292,11 @@ var LavalinkNode = class {
|
|
|
1232
1292
|
r.path = url.pathname + url.search;
|
|
1233
1293
|
}
|
|
1234
1294
|
});
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1295
|
+
this._emitDebugEvent("PlayerUpdateSuccess" /* PlayerUpdateSuccess */, {
|
|
1296
|
+
state: "log",
|
|
1297
|
+
message: `Player get's updated with following payload :: ${safeStringify(data.playerOptions, 3)}`,
|
|
1298
|
+
functionLayer: "LavalinkNode > node > updatePlayer()"
|
|
1299
|
+
});
|
|
1242
1300
|
this.syncPlayerData({}, res);
|
|
1243
1301
|
return res;
|
|
1244
1302
|
}
|
|
@@ -1274,19 +1332,17 @@ var LavalinkNode = class {
|
|
|
1274
1332
|
*/
|
|
1275
1333
|
connect(sessionId) {
|
|
1276
1334
|
if (this.connected) {
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1335
|
+
this._emitDebugEvent("TryingConnectWhileConnected" /* TryingConnectWhileConnected */, {
|
|
1336
|
+
state: "warn",
|
|
1337
|
+
message: `Tryed to connect to node, but it's already connected!`,
|
|
1338
|
+
functionLayer: "LavalinkNode > node > connect()"
|
|
1339
|
+
});
|
|
1284
1340
|
return;
|
|
1285
1341
|
}
|
|
1286
1342
|
const headers = {
|
|
1287
1343
|
Authorization: this.options.authorization,
|
|
1288
|
-
"User-Id": this.
|
|
1289
|
-
"Client-Name": this.
|
|
1344
|
+
"User-Id": this._LManager.options.client.id,
|
|
1345
|
+
"Client-Name": this._LManager.options.client.username || "Lavalink-Client"
|
|
1290
1346
|
};
|
|
1291
1347
|
if (typeof this.options.sessionId === "string" || typeof sessionId === "string") {
|
|
1292
1348
|
headers["Session-Id"] = this.options.sessionId || sessionId;
|
|
@@ -1299,34 +1355,27 @@ var LavalinkNode = class {
|
|
|
1299
1355
|
this.socket.on("error", this.error.bind(this));
|
|
1300
1356
|
}
|
|
1301
1357
|
heartBeat() {
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1358
|
+
this._emitDebugEvent("HeartBeatTriggered" /* HeartBeatTriggered */, {
|
|
1359
|
+
state: "log",
|
|
1360
|
+
message: `Node Socket Heartbeat triggered, resetting old Timeout to 65000ms (should happen every 60s due to /stats event)`,
|
|
1361
|
+
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat()"
|
|
1362
|
+
});
|
|
1309
1363
|
this.resetAckTimeouts(false, true);
|
|
1310
1364
|
if (this.pingTimeout) clearTimeout(this.pingTimeout);
|
|
1311
1365
|
this.pingTimeout = setTimeout(() => {
|
|
1312
1366
|
this.pingTimeout = null;
|
|
1313
1367
|
if (!this.socket) {
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
|
|
1318
|
-
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
1324
|
-
this.NodeManager.LavalinkManager.emit("debug", "SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
|
|
1325
|
-
state: "warn",
|
|
1326
|
-
message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
|
|
1368
|
+
return this._emitDebugEvent("NoSocketOnDestroy" /* NoSocketOnDestroy */, {
|
|
1369
|
+
state: "error",
|
|
1370
|
+
message: `Heartbeat registered a disconnect, but socket didn't exist therefore can't terminate`,
|
|
1327
1371
|
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1328
1372
|
});
|
|
1329
1373
|
}
|
|
1374
|
+
this._emitDebugEvent("SocketTerminateHeartBeatTimeout" /* SocketTerminateHeartBeatTimeout */, {
|
|
1375
|
+
state: "warn",
|
|
1376
|
+
message: `Heartbeat registered a disconnect, because timeout wasn't resetted in time. Terminating Web-Socket`,
|
|
1377
|
+
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat() > timeoutHit"
|
|
1378
|
+
});
|
|
1330
1379
|
this.isAlive = false;
|
|
1331
1380
|
this.socket.terminate();
|
|
1332
1381
|
}, 65e3);
|
|
@@ -1362,71 +1411,75 @@ var LavalinkNode = class {
|
|
|
1362
1411
|
*/
|
|
1363
1412
|
destroy(destroyReason, deleteNode = true, movePlayers = false) {
|
|
1364
1413
|
this.reconnectionState = "IDLE" /* IDLE */;
|
|
1365
|
-
const players = this.
|
|
1366
|
-
if (players
|
|
1367
|
-
const enableDebugEvents = this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents;
|
|
1368
|
-
const handlePlayerOperations = () => {
|
|
1369
|
-
if (movePlayers) {
|
|
1370
|
-
const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
|
|
1371
|
-
if (nodeToMove) {
|
|
1372
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1373
|
-
(player) => player.changeNode(nodeToMove.options.id).catch((error) => {
|
|
1374
|
-
if (enableDebugEvents) {
|
|
1375
|
-
console.error(`Node > destroy() Failed to move player ${player.guildId}: ${error.message}`);
|
|
1376
|
-
}
|
|
1377
|
-
return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
|
|
1378
|
-
if (enableDebugEvents) {
|
|
1379
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`);
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
})
|
|
1383
|
-
));
|
|
1384
|
-
} else {
|
|
1385
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1386
|
-
(player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
|
|
1387
|
-
if (enableDebugEvents) {
|
|
1388
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
|
|
1389
|
-
}
|
|
1390
|
-
})
|
|
1391
|
-
));
|
|
1392
|
-
}
|
|
1393
|
-
} else {
|
|
1394
|
-
return Promise.allSettled(Array.from(players.values()).map(
|
|
1395
|
-
(player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
|
|
1396
|
-
if (enableDebugEvents) {
|
|
1397
|
-
console.error(`Node > destroy() Failed to destroy player ${player.guildId}: ${error.message}`);
|
|
1398
|
-
}
|
|
1399
|
-
})
|
|
1400
|
-
));
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
handlePlayerOperations().finally(() => {
|
|
1404
|
-
this.socket?.close(1e3, "Node-Destroy");
|
|
1405
|
-
this.socket?.removeAllListeners();
|
|
1406
|
-
this.socket = null;
|
|
1407
|
-
this.resetReconnectionAttempts();
|
|
1408
|
-
if (deleteNode) {
|
|
1409
|
-
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1410
|
-
this.NodeManager.nodes.delete(this.id);
|
|
1411
|
-
this.resetAckTimeouts(true, true);
|
|
1412
|
-
} else {
|
|
1413
|
-
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1414
|
-
}
|
|
1415
|
-
});
|
|
1416
|
-
} else {
|
|
1414
|
+
const players = this._LManager.players.filter((p) => p.node.id === this.id);
|
|
1415
|
+
if (!players?.size) {
|
|
1417
1416
|
this.socket?.close(1e3, "Node-Destroy");
|
|
1418
1417
|
this.socket?.removeAllListeners();
|
|
1419
1418
|
this.socket = null;
|
|
1420
1419
|
this.resetReconnectionAttempts();
|
|
1421
|
-
if (deleteNode) {
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1420
|
+
if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1421
|
+
;
|
|
1422
|
+
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1423
|
+
this.NodeManager.nodes.delete(this.id);
|
|
1424
|
+
this.resetAckTimeouts(true, true);
|
|
1425
|
+
return;
|
|
1428
1426
|
}
|
|
1429
|
-
|
|
1427
|
+
const handlePlayerOperations = () => {
|
|
1428
|
+
if (!movePlayers) {
|
|
1429
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1430
|
+
(player) => player.destroy(destroyReason || "NodeDestroy" /* NodeDestroy */).catch((error) => {
|
|
1431
|
+
this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
|
|
1432
|
+
state: "error",
|
|
1433
|
+
message: `Failed to destroy player ${player.guildId}: ${error.message}`,
|
|
1434
|
+
error,
|
|
1435
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1436
|
+
});
|
|
1437
|
+
})
|
|
1438
|
+
));
|
|
1439
|
+
}
|
|
1440
|
+
const nodeToMove = Array.from(this.NodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.id);
|
|
1441
|
+
if (!nodeToMove) {
|
|
1442
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1443
|
+
(player) => player.destroy("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */).catch((error) => {
|
|
1444
|
+
this._emitDebugEvent("PlayerChangeNodeFailNoEligibleNode" /* PlayerChangeNodeFailNoEligibleNode */, {
|
|
1445
|
+
state: "error",
|
|
1446
|
+
message: `Failed to destroy player ${player.guildId}: ${error.message}`,
|
|
1447
|
+
error,
|
|
1448
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1449
|
+
});
|
|
1450
|
+
})
|
|
1451
|
+
));
|
|
1452
|
+
}
|
|
1453
|
+
return Promise.allSettled(Array.from(players.values()).map(
|
|
1454
|
+
(player) => player.changeNode(nodeToMove.options.id).catch((error) => {
|
|
1455
|
+
this._emitDebugEvent("PlayerChangeNodeFail" /* PlayerChangeNodeFail */, {
|
|
1456
|
+
state: "error",
|
|
1457
|
+
message: `Failed to move player ${player.guildId}: ${error.message}`,
|
|
1458
|
+
error,
|
|
1459
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1460
|
+
});
|
|
1461
|
+
return player.destroy(error.message ?? "PlayerChangeNodeFail" /* PlayerChangeNodeFail */).catch((destroyError) => {
|
|
1462
|
+
this._emitDebugEvent("PlayerDestroyFail" /* PlayerDestroyFail */, {
|
|
1463
|
+
state: "error",
|
|
1464
|
+
message: `Failed to destroy player ${player.guildId} after move failure: ${destroyError.message}`,
|
|
1465
|
+
error: destroyError,
|
|
1466
|
+
functionLayer: "Node > destroy() > movePlayers"
|
|
1467
|
+
});
|
|
1468
|
+
});
|
|
1469
|
+
})
|
|
1470
|
+
));
|
|
1471
|
+
};
|
|
1472
|
+
return void handlePlayerOperations().finally(() => {
|
|
1473
|
+
this.socket?.close(1e3, "Node-Destroy");
|
|
1474
|
+
this.socket?.removeAllListeners();
|
|
1475
|
+
this.socket = null;
|
|
1476
|
+
this.resetReconnectionAttempts();
|
|
1477
|
+
if (!deleteNode) return void this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1478
|
+
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1479
|
+
this.NodeManager.nodes.delete(this.id);
|
|
1480
|
+
this.resetAckTimeouts(true, true);
|
|
1481
|
+
return;
|
|
1482
|
+
});
|
|
1430
1483
|
}
|
|
1431
1484
|
/**
|
|
1432
1485
|
* Disconnects the Node-Connection (Websocket)
|
|
@@ -1449,35 +1502,6 @@ var LavalinkNode = class {
|
|
|
1449
1502
|
this.resetReconnectionAttempts();
|
|
1450
1503
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
|
|
1451
1504
|
}
|
|
1452
|
-
/**
|
|
1453
|
-
* Returns if connected to the Node.
|
|
1454
|
-
*
|
|
1455
|
-
* @example
|
|
1456
|
-
* ```ts
|
|
1457
|
-
* const isConnected = player.node.connected;
|
|
1458
|
-
* console.log("node is connected: ", isConnected ? "yes" : "no")
|
|
1459
|
-
* ```
|
|
1460
|
-
*/
|
|
1461
|
-
get connected() {
|
|
1462
|
-
return this.socket && this.socket.readyState === WebSocket.OPEN;
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* Returns the current ConnectionStatus
|
|
1466
|
-
*
|
|
1467
|
-
* @example
|
|
1468
|
-
* ```ts
|
|
1469
|
-
* try {
|
|
1470
|
-
* const statusOfConnection = player.node.connectionStatus;
|
|
1471
|
-
* console.log("node's connection status is:", statusOfConnection)
|
|
1472
|
-
* } catch (error) {
|
|
1473
|
-
* console.error("no socket available?", error)
|
|
1474
|
-
* }
|
|
1475
|
-
* ```
|
|
1476
|
-
*/
|
|
1477
|
-
get connectionStatus() {
|
|
1478
|
-
if (!this.socket) throw new Error("no websocket was initialized yet");
|
|
1479
|
-
return ["CONNECTING", "OPEN", "CLOSING", "CLOSED"][this.socket.readyState] || "UNKNOWN";
|
|
1480
|
-
}
|
|
1481
1505
|
/**
|
|
1482
1506
|
* Gets all Players of a Node
|
|
1483
1507
|
* @returns array of players inside of lavalink
|
|
@@ -1551,7 +1575,7 @@ var LavalinkNode = class {
|
|
|
1551
1575
|
*/
|
|
1552
1576
|
singleTrack: async (encoded, requester) => {
|
|
1553
1577
|
if (!encoded) throw new SyntaxError("No encoded (Base64 string) was provided");
|
|
1554
|
-
return this.
|
|
1578
|
+
return this._LManager.utils?.buildTrack(await this.request(`/decodetrack?encodedTrack=${encodeURIComponent(encoded.replace(/\s/g, ""))}`), requester);
|
|
1555
1579
|
},
|
|
1556
1580
|
/**
|
|
1557
1581
|
* Decodes multiple tracks into their info
|
|
@@ -1572,7 +1596,7 @@ var LavalinkNode = class {
|
|
|
1572
1596
|
r.method = "POST";
|
|
1573
1597
|
r.body = safeStringify(encodeds);
|
|
1574
1598
|
r.headers["Content-Type"] = "application/json";
|
|
1575
|
-
}).then((r) => r.map((track) => this.
|
|
1599
|
+
}).then((r) => r.map((track) => this._LManager.utils.buildTrack(track, requester)));
|
|
1576
1600
|
}
|
|
1577
1601
|
};
|
|
1578
1602
|
lyrics = {
|
|
@@ -1591,8 +1615,8 @@ var LavalinkNode = class {
|
|
|
1591
1615
|
*/
|
|
1592
1616
|
get: async (track, skipTrackSource = false) => {
|
|
1593
1617
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1594
|
-
if (!this.info
|
|
1595
|
-
if (!this.info
|
|
1618
|
+
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}`);
|
|
1619
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin") && this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
1596
1620
|
const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
|
|
1597
1621
|
return await this.request(url);
|
|
1598
1622
|
},
|
|
@@ -1611,8 +1635,8 @@ var LavalinkNode = class {
|
|
|
1611
1635
|
*/
|
|
1612
1636
|
getCurrent: async (guildId, skipTrackSource = false) => {
|
|
1613
1637
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1614
|
-
if (!this.info
|
|
1615
|
-
if (!this.info
|
|
1638
|
+
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}`);
|
|
1639
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavasrc-plugin") && this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "java-lyrics-plugin")) throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
1616
1640
|
const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
|
|
1617
1641
|
return await this.request(url);
|
|
1618
1642
|
},
|
|
@@ -1630,7 +1654,7 @@ var LavalinkNode = class {
|
|
|
1630
1654
|
*/
|
|
1631
1655
|
subscribe: async (guildId) => {
|
|
1632
1656
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1633
|
-
if (!this.info
|
|
1657
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
1634
1658
|
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
|
|
1635
1659
|
options.method = "POST";
|
|
1636
1660
|
});
|
|
@@ -1649,7 +1673,7 @@ var LavalinkNode = class {
|
|
|
1649
1673
|
*/
|
|
1650
1674
|
unsubscribe: async (guildId) => {
|
|
1651
1675
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1652
|
-
if (!this.info
|
|
1676
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin")) throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
1653
1677
|
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
|
|
1654
1678
|
options.method = "DELETE";
|
|
1655
1679
|
});
|
|
@@ -1763,7 +1787,7 @@ var LavalinkNode = class {
|
|
|
1763
1787
|
*/
|
|
1764
1788
|
syncPlayerData(data, res) {
|
|
1765
1789
|
if (typeof data === "object" && typeof data?.guildId === "string" && typeof data.playerOptions === "object" && Object.keys(data.playerOptions).length > 0) {
|
|
1766
|
-
const player = this.
|
|
1790
|
+
const player = this._LManager.getPlayer(data.guildId);
|
|
1767
1791
|
if (!player) return;
|
|
1768
1792
|
if (typeof data.playerOptions.paused !== "undefined") {
|
|
1769
1793
|
player.paused = data.playerOptions.paused;
|
|
@@ -1775,8 +1799,8 @@ var LavalinkNode = class {
|
|
|
1775
1799
|
}
|
|
1776
1800
|
if (typeof data.playerOptions.voice !== "undefined") player.voice = data.playerOptions.voice;
|
|
1777
1801
|
if (typeof data.playerOptions.volume !== "undefined") {
|
|
1778
|
-
if (this.
|
|
1779
|
-
player.volume = Math.round(data.playerOptions.volume / this.
|
|
1802
|
+
if (this._LManager.options.playerOptions.volumeDecrementer) {
|
|
1803
|
+
player.volume = Math.round(data.playerOptions.volume / this._LManager.options.playerOptions.volumeDecrementer);
|
|
1780
1804
|
player.lavalinkVolume = Math.round(data.playerOptions.volume);
|
|
1781
1805
|
} else {
|
|
1782
1806
|
player.volume = Math.round(data.playerOptions.volume);
|
|
@@ -1800,7 +1824,7 @@ var LavalinkNode = class {
|
|
|
1800
1824
|
}
|
|
1801
1825
|
}
|
|
1802
1826
|
if (res?.guildId === "string" && typeof res?.voice !== "undefined") {
|
|
1803
|
-
const player = this.
|
|
1827
|
+
const player = this._LManager.getPlayer(data.guildId);
|
|
1804
1828
|
if (!player) return;
|
|
1805
1829
|
if (typeof res?.voice?.connected === "boolean" && res.voice.connected === false) {
|
|
1806
1830
|
player.destroy("LavalinkNoVoice" /* LavalinkNoVoice */);
|
|
@@ -1933,7 +1957,7 @@ var LavalinkNode = class {
|
|
|
1933
1957
|
}
|
|
1934
1958
|
} catch (e) {
|
|
1935
1959
|
if (this.NodeManager?.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
|
|
1936
|
-
this.
|
|
1960
|
+
this._LManager.emit("debug", "SocketCleanupError" /* SocketCleanupError */, {
|
|
1937
1961
|
state: "warn",
|
|
1938
1962
|
message: `An error occurred during socket cleanup in close() (likely a race condition): ${e.message}`,
|
|
1939
1963
|
functionLayer: "LavalinkNode > close()"
|
|
@@ -1949,9 +1973,9 @@ var LavalinkNode = class {
|
|
|
1949
1973
|
this.reconnect();
|
|
1950
1974
|
}
|
|
1951
1975
|
}
|
|
1952
|
-
this.
|
|
1953
|
-
if (!this.
|
|
1954
|
-
if (this.
|
|
1976
|
+
this._LManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
1977
|
+
if (!this._LManager.options.autoMove) return p.playing = false;
|
|
1978
|
+
if (this._LManager.options.autoMove) {
|
|
1955
1979
|
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
1956
1980
|
return p.playing = false;
|
|
1957
1981
|
p.moveNode();
|
|
@@ -1992,17 +2016,12 @@ var LavalinkNode = class {
|
|
|
1992
2016
|
break;
|
|
1993
2017
|
case "playerUpdate":
|
|
1994
2018
|
{
|
|
1995
|
-
const player = this.
|
|
1996
|
-
if (!player) {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
return;
|
|
2005
|
-
}
|
|
2019
|
+
const player = this._LManager.getPlayer(payload.guildId);
|
|
2020
|
+
if (!player) return this._emitDebugEvent("PlayerUpdateNoPlayer" /* PlayerUpdateNoPlayer */, {
|
|
2021
|
+
state: "error",
|
|
2022
|
+
message: `PlayerUpdate Event Triggered, but no player found of payload.guildId: ${payload.guildId}`,
|
|
2023
|
+
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2024
|
+
});
|
|
2006
2025
|
const oldPlayer = player?.toJSON();
|
|
2007
2026
|
player.lastPositionChange = Date.now();
|
|
2008
2027
|
player.lastPosition = payload.state.position || 0;
|
|
@@ -2011,16 +2030,14 @@ var LavalinkNode = class {
|
|
|
2011
2030
|
if (!player.createdTimeStamp && payload.state.time) player.createdTimeStamp = payload.state.time;
|
|
2012
2031
|
if (player.filterManager.filterUpdatedState === true && ((player.queue.current?.info?.duration || 0) <= (player.LavalinkManager.options.advancedOptions.maxFilterFixDuration || 6e5) || player.queue.current?.info?.uri && isAbsolute(player.queue.current?.info?.uri))) {
|
|
2013
2032
|
player.filterManager.filterUpdatedState = false;
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
});
|
|
2020
|
-
}
|
|
2033
|
+
this._emitDebugEvent("PlayerUpdateFilterFixApply" /* PlayerUpdateFilterFixApply */, {
|
|
2034
|
+
state: "log",
|
|
2035
|
+
message: `Fixing FilterState on "${player.guildId}" because player.options.instaUpdateFiltersFix === true`,
|
|
2036
|
+
functionLayer: "LavalinkNode > nodeEvent > playerUpdate"
|
|
2037
|
+
});
|
|
2021
2038
|
await player.seek(player.position);
|
|
2022
2039
|
}
|
|
2023
|
-
this.
|
|
2040
|
+
this._LManager.emit("playerUpdate", oldPlayer, player);
|
|
2024
2041
|
}
|
|
2025
2042
|
break;
|
|
2026
2043
|
case "event":
|
|
@@ -2034,14 +2051,12 @@ var LavalinkNode = class {
|
|
|
2034
2051
|
try {
|
|
2035
2052
|
this.NodeManager.emit("resumed", this, payload, await this.fetchAllPlayers());
|
|
2036
2053
|
} catch (e) {
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2054
|
+
this._emitDebugEvent("ResumingFetchingError" /* ResumingFetchingError */, {
|
|
2055
|
+
state: "error",
|
|
2056
|
+
message: `Failed to fetch players for resumed event, falling back without players array`,
|
|
2057
|
+
error: e,
|
|
2058
|
+
functionLayer: "LavalinkNode > nodeEvent > resumed"
|
|
2059
|
+
});
|
|
2045
2060
|
this.NodeManager.emit("resumed", this, payload, []);
|
|
2046
2061
|
}
|
|
2047
2062
|
}
|
|
@@ -2054,7 +2069,7 @@ var LavalinkNode = class {
|
|
|
2054
2069
|
/** @private middleware util function for handling all kind of events from websocket */
|
|
2055
2070
|
async handleEvent(payload) {
|
|
2056
2071
|
if (!payload?.guildId) return;
|
|
2057
|
-
const player = this.
|
|
2072
|
+
const player = this._LManager.getPlayer(payload.guildId);
|
|
2058
2073
|
if (!player) return;
|
|
2059
2074
|
switch (payload.type) {
|
|
2060
2075
|
case "TrackStartEvent":
|
|
@@ -2100,7 +2115,7 @@ var LavalinkNode = class {
|
|
|
2100
2115
|
return;
|
|
2101
2116
|
}
|
|
2102
2117
|
getTrackOfPayload(payload) {
|
|
2103
|
-
return "track" in payload ? this.
|
|
2118
|
+
return "track" in payload ? this._LManager.utils.buildTrack(payload.track, void 0) : null;
|
|
2104
2119
|
}
|
|
2105
2120
|
/** @private util function for handling trackStart event */
|
|
2106
2121
|
async trackStart(player, track, payload) {
|
|
@@ -2108,31 +2123,26 @@ var LavalinkNode = class {
|
|
|
2108
2123
|
player.playing = true;
|
|
2109
2124
|
player.paused = false;
|
|
2110
2125
|
}
|
|
2111
|
-
if (this.
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
});
|
|
2118
|
-
}
|
|
2119
|
-
return;
|
|
2126
|
+
if (this._LManager.options?.emitNewSongsOnly === true && player.queue.previous[0]?.info?.identifier === track?.info?.identifier) {
|
|
2127
|
+
return this._emitDebugEvent("TrackStartNewSongsOnly" /* TrackStartNewSongsOnly */, {
|
|
2128
|
+
state: "log",
|
|
2129
|
+
message: `TrackStart not Emitting, because playing the previous song again.`,
|
|
2130
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2131
|
+
});
|
|
2120
2132
|
}
|
|
2121
2133
|
if (!player.queue.current) {
|
|
2122
2134
|
player.queue.current = this.getTrackOfPayload(payload);
|
|
2123
2135
|
if (player.queue.current) {
|
|
2124
2136
|
await player.queue.utils.save();
|
|
2125
2137
|
} else {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
});
|
|
2132
|
-
}
|
|
2138
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2139
|
+
state: "warn",
|
|
2140
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2141
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2142
|
+
});
|
|
2133
2143
|
}
|
|
2134
2144
|
}
|
|
2135
|
-
this.
|
|
2145
|
+
this._LManager.emit("trackStart", player, player.queue.current, payload);
|
|
2136
2146
|
return;
|
|
2137
2147
|
}
|
|
2138
2148
|
/** @private util function for handling trackEnd event */
|
|
@@ -2140,14 +2150,12 @@ var LavalinkNode = class {
|
|
|
2140
2150
|
if (player.get("internal_nodeChanging") === true) return;
|
|
2141
2151
|
const trackToUse = track || this.getTrackOfPayload(payload);
|
|
2142
2152
|
if (payload.reason === "replaced") {
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
}
|
|
2150
|
-
this.NodeManager.LavalinkManager.emit("trackEnd", player, trackToUse, payload);
|
|
2153
|
+
this._emitDebugEvent("TrackEndReplaced" /* TrackEndReplaced */, {
|
|
2154
|
+
state: "warn",
|
|
2155
|
+
message: `TrackEnd Event does not handle any playback, because the track was replaced.`,
|
|
2156
|
+
functionLayer: "LavalinkNode > trackEnd()"
|
|
2157
|
+
});
|
|
2158
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2151
2159
|
return;
|
|
2152
2160
|
}
|
|
2153
2161
|
if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) return this.queueEnd(player, track, payload);
|
|
@@ -2155,8 +2163,8 @@ var LavalinkNode = class {
|
|
|
2155
2163
|
if (player.get("internal_destroystatus") === true) return;
|
|
2156
2164
|
await queueTrackEnd(player);
|
|
2157
2165
|
if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
|
|
2158
|
-
this.
|
|
2159
|
-
if (this.
|
|
2166
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2167
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2160
2168
|
player.play({ noReplace: true });
|
|
2161
2169
|
}
|
|
2162
2170
|
return;
|
|
@@ -2169,30 +2177,28 @@ var LavalinkNode = class {
|
|
|
2169
2177
|
}
|
|
2170
2178
|
if (!player.queue.current) return this.queueEnd(player, trackToUse, payload);
|
|
2171
2179
|
player.set("internal_skipped", false);
|
|
2172
|
-
this.
|
|
2173
|
-
if (this.
|
|
2180
|
+
this._LManager.emit("trackEnd", player, trackToUse, payload);
|
|
2181
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2174
2182
|
player.play({ noReplace: true });
|
|
2175
2183
|
}
|
|
2176
2184
|
return;
|
|
2177
2185
|
}
|
|
2178
2186
|
/** @private util function for handling trackStuck event */
|
|
2179
2187
|
async trackStuck(player, track, payload) {
|
|
2180
|
-
if (this.
|
|
2181
|
-
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.
|
|
2188
|
+
if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
|
|
2189
|
+
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
|
|
2182
2190
|
player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
|
|
2183
|
-
if (oldTimestamps.length > this.
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
});
|
|
2190
|
-
}
|
|
2191
|
+
if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
|
|
2192
|
+
this._emitDebugEvent("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */, {
|
|
2193
|
+
state: "log",
|
|
2194
|
+
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}"`,
|
|
2195
|
+
functionLayer: "LavalinkNode > trackStuck()"
|
|
2196
|
+
});
|
|
2191
2197
|
player.destroy("TrackStuckMaxTracksErroredPerTime" /* TrackStuckMaxTracksErroredPerTime */);
|
|
2192
2198
|
return;
|
|
2193
2199
|
}
|
|
2194
2200
|
}
|
|
2195
|
-
this.
|
|
2201
|
+
this._LManager.emit("trackStuck", player, track || this.getTrackOfPayload(payload), payload);
|
|
2196
2202
|
if (!player.queue.tracks.length && (player.repeatMode === "off" || player.get("internal_stopPlaying"))) {
|
|
2197
2203
|
try {
|
|
2198
2204
|
await player.node.updatePlayer({ guildId: player.guildId, playerOptions: { track: { encoded: null } } });
|
|
@@ -2205,54 +2211,52 @@ var LavalinkNode = class {
|
|
|
2205
2211
|
if (!player.queue.current) {
|
|
2206
2212
|
return this.queueEnd(player, track || this.getTrackOfPayload(payload), payload);
|
|
2207
2213
|
}
|
|
2208
|
-
if (this.
|
|
2214
|
+
if (this._LManager.options.autoSkip && player.queue.current) {
|
|
2209
2215
|
player.play({ track: player.queue.current, noReplace: false });
|
|
2210
2216
|
}
|
|
2211
2217
|
return;
|
|
2212
2218
|
}
|
|
2213
2219
|
/** @private util function for handling trackError event */
|
|
2214
2220
|
async trackError(player, track, payload) {
|
|
2215
|
-
if (this.
|
|
2216
|
-
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this.
|
|
2221
|
+
if (this._LManager.options.playerOptions.maxErrorsPerTime?.threshold > 0 && this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount >= 0) {
|
|
2222
|
+
const oldTimestamps = (player.get("internal_erroredTracksTimestamps") || []).filter((v) => Date.now() - v < this._LManager.options.playerOptions.maxErrorsPerTime?.threshold);
|
|
2217
2223
|
player.set("internal_erroredTracksTimestamps", [...oldTimestamps, Date.now()]);
|
|
2218
|
-
if (oldTimestamps.length > this.
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
});
|
|
2225
|
-
}
|
|
2224
|
+
if (oldTimestamps.length > this._LManager.options.playerOptions.maxErrorsPerTime?.maxAmount) {
|
|
2225
|
+
this._emitDebugEvent("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */, {
|
|
2226
|
+
state: "log",
|
|
2227
|
+
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}"`,
|
|
2228
|
+
functionLayer: "LavalinkNode > trackError()"
|
|
2229
|
+
});
|
|
2226
2230
|
player.destroy("TrackErrorMaxTracksErroredPerTime" /* TrackErrorMaxTracksErroredPerTime */);
|
|
2227
2231
|
return;
|
|
2228
2232
|
}
|
|
2229
2233
|
}
|
|
2230
|
-
this.
|
|
2234
|
+
this._LManager.emit("trackError", player, track || this.getTrackOfPayload(payload), payload);
|
|
2231
2235
|
return;
|
|
2232
2236
|
}
|
|
2233
2237
|
/** @private util function for handling socketClosed event */
|
|
2234
2238
|
socketClosed(player, payload) {
|
|
2235
|
-
this.
|
|
2239
|
+
this._LManager.emit("playerSocketClosed", player, payload);
|
|
2236
2240
|
return;
|
|
2237
2241
|
}
|
|
2238
2242
|
/** @private util function for handling SponsorBlock Segmentloaded event */
|
|
2239
2243
|
SponsorBlockSegmentLoaded(player, track, payload) {
|
|
2240
|
-
this.
|
|
2244
|
+
this._LManager.emit("SegmentsLoaded", player, track || this.getTrackOfPayload(payload), payload);
|
|
2241
2245
|
return;
|
|
2242
2246
|
}
|
|
2243
2247
|
/** @private util function for handling SponsorBlock SegmentSkipped event */
|
|
2244
2248
|
SponsorBlockSegmentSkipped(player, track, payload) {
|
|
2245
|
-
this.
|
|
2249
|
+
this._LManager.emit("SegmentSkipped", player, track || this.getTrackOfPayload(payload), payload);
|
|
2246
2250
|
return;
|
|
2247
2251
|
}
|
|
2248
2252
|
/** @private util function for handling SponsorBlock Chaptersloaded event */
|
|
2249
2253
|
SponsorBlockChaptersLoaded(player, track, payload) {
|
|
2250
|
-
this.
|
|
2254
|
+
this._LManager.emit("ChaptersLoaded", player, track || this.getTrackOfPayload(payload), payload);
|
|
2251
2255
|
return;
|
|
2252
2256
|
}
|
|
2253
2257
|
/** @private util function for handling SponsorBlock Chaptersstarted event */
|
|
2254
2258
|
SponsorBlockChapterStarted(player, track, payload) {
|
|
2255
|
-
this.
|
|
2259
|
+
this._LManager.emit("ChapterStarted", player, track || this.getTrackOfPayload(payload), payload);
|
|
2256
2260
|
return;
|
|
2257
2261
|
}
|
|
2258
2262
|
/**
|
|
@@ -2267,7 +2271,7 @@ var LavalinkNode = class {
|
|
|
2267
2271
|
* ```
|
|
2268
2272
|
*/
|
|
2269
2273
|
async getSponsorBlock(player) {
|
|
2270
|
-
if (!this.info
|
|
2274
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
|
|
2271
2275
|
return await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`);
|
|
2272
2276
|
}
|
|
2273
2277
|
/**
|
|
@@ -2282,7 +2286,7 @@ var LavalinkNode = class {
|
|
|
2282
2286
|
* ```
|
|
2283
2287
|
*/
|
|
2284
2288
|
async setSponsorBlock(player, segments = ["sponsor", "selfpromo"]) {
|
|
2285
|
-
if (!this.info
|
|
2289
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
|
|
2286
2290
|
if (!segments.length) throw new RangeError("No Segments provided. Did you ment to use 'deleteSponsorBlock'?");
|
|
2287
2291
|
if (segments.some((v) => !validSponsorBlocks.includes(v.toLowerCase()))) throw new SyntaxError(`You provided a sponsorblock which isn't valid, valid ones are: ${validSponsorBlocks.map((v) => `'${v}'`).join(", ")}`);
|
|
2288
2292
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
|
|
@@ -2291,13 +2295,11 @@ var LavalinkNode = class {
|
|
|
2291
2295
|
r.body = safeStringify(segments.map((v) => v.toLowerCase()));
|
|
2292
2296
|
});
|
|
2293
2297
|
player.set("internal_sponsorBlockCategories", segments.map((v) => v.toLowerCase()));
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
});
|
|
2300
|
-
}
|
|
2298
|
+
this._emitDebugEvent("SetSponsorBlock" /* SetSponsorBlock */, {
|
|
2299
|
+
state: "log",
|
|
2300
|
+
message: `SponsorBlock was set for Player: ${player.guildId} to: ${segments.map((v) => `'${v.toLowerCase()}'`).join(", ")}`,
|
|
2301
|
+
functionLayer: "LavalinkNode > setSponsorBlock()"
|
|
2302
|
+
});
|
|
2301
2303
|
return;
|
|
2302
2304
|
}
|
|
2303
2305
|
/**
|
|
@@ -2312,18 +2314,16 @@ var LavalinkNode = class {
|
|
|
2312
2314
|
* ```
|
|
2313
2315
|
*/
|
|
2314
2316
|
async deleteSponsorBlock(player) {
|
|
2315
|
-
if (!this.info
|
|
2317
|
+
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "sponsorblock-plugin")) throw new RangeError(`there is no sponsorblock-plugin available in the lavalink node: ${this.id}`);
|
|
2316
2318
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/sponsorblock/categories`, (r) => {
|
|
2317
2319
|
r.method = "DELETE";
|
|
2318
2320
|
});
|
|
2319
2321
|
player.set("internal_sponsorBlockCategories", []);
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
});
|
|
2326
|
-
}
|
|
2322
|
+
this._emitDebugEvent("DeleteSponsorBlock" /* DeleteSponsorBlock */, {
|
|
2323
|
+
state: "log",
|
|
2324
|
+
message: `SponsorBlock was deleted for Player: ${player.guildId}`,
|
|
2325
|
+
functionLayer: "LavalinkNode > deleteSponsorBlock()"
|
|
2326
|
+
});
|
|
2327
2327
|
return;
|
|
2328
2328
|
}
|
|
2329
2329
|
/** private util function for handling the queue end event */
|
|
@@ -2332,46 +2332,38 @@ var LavalinkNode = class {
|
|
|
2332
2332
|
player.queue.current = null;
|
|
2333
2333
|
player.playing = false;
|
|
2334
2334
|
player.set("internal_stopPlaying", void 0);
|
|
2335
|
-
|
|
2336
|
-
|
|
2335
|
+
this._emitDebugEvent("QueueEnded" /* QueueEnded */, {
|
|
2336
|
+
state: "log",
|
|
2337
|
+
message: `Queue Ended because no more Tracks were in the Queue, due to EventName: "${payload.type}"`,
|
|
2338
|
+
functionLayer: "LavalinkNode > queueEnd()"
|
|
2339
|
+
});
|
|
2340
|
+
if (typeof this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
|
|
2341
|
+
this._emitDebugEvent("AutoplayExecution" /* AutoplayExecution */, {
|
|
2337
2342
|
state: "log",
|
|
2338
|
-
message: `
|
|
2339
|
-
functionLayer: "LavalinkNode > queueEnd()"
|
|
2343
|
+
message: `Now Triggering Autoplay.`,
|
|
2344
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2340
2345
|
});
|
|
2341
|
-
}
|
|
2342
|
-
if (typeof this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
|
|
2343
|
-
if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
2344
|
-
this.NodeManager.LavalinkManager.emit("debug", "AutoplayExecution" /* AutoplayExecution */, {
|
|
2345
|
-
state: "log",
|
|
2346
|
-
message: `Now Triggering Autoplay.`,
|
|
2347
|
-
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2348
|
-
});
|
|
2349
|
-
}
|
|
2350
2346
|
const previousAutoplayTime = player.get("internal_previousautoplay");
|
|
2351
2347
|
const duration = previousAutoplayTime ? Date.now() - previousAutoplayTime : 0;
|
|
2352
|
-
if (!duration || duration > this.
|
|
2353
|
-
await this.
|
|
2348
|
+
if (!duration || duration > this._LManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
|
|
2349
|
+
await this._LManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
|
|
2354
2350
|
player.set("internal_previousautoplay", Date.now());
|
|
2355
2351
|
if (player.queue.tracks.length > 0) await queueTrackEnd(player);
|
|
2356
|
-
else
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
if (
|
|
2364
|
-
|
|
2365
|
-
if (this.NodeManager.LavalinkManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
|
|
2366
|
-
}
|
|
2352
|
+
else this._emitDebugEvent("AutoplayNoSongsAdded" /* AutoplayNoSongsAdded */, {
|
|
2353
|
+
state: "warn",
|
|
2354
|
+
message: `Autoplay was triggered but no songs were added to the queue.`,
|
|
2355
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
if (player.queue.current) {
|
|
2359
|
+
if (payload.type === "TrackEndEvent") this._LManager.emit("trackEnd", player, track, payload);
|
|
2360
|
+
if (this._LManager.options.autoSkip) return player.play({ noReplace: true, paused: false });
|
|
2367
2361
|
} else {
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
});
|
|
2374
|
-
}
|
|
2362
|
+
this._emitDebugEvent("AutoplayThresholdSpamLimiter" /* AutoplayThresholdSpamLimiter */, {
|
|
2363
|
+
state: "warn",
|
|
2364
|
+
message: `Autoplay was triggered after the previousautoplay too early. Threshold is: ${this._LManager.options.playerOptions.minAutoPlayMs}ms and the Duration was ${duration}ms`,
|
|
2365
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction"
|
|
2366
|
+
});
|
|
2375
2367
|
}
|
|
2376
2368
|
}
|
|
2377
2369
|
player.set("internal_skipped", false);
|
|
@@ -2384,31 +2376,29 @@ var LavalinkNode = class {
|
|
|
2384
2376
|
if (payload?.reason !== "stopped") {
|
|
2385
2377
|
await player.queue.utils.save();
|
|
2386
2378
|
}
|
|
2387
|
-
if (typeof this.
|
|
2388
|
-
if (this.
|
|
2379
|
+
if (typeof this._LManager.options.playerOptions?.onEmptyQueue?.destroyAfterMs === "number" && !isNaN(this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs) && this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs >= 0) {
|
|
2380
|
+
if (this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs === 0) {
|
|
2389
2381
|
player.destroy("QueueEmpty" /* QueueEmpty */);
|
|
2390
2382
|
return;
|
|
2391
2383
|
} else {
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
}
|
|
2399
|
-
this.NodeManager.LavalinkManager.emit("playerQueueEmptyStart", player, this.NodeManager.LavalinkManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
|
|
2384
|
+
this._emitDebugEvent("TriggerQueueEmptyInterval" /* TriggerQueueEmptyInterval */, {
|
|
2385
|
+
state: "log",
|
|
2386
|
+
message: `Trigger Queue Empty Interval was Triggered because playerOptions.onEmptyQueue.destroyAfterMs is set to ${this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs}ms`,
|
|
2387
|
+
functionLayer: "LavalinkNode > queueEnd() > destroyAfterMs"
|
|
2388
|
+
});
|
|
2389
|
+
this._LManager.emit("playerQueueEmptyStart", player, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs);
|
|
2400
2390
|
if (player.get("internal_queueempty")) clearTimeout(player.get("internal_queueempty"));
|
|
2401
2391
|
player.set("internal_queueempty", setTimeout(() => {
|
|
2402
2392
|
player.set("internal_queueempty", void 0);
|
|
2403
2393
|
if (player.queue.current) {
|
|
2404
|
-
return this.
|
|
2394
|
+
return this._LManager.emit("playerQueueEmptyCancel", player);
|
|
2405
2395
|
}
|
|
2406
|
-
this.
|
|
2396
|
+
this._LManager.emit("playerQueueEmptyEnd", player);
|
|
2407
2397
|
player.destroy("QueueEmpty" /* QueueEmpty */);
|
|
2408
|
-
}, this.
|
|
2398
|
+
}, this._LManager.options.playerOptions.onEmptyQueue?.destroyAfterMs));
|
|
2409
2399
|
}
|
|
2410
2400
|
}
|
|
2411
|
-
this.
|
|
2401
|
+
this._LManager.emit("queueEnd", player, track, payload);
|
|
2412
2402
|
return;
|
|
2413
2403
|
}
|
|
2414
2404
|
/**
|
|
@@ -2424,16 +2414,14 @@ var LavalinkNode = class {
|
|
|
2424
2414
|
if (player.queue.current) {
|
|
2425
2415
|
await player.queue.utils.save();
|
|
2426
2416
|
} else {
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2417
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2418
|
+
state: "warn",
|
|
2419
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2420
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2421
|
+
});
|
|
2434
2422
|
}
|
|
2435
2423
|
}
|
|
2436
|
-
this.
|
|
2424
|
+
this._LManager.emit("LyricsLine", player, track, payload);
|
|
2437
2425
|
return;
|
|
2438
2426
|
}
|
|
2439
2427
|
/**
|
|
@@ -2449,16 +2437,14 @@ var LavalinkNode = class {
|
|
|
2449
2437
|
if (player.queue.current) {
|
|
2450
2438
|
await player.queue.utils.save();
|
|
2451
2439
|
} else {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
});
|
|
2458
|
-
}
|
|
2440
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2441
|
+
state: "warn",
|
|
2442
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2443
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2444
|
+
});
|
|
2459
2445
|
}
|
|
2460
2446
|
}
|
|
2461
|
-
this.
|
|
2447
|
+
this._LManager.emit("LyricsFound", player, track, payload);
|
|
2462
2448
|
return;
|
|
2463
2449
|
}
|
|
2464
2450
|
/**
|
|
@@ -2474,16 +2460,14 @@ var LavalinkNode = class {
|
|
|
2474
2460
|
if (player.queue.current) {
|
|
2475
2461
|
await player.queue.utils.save();
|
|
2476
2462
|
} else {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
});
|
|
2483
|
-
}
|
|
2463
|
+
this._emitDebugEvent("TrackStartNoTrack" /* TrackStartNoTrack */, {
|
|
2464
|
+
state: "warn",
|
|
2465
|
+
message: `Trackstart emitted but there is no track on player.queue.current, trying to get the track of the payload failed too.`,
|
|
2466
|
+
functionLayer: "LavalinkNode > trackStart()"
|
|
2467
|
+
});
|
|
2484
2468
|
}
|
|
2485
2469
|
}
|
|
2486
|
-
this.
|
|
2470
|
+
this._LManager.emit("LyricsNotFound", player, track, payload);
|
|
2487
2471
|
return;
|
|
2488
2472
|
}
|
|
2489
2473
|
};
|
|
@@ -2845,6 +2829,21 @@ var FilterManager = class {
|
|
|
2845
2829
|
data = structuredClone(DEFAULT_FILTER_DATAS);
|
|
2846
2830
|
/** The Player assigned to this Filter Manager */
|
|
2847
2831
|
player;
|
|
2832
|
+
get _LManager() {
|
|
2833
|
+
return this.player.LavalinkManager;
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2836
|
+
* Returns wether the plugin validations are enabled or not
|
|
2837
|
+
*/
|
|
2838
|
+
get _checkForPlugins() {
|
|
2839
|
+
return !!this._LManager.options?.autoChecks?.pluginValidations;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Returns wether the source validations are enabled or not
|
|
2843
|
+
*/
|
|
2844
|
+
get _checkForSources() {
|
|
2845
|
+
return !!this._LManager.options?.autoChecks?.sourcesValidations;
|
|
2846
|
+
}
|
|
2848
2847
|
/** The Constructor for the FilterManager */
|
|
2849
2848
|
constructor(player) {
|
|
2850
2849
|
this.player = player;
|
|
@@ -2881,13 +2880,13 @@ var FilterManager = class {
|
|
|
2881
2880
|
if (!this.filters.karaoke) delete sendData.karaoke;
|
|
2882
2881
|
if (!this.filters.rotation) delete sendData.rotation;
|
|
2883
2882
|
if (this.filters.audioOutput === "stereo") delete sendData.channelMix;
|
|
2884
|
-
if (Object.values(this.data.timescale).every((v) => v === 1)) delete sendData.timescale;
|
|
2883
|
+
if (Object.values(this.data.timescale ?? {}).every((v) => v === 1)) delete sendData.timescale;
|
|
2885
2884
|
if (!this.player.node.sessionId) throw new Error("The Lavalink-Node is either not ready or not up to date");
|
|
2886
2885
|
sendData.equalizer = [...this.equalizerBands];
|
|
2887
2886
|
if (sendData.equalizer.length === 0) delete sendData.equalizer;
|
|
2888
2887
|
for (const key of Object.keys(sendData)) {
|
|
2889
2888
|
if (key === "pluginFilters") {
|
|
2890
|
-
} else if (this.
|
|
2889
|
+
} else if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.(key)) delete sendData[key];
|
|
2891
2890
|
}
|
|
2892
2891
|
const now = performance.now();
|
|
2893
2892
|
if (this.player.options.instaUpdateFiltersFix === true) this.filterUpdatedState = true;
|
|
@@ -3027,7 +3026,7 @@ var FilterManager = class {
|
|
|
3027
3026
|
* ```
|
|
3028
3027
|
*/
|
|
3029
3028
|
async setAudioOutput(type) {
|
|
3030
|
-
if (this.
|
|
3029
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("channelMix")) throw new Error("Node#Info#filters does not include the 'channelMix' Filter (Node has it not enable)");
|
|
3031
3030
|
if (!type || !audioOutputsData[type]) throw "Invalid audio type added, must be 'mono' / 'stereo' / 'left' / 'right'";
|
|
3032
3031
|
this.data = this.data ?? {};
|
|
3033
3032
|
this.data.channelMix = audioOutputsData[type];
|
|
@@ -3047,7 +3046,7 @@ var FilterManager = class {
|
|
|
3047
3046
|
* ```
|
|
3048
3047
|
*/
|
|
3049
3048
|
async setSpeed(speed = 1) {
|
|
3050
|
-
if (this.
|
|
3049
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
3051
3050
|
this.data = this.data ?? {};
|
|
3052
3051
|
this.filters.nightcore = false;
|
|
3053
3052
|
this.filters.vaporwave = false;
|
|
@@ -3068,7 +3067,7 @@ var FilterManager = class {
|
|
|
3068
3067
|
* ```
|
|
3069
3068
|
*/
|
|
3070
3069
|
async setPitch(pitch = 1) {
|
|
3071
|
-
if (this.
|
|
3070
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
3072
3071
|
this.data = this.data ?? {};
|
|
3073
3072
|
this.filters.nightcore = false;
|
|
3074
3073
|
this.filters.vaporwave = false;
|
|
@@ -3089,7 +3088,7 @@ var FilterManager = class {
|
|
|
3089
3088
|
* ```
|
|
3090
3089
|
*/
|
|
3091
3090
|
async setRate(rate = 1) {
|
|
3092
|
-
if (this.
|
|
3091
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
3093
3092
|
this.data = this.data ?? {};
|
|
3094
3093
|
this.filters.nightcore = false;
|
|
3095
3094
|
this.filters.vaporwave = false;
|
|
@@ -3113,7 +3112,7 @@ var FilterManager = class {
|
|
|
3113
3112
|
* ```
|
|
3114
3113
|
*/
|
|
3115
3114
|
async toggleRotation(rotationHz = 0.2) {
|
|
3116
|
-
if (this.
|
|
3115
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("rotation")) throw new Error("Node#Info#filters does not include the 'rotation' Filter (Node has it not enable)");
|
|
3117
3116
|
this.data = this.data ?? {};
|
|
3118
3117
|
this.data.rotation = this.filters.rotation ? DEFAULT_FILTER_DATAS.rotation : { rotationHz };
|
|
3119
3118
|
this.filters.rotation = !this.filters.rotation;
|
|
@@ -3136,7 +3135,7 @@ var FilterManager = class {
|
|
|
3136
3135
|
* ```
|
|
3137
3136
|
*/
|
|
3138
3137
|
async toggleVibrato(frequency = 10, depth = 1) {
|
|
3139
|
-
if (this.
|
|
3138
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("vibrato")) throw new Error("Node#Info#filters does not include the 'vibrato' Filter (Node has it not enable)");
|
|
3140
3139
|
this.data = this.data ?? {};
|
|
3141
3140
|
this.data.vibrato = this.filters.vibrato ? DEFAULT_FILTER_DATAS.vibrato : { depth, frequency };
|
|
3142
3141
|
this.filters.vibrato = !this.filters.vibrato;
|
|
@@ -3159,7 +3158,7 @@ var FilterManager = class {
|
|
|
3159
3158
|
* ```
|
|
3160
3159
|
*/
|
|
3161
3160
|
async toggleTremolo(frequency = 4, depth = 0.8) {
|
|
3162
|
-
if (this.
|
|
3161
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("tremolo")) throw new Error("Node#Info#filters does not include the 'tremolo' Filter (Node has it not enable)");
|
|
3163
3162
|
this.data = this.data ?? {};
|
|
3164
3163
|
this.data.tremolo = this.filters.tremolo ? DEFAULT_FILTER_DATAS.tremolo : { depth, frequency };
|
|
3165
3164
|
this.filters.tremolo = !this.filters.tremolo;
|
|
@@ -3181,7 +3180,7 @@ var FilterManager = class {
|
|
|
3181
3180
|
* ```
|
|
3182
3181
|
*/
|
|
3183
3182
|
async toggleLowPass(smoothing = 20) {
|
|
3184
|
-
if (this.
|
|
3183
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("lowPass")) throw new Error("Node#Info#filters does not include the 'lowPass' Filter (Node has it not enable)");
|
|
3185
3184
|
this.data = this.data ?? {};
|
|
3186
3185
|
this.data.lowPass = this.filters.lowPass ? DEFAULT_FILTER_DATAS.lowPass : { smoothing };
|
|
3187
3186
|
this.filters.lowPass = !this.filters.lowPass;
|
|
@@ -3208,8 +3207,8 @@ var FilterManager = class {
|
|
|
3208
3207
|
* ```
|
|
3209
3208
|
*/
|
|
3210
3209
|
toggleLowPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3211
|
-
if (this.
|
|
3212
|
-
if (this.
|
|
3210
|
+
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");
|
|
3211
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("low-pass")) throw new Error("Node#Info#filters does not include the 'low-pass' Filter (Node has it not enable)");
|
|
3213
3212
|
this.data = this.data ?? {};
|
|
3214
3213
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3215
3214
|
if (this.filters.lavalinkLavaDspxPlugin.lowPass) delete this.data.pluginFilters["low-pass"];
|
|
@@ -3234,8 +3233,8 @@ var FilterManager = class {
|
|
|
3234
3233
|
* ```
|
|
3235
3234
|
*/
|
|
3236
3235
|
toggleHighPass: async (boostFactor = 1, cutoffFrequency = 80) => {
|
|
3237
|
-
if (this.
|
|
3238
|
-
if (this.
|
|
3236
|
+
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");
|
|
3237
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("high-pass")) throw new Error("Node#Info#filters does not include the 'high-pass' Filter (Node has it not enable)");
|
|
3239
3238
|
this.data = this.data ?? {};
|
|
3240
3239
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3241
3240
|
if (this.filters.lavalinkLavaDspxPlugin.highPass) delete this.data.pluginFilters["high-pass"];
|
|
@@ -3260,8 +3259,8 @@ var FilterManager = class {
|
|
|
3260
3259
|
* ```
|
|
3261
3260
|
*/
|
|
3262
3261
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
3263
|
-
if (this.
|
|
3264
|
-
if (this.
|
|
3262
|
+
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");
|
|
3263
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("normalization")) throw new Error("Node#Info#filters does not include the 'normalization' Filter (Node has it not enable)");
|
|
3265
3264
|
this.data = this.data ?? {};
|
|
3266
3265
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3267
3266
|
if (this.filters.lavalinkLavaDspxPlugin.normalization) delete this.data.pluginFilters.normalization;
|
|
@@ -3286,8 +3285,8 @@ var FilterManager = class {
|
|
|
3286
3285
|
* ```
|
|
3287
3286
|
*/
|
|
3288
3287
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
3289
|
-
if (this.
|
|
3290
|
-
if (this.
|
|
3288
|
+
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");
|
|
3289
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable)");
|
|
3291
3290
|
this.data = this.data ?? {};
|
|
3292
3291
|
this.data.pluginFilters = this.data.pluginFilters ?? {};
|
|
3293
3292
|
if (this.filters.lavalinkLavaDspxPlugin.echo) delete this.data.pluginFilters.echo;
|
|
@@ -3317,8 +3316,8 @@ var FilterManager = class {
|
|
|
3317
3316
|
* ```
|
|
3318
3317
|
*/
|
|
3319
3318
|
toggleEcho: async (delay = 4, decay = 0.8) => {
|
|
3320
|
-
if (this.
|
|
3321
|
-
if (this.
|
|
3319
|
+
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");
|
|
3320
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("echo")) throw new Error("Node#Info#filters does not include the 'echo' Filter (Node has it not enable aka not installed!)");
|
|
3322
3321
|
this.data = this.data ?? {};
|
|
3323
3322
|
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3324
3323
|
this.data.pluginFilters = {
|
|
@@ -3348,8 +3347,8 @@ var FilterManager = class {
|
|
|
3348
3347
|
* ```
|
|
3349
3348
|
*/
|
|
3350
3349
|
toggleReverb: async (delays = [0.037, 0.042, 0.048, 0.053], gains = [0.84, 0.83, 0.82, 0.81]) => {
|
|
3351
|
-
if (this.
|
|
3352
|
-
if (this.
|
|
3350
|
+
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");
|
|
3351
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("reverb")) throw new Error("Node#Info#filters does not include the 'reverb' Filter (Node has it not enable aka not installed!)");
|
|
3353
3352
|
this.data = this.data ?? {};
|
|
3354
3353
|
const { echo, reverb } = DEFAULT_FILTER_DATAS.pluginFilters["lavalink-filter-plugin"];
|
|
3355
3354
|
this.data.pluginFilters = {
|
|
@@ -3381,7 +3380,7 @@ var FilterManager = class {
|
|
|
3381
3380
|
* ```
|
|
3382
3381
|
*/
|
|
3383
3382
|
async toggleNightcore(speed = 1.289999523162842, pitch = 1.289999523162842, rate = 0.9365999523162842) {
|
|
3384
|
-
if (this.
|
|
3383
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
3385
3384
|
this.data = this.data ?? {};
|
|
3386
3385
|
this.data.timescale = this.filters.nightcore ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3387
3386
|
this.filters.nightcore = !this.filters.nightcore;
|
|
@@ -3407,7 +3406,7 @@ var FilterManager = class {
|
|
|
3407
3406
|
* ```
|
|
3408
3407
|
*/
|
|
3409
3408
|
async toggleVaporwave(speed = 0.8500000238418579, pitch = 0.800000011920929, rate = 1) {
|
|
3410
|
-
if (this.
|
|
3409
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("timescale")) throw new Error("Node#Info#filters does not include the 'timescale' Filter (Node has it not enable)");
|
|
3411
3410
|
this.data = this.data ?? {};
|
|
3412
3411
|
this.data.timescale = this.filters.vaporwave ? DEFAULT_FILTER_DATAS.timescale : { speed, pitch, rate };
|
|
3413
3412
|
this.filters.vaporwave = !this.filters.vaporwave;
|
|
@@ -3434,7 +3433,7 @@ var FilterManager = class {
|
|
|
3434
3433
|
* ```
|
|
3435
3434
|
*/
|
|
3436
3435
|
async toggleKaraoke(level = 1, monoLevel = 1, filterBand = 220, filterWidth = 100) {
|
|
3437
|
-
if (this.
|
|
3436
|
+
if (this._checkForSources && !this.player?.node?.info?.filters?.includes?.("karaoke")) throw new Error("Node#Info#filters does not include the 'karaoke' Filter (Node has it not enable)");
|
|
3438
3437
|
this.data = this.data ?? {};
|
|
3439
3438
|
this.data.karaoke = this.filters.karaoke ? DEFAULT_FILTER_DATAS.karaoke : { level, monoLevel, filterBand, filterWidth };
|
|
3440
3439
|
this.filters.karaoke = !this.filters.karaoke;
|
|
@@ -3951,6 +3950,15 @@ var Player = class {
|
|
|
3951
3950
|
};
|
|
3952
3951
|
/** Custom data for the player */
|
|
3953
3952
|
data = {};
|
|
3953
|
+
/**
|
|
3954
|
+
* Emits a debug event to the LavalinkManager
|
|
3955
|
+
* @param name name of the event
|
|
3956
|
+
* @param eventData event data
|
|
3957
|
+
*/
|
|
3958
|
+
_emitDebugEvent(name, eventData) {
|
|
3959
|
+
if (!this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) return;
|
|
3960
|
+
this.LavalinkManager.emit("debug", name, eventData);
|
|
3961
|
+
}
|
|
3954
3962
|
/**
|
|
3955
3963
|
* Create a new Player
|
|
3956
3964
|
* @param options
|
|
@@ -3966,8 +3974,8 @@ var Player = class {
|
|
|
3966
3974
|
this.textChannelId = this.options.textChannelId || null;
|
|
3967
3975
|
this.node = typeof this.options.node === "string" ? this.LavalinkManager.nodeManager.nodes.get(this.options.node) : this.options.node;
|
|
3968
3976
|
if (!this.node || typeof this.node.request !== "function") {
|
|
3969
|
-
if (typeof this.options.node === "string"
|
|
3970
|
-
this.
|
|
3977
|
+
if (typeof this.options.node === "string") {
|
|
3978
|
+
this._emitDebugEvent("PlayerCreateNodeNotFound" /* PlayerCreateNodeNotFound */, {
|
|
3971
3979
|
state: "warn",
|
|
3972
3980
|
message: `Player was created with provided node Id: ${this.options.node}, but no node with that Id was found.`,
|
|
3973
3981
|
functionLayer: "Player > constructor()"
|
|
@@ -4024,13 +4032,11 @@ var Player = class {
|
|
|
4024
4032
|
*/
|
|
4025
4033
|
async play(options = {}) {
|
|
4026
4034
|
if (this.get("internal_queueempty")) {
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4035
|
+
this._emitDebugEvent("PlayerPlayQueueEmptyTimeoutClear" /* PlayerPlayQueueEmptyTimeoutClear */, {
|
|
4036
|
+
state: "log",
|
|
4037
|
+
message: `Player was called to play something, while there was a queueEmpty Timeout set, clearing the timeout.`,
|
|
4038
|
+
functionLayer: "Player > play()"
|
|
4039
|
+
});
|
|
4034
4040
|
this.LavalinkManager.emit("playerQueueEmptyCancel", this);
|
|
4035
4041
|
clearTimeout(this.get("internal_queueempty"));
|
|
4036
4042
|
this.set("internal_queueempty", void 0);
|
|
@@ -4040,14 +4046,12 @@ var Player = class {
|
|
|
4040
4046
|
try {
|
|
4041
4047
|
await options.clientTrack.resolve(this);
|
|
4042
4048
|
} catch (error) {
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
});
|
|
4050
|
-
}
|
|
4049
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
|
|
4050
|
+
state: "error",
|
|
4051
|
+
error,
|
|
4052
|
+
message: `Player Play was called with clientTrack, Song is unresolved, but couldn't resolve it`,
|
|
4053
|
+
functionLayer: "Player > play() > resolve currentTrack"
|
|
4054
|
+
});
|
|
4051
4055
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
4052
4056
|
if (options && "clientTrack" in options) delete options.clientTrack;
|
|
4053
4057
|
if (options && "track" in options) delete options.track;
|
|
@@ -4084,13 +4088,11 @@ var Player = class {
|
|
|
4084
4088
|
...options.track.userData
|
|
4085
4089
|
}
|
|
4086
4090
|
}).filter((v) => typeof v[1] !== "undefined"));
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
});
|
|
4093
|
-
}
|
|
4091
|
+
this._emitDebugEvent("PlayerPlayWithTrackReplace" /* PlayerPlayWithTrackReplace */, {
|
|
4092
|
+
state: "log",
|
|
4093
|
+
message: `Player was called to play something, with a specific track provided. Replacing the current Track and resolving the track on trackStart Event.`,
|
|
4094
|
+
functionLayer: "Player > play()"
|
|
4095
|
+
});
|
|
4094
4096
|
return this.node.updatePlayer({
|
|
4095
4097
|
guildId: this.guildId,
|
|
4096
4098
|
noReplace: false,
|
|
@@ -4107,13 +4109,11 @@ var Player = class {
|
|
|
4107
4109
|
}
|
|
4108
4110
|
if (!this.queue.current && this.queue.tracks.length) await queueTrackEnd(this);
|
|
4109
4111
|
if (this.queue.current && this.LavalinkManager.utils.isUnresolvedTrack(this.queue.current)) {
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
});
|
|
4116
|
-
}
|
|
4112
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrack" /* PlayerPlayUnresolvedTrack */, {
|
|
4113
|
+
state: "log",
|
|
4114
|
+
message: `Player Play was called, current Queue Song is unresolved, resolving the track.`,
|
|
4115
|
+
functionLayer: "Player > play()"
|
|
4116
|
+
});
|
|
4117
4117
|
try {
|
|
4118
4118
|
await this.queue.current.resolve(this);
|
|
4119
4119
|
if (typeof options.track?.userData === "object" && this.queue.current) this.queue.current.userData = {
|
|
@@ -4122,14 +4122,12 @@ var Player = class {
|
|
|
4122
4122
|
...options.track?.userData
|
|
4123
4123
|
};
|
|
4124
4124
|
} catch (error) {
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
});
|
|
4132
|
-
}
|
|
4125
|
+
this._emitDebugEvent("PlayerPlayUnresolvedTrackFailed" /* PlayerPlayUnresolvedTrackFailed */, {
|
|
4126
|
+
state: "error",
|
|
4127
|
+
error,
|
|
4128
|
+
message: `Player Play was called, current Queue Song is unresolved, but couldn't resolve it`,
|
|
4129
|
+
functionLayer: "Player > play() > resolve currentTrack"
|
|
4130
|
+
});
|
|
4133
4131
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
4134
4132
|
if (options && "clientTrack" in options) delete options.clientTrack;
|
|
4135
4133
|
if (options && "track" in options) delete options.track;
|
|
@@ -4190,13 +4188,11 @@ var Player = class {
|
|
|
4190
4188
|
), 1e3), 0));
|
|
4191
4189
|
const now = performance.now();
|
|
4192
4190
|
if (this.LavalinkManager.options.playerOptions.applyVolumeAsFilter) {
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
});
|
|
4199
|
-
}
|
|
4191
|
+
this._emitDebugEvent("PlayerVolumeAsFilter" /* PlayerVolumeAsFilter */, {
|
|
4192
|
+
state: "log",
|
|
4193
|
+
message: `Player Volume was set as a Filter, because LavalinkManager option "playerOptions.applyVolumeAsFilter" is true`,
|
|
4194
|
+
functionLayer: "Player > setVolume()"
|
|
4195
|
+
});
|
|
4200
4196
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { filters: { volume: this.lavalinkVolume / 100 } } });
|
|
4201
4197
|
} else {
|
|
4202
4198
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { volume: this.lavalinkVolume } });
|
|
@@ -4241,13 +4237,11 @@ var Player = class {
|
|
|
4241
4237
|
async search(query, requestUser, throwOnEmpty = false) {
|
|
4242
4238
|
const Query = this.LavalinkManager.utils.transformQuery(query);
|
|
4243
4239
|
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info?.sourceManagers.includes("bandcamp")) {
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
});
|
|
4250
|
-
}
|
|
4240
|
+
this._emitDebugEvent("BandcampSearchLokalEngine" /* BandcampSearchLokalEngine */, {
|
|
4241
|
+
state: "log",
|
|
4242
|
+
message: `Player.search was called with a Bandcamp Query, but no bandcamp search was enabled on lavalink, searching with the custom Search Engine.`,
|
|
4243
|
+
functionLayer: "Player > search()"
|
|
4244
|
+
});
|
|
4251
4245
|
return await bandCampSearch(this, Query.query, requestUser);
|
|
4252
4246
|
}
|
|
4253
4247
|
return this.node.search(Query, requestUser, throwOnEmpty);
|
|
@@ -4399,13 +4393,11 @@ var Player = class {
|
|
|
4399
4393
|
this.set("internal_queueempty", void 0);
|
|
4400
4394
|
}
|
|
4401
4395
|
if (this.get("internal_destroystatus") === true) {
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
});
|
|
4408
|
-
}
|
|
4396
|
+
this._emitDebugEvent("PlayerDestroyingSomewhereElse" /* PlayerDestroyingSomewhereElse */, {
|
|
4397
|
+
state: "warn",
|
|
4398
|
+
message: `Player is already destroying somewhere else..`,
|
|
4399
|
+
functionLayer: "Player > destroy()"
|
|
4400
|
+
});
|
|
4409
4401
|
if (this.LavalinkManager.options.advancedOptions?.debugOptions.playerDestroy.debugLog) console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Already destroying somewhere else..`);
|
|
4410
4402
|
return;
|
|
4411
4403
|
}
|
|
@@ -4498,17 +4490,15 @@ var Player = class {
|
|
|
4498
4490
|
const missingSources = [...trackSources].filter(
|
|
4499
4491
|
(source) => !updateNode.info?.sourceManagers.includes(source)
|
|
4500
4492
|
);
|
|
4501
|
-
if (missingSources.length)
|
|
4493
|
+
if (this.LavalinkManager.options.autoChecks?.sourcesValidations && missingSources.length)
|
|
4502
4494
|
throw new RangeError(`Sources missing for Node ${updateNode.id}: ${missingSources.join(", ")}`);
|
|
4503
4495
|
}
|
|
4504
4496
|
}
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
});
|
|
4511
|
-
}
|
|
4497
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4498
|
+
state: "log",
|
|
4499
|
+
message: `Player.changeNode() was executed, trying to change from "${this.node.id}" to "${updateNode.id}"`,
|
|
4500
|
+
functionLayer: "Player > changeNode()"
|
|
4501
|
+
});
|
|
4512
4502
|
const data = this.toJSON();
|
|
4513
4503
|
const currentTrack = this.queue.current;
|
|
4514
4504
|
if (!this.voice.endpoint || !this.voice.sessionId || !this.voice.token)
|
|
@@ -4519,30 +4509,26 @@ var Player = class {
|
|
|
4519
4509
|
const now = performance.now();
|
|
4520
4510
|
try {
|
|
4521
4511
|
await this.connect();
|
|
4522
|
-
const hasSponsorBlock = this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
|
|
4512
|
+
const hasSponsorBlock = !this.LavalinkManager.options?.autoChecks?.pluginValidations || this.node.info?.plugins?.find((v) => v.name === "sponsorblock-plugin");
|
|
4523
4513
|
if (hasSponsorBlock) {
|
|
4524
4514
|
const sponsorBlockCategories = this.get("internal_sponsorBlockCategories");
|
|
4525
4515
|
if (Array.isArray(sponsorBlockCategories) && sponsorBlockCategories.length) {
|
|
4526
4516
|
await this.setSponsorBlock(sponsorBlockCategories).catch((error) => {
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
});
|
|
4534
|
-
}
|
|
4517
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4518
|
+
state: "error",
|
|
4519
|
+
error,
|
|
4520
|
+
message: `Player > changeNode() Unable to set SponsorBlock Segments`,
|
|
4521
|
+
functionLayer: "Player > changeNode()"
|
|
4522
|
+
});
|
|
4535
4523
|
});
|
|
4536
4524
|
} else {
|
|
4537
4525
|
await this.setSponsorBlock().catch((error) => {
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
});
|
|
4545
|
-
}
|
|
4526
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4527
|
+
state: "error",
|
|
4528
|
+
error,
|
|
4529
|
+
message: `Player > changeNode() Unable to set SponsorBlock Segments`,
|
|
4530
|
+
functionLayer: "Player > changeNode()"
|
|
4531
|
+
});
|
|
4546
4532
|
});
|
|
4547
4533
|
}
|
|
4548
4534
|
}
|
|
@@ -4567,14 +4553,12 @@ var Player = class {
|
|
|
4567
4553
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
4568
4554
|
return this.node.id;
|
|
4569
4555
|
} catch (error) {
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
});
|
|
4577
|
-
}
|
|
4556
|
+
this._emitDebugEvent("PlayerChangeNode" /* PlayerChangeNode */, {
|
|
4557
|
+
state: "error",
|
|
4558
|
+
error,
|
|
4559
|
+
message: `Player.changeNode() execution failed`,
|
|
4560
|
+
functionLayer: "Player > changeNode()"
|
|
4561
|
+
});
|
|
4578
4562
|
throw new Error(`Failed to change the node: ${error}`);
|
|
4579
4563
|
} finally {
|
|
4580
4564
|
this.set("internal_nodeChanging", void 0);
|
|
@@ -4700,6 +4684,10 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4700
4684
|
id: options?.client?.id,
|
|
4701
4685
|
username: options?.client?.username ?? "lavalink-client"
|
|
4702
4686
|
},
|
|
4687
|
+
autoChecks: {
|
|
4688
|
+
sourcesValidations: options?.autoChecks?.sourcesValidations ?? true,
|
|
4689
|
+
pluginValidations: options?.autoChecks?.pluginValidations ?? true
|
|
4690
|
+
},
|
|
4703
4691
|
sendToShard: options?.sendToShard,
|
|
4704
4692
|
autoMove: options?.autoMove ?? false,
|
|
4705
4693
|
nodes: options?.nodes,
|
|
@@ -4763,6 +4751,8 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4763
4751
|
if (options?.autoSkipOnResolveError && typeof options?.autoSkipOnResolveError !== "boolean") throw new SyntaxError("ManagerOption.autoSkipOnResolveError must be either false | true aka boolean");
|
|
4764
4752
|
if (options?.emitNewSongsOnly && typeof options?.emitNewSongsOnly !== "boolean") throw new SyntaxError("ManagerOption.emitNewSongsOnly must be either false | true aka boolean");
|
|
4765
4753
|
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");
|
|
4754
|
+
if (typeof options?.autoChecks?.sourcesValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.sourcesValidations must be either false | true aka boolean");
|
|
4755
|
+
if (typeof options?.autoChecks?.pluginValidations !== "boolean") throw new SyntaxError("ManagerOption.autoChecks.pluginValidations must be either false | true aka boolean");
|
|
4766
4756
|
if (options?.queueOptions?.queueStore) {
|
|
4767
4757
|
const keys = Object.getOwnPropertyNames(Object.getPrototypeOf(options?.queueOptions?.queueStore));
|
|
4768
4758
|
const requiredKeys = ["get", "set", "stringify", "parse", "delete"];
|
|
@@ -4775,6 +4765,15 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4775
4765
|
}
|
|
4776
4766
|
if (typeof options?.queueOptions?.maxPreviousTracks !== "number" || options?.queueOptions?.maxPreviousTracks < 0) options.queueOptions.maxPreviousTracks = 25;
|
|
4777
4767
|
}
|
|
4768
|
+
/**
|
|
4769
|
+
* Emits a debug event to the LavalinkManager
|
|
4770
|
+
* @param name name of the event
|
|
4771
|
+
* @param eventData event data
|
|
4772
|
+
*/
|
|
4773
|
+
_emitDebugEvent(name, eventData) {
|
|
4774
|
+
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
4775
|
+
this.emit("debug", name, eventData);
|
|
4776
|
+
}
|
|
4778
4777
|
/**
|
|
4779
4778
|
* Create the Lavalink Manager
|
|
4780
4779
|
* @param options
|
|
@@ -4924,13 +4923,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4924
4923
|
if (!oldPlayer) return;
|
|
4925
4924
|
if (typeof oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
4926
4925
|
if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError) throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${safeStringify(oldPlayer.toJSON?.())}`);
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
});
|
|
4933
|
-
}
|
|
4926
|
+
this._emitDebugEvent("PlayerDeleteInsteadOfDestroy" /* PlayerDeleteInsteadOfDestroy */, {
|
|
4927
|
+
state: "warn",
|
|
4928
|
+
message: "Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player",
|
|
4929
|
+
functionLayer: "LavalinkManager > deletePlayer()"
|
|
4930
|
+
});
|
|
4934
4931
|
}
|
|
4935
4932
|
return this.players.delete(guildId);
|
|
4936
4933
|
}
|
|
@@ -4978,13 +4975,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4978
4975
|
}
|
|
4979
4976
|
}
|
|
4980
4977
|
if (success > 0) this.initiated = true;
|
|
4981
|
-
else
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
});
|
|
4987
|
-
}
|
|
4978
|
+
else this._emitDebugEvent("FailedToConnectToNodes" /* FailedToConnectToNodes */, {
|
|
4979
|
+
state: "error",
|
|
4980
|
+
message: "Failed to connect to at least 1 Node",
|
|
4981
|
+
functionLayer: "LavalinkManager > init()"
|
|
4982
|
+
});
|
|
4988
4983
|
return this;
|
|
4989
4984
|
}
|
|
4990
4985
|
/**
|
|
@@ -5004,24 +4999,20 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5004
4999
|
*/
|
|
5005
5000
|
async sendRawData(data) {
|
|
5006
5001
|
if (!this.initiated) {
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
});
|
|
5013
|
-
}
|
|
5002
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5003
|
+
state: "log",
|
|
5004
|
+
message: "Manager is not initated yet",
|
|
5005
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5006
|
+
});
|
|
5014
5007
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet");
|
|
5015
5008
|
return;
|
|
5016
5009
|
}
|
|
5017
5010
|
if (!("t" in data)) {
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
});
|
|
5024
|
-
}
|
|
5011
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5012
|
+
state: "error",
|
|
5013
|
+
message: "No 't' in payload-data of the raw event:",
|
|
5014
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5015
|
+
});
|
|
5025
5016
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 't' in payload-data of the raw event:", data);
|
|
5026
5017
|
return;
|
|
5027
5018
|
}
|
|
@@ -5034,47 +5025,39 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5034
5025
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
5035
5026
|
const update = "d" in data ? data.d : data;
|
|
5036
5027
|
if (!update) {
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
});
|
|
5043
|
-
}
|
|
5028
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5029
|
+
state: "warn",
|
|
5030
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
5031
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5032
|
+
});
|
|
5044
5033
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no update data found in payload:", data);
|
|
5045
5034
|
return;
|
|
5046
5035
|
}
|
|
5047
5036
|
if (!("token" in update) && !("session_id" in update)) {
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
});
|
|
5054
|
-
}
|
|
5037
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5038
|
+
state: "error",
|
|
5039
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
5040
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5041
|
+
});
|
|
5055
5042
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 'token' nor 'session_id' found in payload:", data);
|
|
5056
5043
|
return;
|
|
5057
5044
|
}
|
|
5058
5045
|
const player = this.getPlayer(update.guild_id);
|
|
5059
5046
|
if (!player) {
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
});
|
|
5066
|
-
}
|
|
5047
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5048
|
+
state: "warn",
|
|
5049
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
5050
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5051
|
+
});
|
|
5067
5052
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, No Lavalink Player found via key: 'guild_id' of update-data:", update);
|
|
5068
5053
|
return;
|
|
5069
5054
|
}
|
|
5070
5055
|
if (player.get("internal_destroystatus") === true) {
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
});
|
|
5077
|
-
}
|
|
5056
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5057
|
+
state: "warn",
|
|
5058
|
+
message: `Player is in a destroying state. can't signal the voice states`,
|
|
5059
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5060
|
+
});
|
|
5078
5061
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states");
|
|
5079
5062
|
return;
|
|
5080
5063
|
}
|
|
@@ -5099,13 +5082,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5099
5082
|
}
|
|
5100
5083
|
}
|
|
5101
5084
|
});
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
});
|
|
5108
|
-
}
|
|
5085
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5086
|
+
state: "log",
|
|
5087
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, update, playerVoice: player.voice }, 2)}`,
|
|
5088
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5089
|
+
});
|
|
5109
5090
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session", { voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use }, playerVoice: player.voice, update });
|
|
5110
5091
|
}
|
|
5111
5092
|
return;
|
|
@@ -5114,13 +5095,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5114
5095
|
if (update.user_id && player.voiceChannelId) {
|
|
5115
5096
|
this.emit(update.channel_id === player.voiceChannelId ? "playerVoiceJoin" : "playerVoiceLeave", player, update.user_id);
|
|
5116
5097
|
}
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
});
|
|
5123
|
-
}
|
|
5098
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5099
|
+
state: "warn",
|
|
5100
|
+
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}"`,
|
|
5101
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5102
|
+
});
|
|
5124
5103
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, voice update user is not equal to provided client id of the manageroptions#client#id", "user:", update.user_id, "manager client id:", this.options?.client.id);
|
|
5125
5104
|
return;
|
|
5126
5105
|
}
|
|
@@ -5128,13 +5107,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5128
5107
|
if (player.voiceChannelId !== update.channel_id) this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
5129
5108
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
5130
5109
|
if (!player.voice.sessionId) {
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
});
|
|
5137
|
-
}
|
|
5110
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, {
|
|
5111
|
+
state: "warn",
|
|
5112
|
+
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
5113
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5114
|
+
});
|
|
5138
5115
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) console.debug(`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`);
|
|
5139
5116
|
}
|
|
5140
5117
|
player.voiceChannelId = update.channel_id;
|
|
@@ -5165,13 +5142,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5165
5142
|
try {
|
|
5166
5143
|
const previousPosition = player.position;
|
|
5167
5144
|
const previousPaused = player.paused;
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
});
|
|
5174
|
-
}
|
|
5145
|
+
this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
|
|
5146
|
+
state: "log",
|
|
5147
|
+
message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
|
|
5148
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5149
|
+
});
|
|
5175
5150
|
if (!autoReconnectOnlyWithTracks || autoReconnectOnlyWithTracks && (player.queue.current || player.queue.tracks.length)) {
|
|
5176
5151
|
await player.connect();
|
|
5177
5152
|
}
|
|
@@ -5181,13 +5156,11 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
5181
5156
|
if (player.queue.tracks.length) {
|
|
5182
5157
|
return void await player.play({ paused: previousPaused });
|
|
5183
5158
|
}
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
});
|
|
5190
|
-
}
|
|
5159
|
+
this._emitDebugEvent("PlayerAutoReconnect" /* PlayerAutoReconnect */, {
|
|
5160
|
+
state: "log",
|
|
5161
|
+
message: `Auto reconnected, but nothing to play`,
|
|
5162
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5163
|
+
});
|
|
5191
5164
|
return;
|
|
5192
5165
|
} catch (e) {
|
|
5193
5166
|
console.error(e);
|