lavalink-client 2.6.7 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.d.mts +148 -160
- package/dist/index.d.ts +148 -160
- package/dist/index.js +112 -56
- package/dist/index.mjs +112 -56
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -79,6 +79,7 @@ var DebugEvents = /* @__PURE__ */ ((DebugEvents2) => {
|
|
|
79
79
|
DebugEvents2["PlayerUpdateSuccess"] = "PlayerUpdateSuccess";
|
|
80
80
|
DebugEvents2["HeartBeatTriggered"] = "HeartBeatTriggered";
|
|
81
81
|
DebugEvents2["NoSocketOnDestroy"] = "NoSocketOnDestroy";
|
|
82
|
+
DebugEvents2["SocketCleanupError"] = "SocketCleanupError";
|
|
82
83
|
DebugEvents2["SocketTerminateHeartBeatTimeout"] = "SocketTerminateHeartBeatTimeout";
|
|
83
84
|
DebugEvents2["TryingConnectWhileConnected"] = "TryingConnectWhileConnected";
|
|
84
85
|
DebugEvents2["LavaSearchNothingFound"] = "LavaSearchNothingFound";
|
|
@@ -481,7 +482,7 @@ var SourceLinksRegexes = {
|
|
|
481
482
|
/** DEFAULT SUPPORTED BY LAVALINK */
|
|
482
483
|
YoutubeRegex: /https?:\/\/?(?:www\.)?(?:(m|www)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts|playlist\?|watch\?v=|watch\?.+(?:&|&);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&)index=((?:\d){1,3}))?(?:(?:\?|&|&)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/,
|
|
483
484
|
YoutubeMusicRegex: /https?:\/\/?(?:www\.)?(?:(music|m|www)\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|shorts|playlist\?|watch\?v=|watch\?.+(?:&|&);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&)index=((?:\d){1,3}))?(?:(?:\?|&|&)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?/,
|
|
484
|
-
SoundCloudRegex: /https
|
|
485
|
+
SoundCloudRegex: /https?:\/\/(?:on\.)?soundcloud\.com\//,
|
|
485
486
|
SoundCloudMobileRegex: /https?:\/\/(soundcloud\.app\.goo\.gl)\/(\S+)/,
|
|
486
487
|
bandcamp: /https?:\/\/?(?:www\.)?([\d|\w]+)\.bandcamp\.com\/(\S+)/,
|
|
487
488
|
TwitchTv: /https?:\/\/?(?:www\.)?twitch\.tv\/\w+/,
|
|
@@ -1001,9 +1002,15 @@ async function getClosestTrack(data, player) {
|
|
|
1001
1002
|
source: sourceName !== "twitch" && sourceName !== "flowery-tts" ? sourceName : player.LavalinkManager.options?.playerOptions?.defaultSearchPlatform
|
|
1002
1003
|
}, data.requester).then((res) => {
|
|
1003
1004
|
let trackToUse = null;
|
|
1004
|
-
if (
|
|
1005
|
-
|
|
1006
|
-
|
|
1005
|
+
if ((data.info?.title || data.info?.author) && !trackToUse) trackToUse = res.tracks.find(
|
|
1006
|
+
(track) => (
|
|
1007
|
+
// find via author name (i ... case insensitve)
|
|
1008
|
+
[data.info?.author || "", `${data.info?.author} - Topic`].some((name) => new RegExp(`^${escapeRegExp(name)}$`, "i").test(track.info?.author)) || // find via title (i ... case insensitve)
|
|
1009
|
+
new RegExp(`^${escapeRegExp(data.info?.title)}$`, "i").test(track.info?.title)
|
|
1010
|
+
)
|
|
1011
|
+
);
|
|
1012
|
+
if (data.info?.isrc && !trackToUse) trackToUse = res.tracks.find((track) => track.info?.isrc === data.info?.isrc);
|
|
1013
|
+
if (data.info?.duration && !trackToUse) trackToUse = res.tracks.find((track) => track.info?.duration >= data.info?.duration - 1500 && track?.info.duration <= data.info?.duration + 1500);
|
|
1007
1014
|
return applyUnresolvedData(trackToUse || res.tracks[0], data, player.LavalinkManager.utils);
|
|
1008
1015
|
});
|
|
1009
1016
|
}
|
|
@@ -1347,7 +1354,7 @@ var LavalinkNode = class {
|
|
|
1347
1354
|
functionLayer: "LavalinkNode > nodeEvent > stats > heartBeat()"
|
|
1348
1355
|
});
|
|
1349
1356
|
}
|
|
1350
|
-
|
|
1357
|
+
this.resetAckTimeouts(false, true);
|
|
1351
1358
|
this.pingTimeout = setTimeout(() => {
|
|
1352
1359
|
this.pingTimeout = null;
|
|
1353
1360
|
if (!this.socket) {
|
|
@@ -1440,31 +1447,27 @@ var LavalinkNode = class {
|
|
|
1440
1447
|
}
|
|
1441
1448
|
};
|
|
1442
1449
|
handlePlayerOperations().finally(() => {
|
|
1443
|
-
this.socket
|
|
1444
|
-
this.socket
|
|
1450
|
+
this.socket?.close(1e3, "Node-Destroy");
|
|
1451
|
+
this.socket?.removeAllListeners();
|
|
1445
1452
|
this.socket = null;
|
|
1446
|
-
this.
|
|
1447
|
-
clearTimeout(this.reconnectTimeout);
|
|
1453
|
+
this.resetReconnectionAttempts();
|
|
1448
1454
|
if (deleteNode) {
|
|
1449
1455
|
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1450
1456
|
this.NodeManager.nodes.delete(this.id);
|
|
1451
|
-
|
|
1452
|
-
clearTimeout(this.pingTimeout);
|
|
1457
|
+
this.resetAckTimeouts(true, true);
|
|
1453
1458
|
} else {
|
|
1454
1459
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1455
1460
|
}
|
|
1456
1461
|
});
|
|
1457
1462
|
} else {
|
|
1458
|
-
this.socket
|
|
1459
|
-
this.socket
|
|
1463
|
+
this.socket?.close(1e3, "Node-Destroy");
|
|
1464
|
+
this.socket?.removeAllListeners();
|
|
1460
1465
|
this.socket = null;
|
|
1461
|
-
this.
|
|
1462
|
-
clearTimeout(this.reconnectTimeout);
|
|
1466
|
+
this.resetReconnectionAttempts();
|
|
1463
1467
|
if (deleteNode) {
|
|
1464
1468
|
this.NodeManager.emit("destroy", this, destroyReason);
|
|
1465
1469
|
this.NodeManager.nodes.delete(this.id);
|
|
1466
|
-
|
|
1467
|
-
clearTimeout(this.pingTimeout);
|
|
1470
|
+
this.resetAckTimeouts(true, true);
|
|
1468
1471
|
} else {
|
|
1469
1472
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: destroyReason });
|
|
1470
1473
|
}
|
|
@@ -1485,11 +1488,10 @@ var LavalinkNode = class {
|
|
|
1485
1488
|
*/
|
|
1486
1489
|
disconnect(disconnectReason) {
|
|
1487
1490
|
if (!this.connected) return;
|
|
1488
|
-
this.socket
|
|
1489
|
-
this.socket
|
|
1491
|
+
this.socket?.close(1e3, "Node-Disconnect");
|
|
1492
|
+
this.socket?.removeAllListeners();
|
|
1490
1493
|
this.socket = null;
|
|
1491
|
-
this.
|
|
1492
|
-
clearTimeout(this.reconnectTimeout);
|
|
1494
|
+
this.resetReconnectionAttempts();
|
|
1493
1495
|
this.NodeManager.emit("disconnect", this, { code: 1e3, reason: disconnectReason });
|
|
1494
1496
|
}
|
|
1495
1497
|
/**
|
|
@@ -1877,8 +1879,6 @@ var LavalinkNode = class {
|
|
|
1877
1879
|
this.NodeManager.emit("error", this, error);
|
|
1878
1880
|
return this.destroy("NodeReconnectFail" /* NodeReconnectFail */);
|
|
1879
1881
|
}
|
|
1880
|
-
this.socket.removeAllListeners();
|
|
1881
|
-
this.socket = null;
|
|
1882
1882
|
this.NodeManager.emit("reconnecting", this);
|
|
1883
1883
|
this.connect();
|
|
1884
1884
|
this.reconnectAttempts++;
|
|
@@ -1891,16 +1891,42 @@ var LavalinkNode = class {
|
|
|
1891
1891
|
this.NodeManager.emit("error", this, error);
|
|
1892
1892
|
return this.destroy("NodeReconnectFail" /* NodeReconnectFail */);
|
|
1893
1893
|
}
|
|
1894
|
-
this.socket.removeAllListeners();
|
|
1895
|
-
this.socket = null;
|
|
1896
1894
|
this.NodeManager.emit("reconnecting", this);
|
|
1897
1895
|
this.connect();
|
|
1898
1896
|
this.reconnectAttempts++;
|
|
1899
1897
|
}, this.options.retryDelay || 1e3);
|
|
1900
1898
|
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Private function to reset the reconnection attempts
|
|
1901
|
+
* @returns
|
|
1902
|
+
*/
|
|
1903
|
+
resetReconnectionAttempts() {
|
|
1904
|
+
this.reconnectAttempts = 1;
|
|
1905
|
+
clearTimeout(this.reconnectTimeout);
|
|
1906
|
+
this.reconnectTimeout = null;
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* Private function to reset timeouts/intervals for heartbeating/pinging
|
|
1911
|
+
* @param heartbeat
|
|
1912
|
+
* @param ping
|
|
1913
|
+
* @returns
|
|
1914
|
+
*/
|
|
1915
|
+
resetAckTimeouts(heartbeat = true, ping = true) {
|
|
1916
|
+
if (ping) {
|
|
1917
|
+
if (this.pingTimeout) clearTimeout(this.pingTimeout);
|
|
1918
|
+
this.pingTimeout = null;
|
|
1919
|
+
}
|
|
1920
|
+
if (heartbeat) {
|
|
1921
|
+
if (this.heartBeatInterval) clearInterval(this.heartBeatInterval);
|
|
1922
|
+
this.heartBeatInterval = null;
|
|
1923
|
+
}
|
|
1924
|
+
return;
|
|
1925
|
+
}
|
|
1901
1926
|
/** @private util function for handling opening events from websocket */
|
|
1902
1927
|
async open() {
|
|
1903
1928
|
this.isAlive = true;
|
|
1929
|
+
this.resetReconnectionAttempts();
|
|
1904
1930
|
if (this.options.enablePingOnStatsCheck) this.heartBeat();
|
|
1905
1931
|
if (this.heartBeatInterval) clearInterval(this.heartBeatInterval);
|
|
1906
1932
|
if (this.options.heartBeatInterval > 0) {
|
|
@@ -1916,8 +1942,6 @@ var LavalinkNode = class {
|
|
|
1916
1942
|
this.socket.ping();
|
|
1917
1943
|
}, this.options.heartBeatInterval || 3e4);
|
|
1918
1944
|
}
|
|
1919
|
-
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
|
|
1920
|
-
this.reconnectAttempts = 1;
|
|
1921
1945
|
this.info = await this.fetchInfo().catch((e) => (console.error(e, "ON-OPEN-FETCH"), null));
|
|
1922
1946
|
if (!this.info && ["v3", "v4"].includes(this.version)) {
|
|
1923
1947
|
const errorString = `Lavalink Node (${this.restAddress}) does not provide any /${this.version}/info`;
|
|
@@ -1927,8 +1951,22 @@ var LavalinkNode = class {
|
|
|
1927
1951
|
}
|
|
1928
1952
|
/** @private util function for handling closing events from websocket */
|
|
1929
1953
|
close(code, reason) {
|
|
1930
|
-
|
|
1931
|
-
|
|
1954
|
+
this.resetAckTimeouts(true, true);
|
|
1955
|
+
try {
|
|
1956
|
+
if (this.socket) {
|
|
1957
|
+
this.socket.removeAllListeners();
|
|
1958
|
+
this.socket = null;
|
|
1959
|
+
}
|
|
1960
|
+
} catch (e) {
|
|
1961
|
+
if (this.NodeManager?.LavalinkManager?.options?.advancedOptions?.enableDebugEvents) {
|
|
1962
|
+
this.NodeManager.LavalinkManager.emit("debug", "SocketCleanupError" /* SocketCleanupError */, {
|
|
1963
|
+
state: "warn",
|
|
1964
|
+
message: `An error occurred during socket cleanup in close() (likely a race condition): ${e.message}`,
|
|
1965
|
+
functionLayer: "LavalinkNode > close()"
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
this.isAlive = false;
|
|
1932
1970
|
if (code === 1006 && !reason) reason = "Socket got terminated due to no ping connection";
|
|
1933
1971
|
if (code === 1e3 && reason === "Node-Disconnect") return;
|
|
1934
1972
|
this.NodeManager.emit("disconnect", this, { code, reason });
|
|
@@ -2013,6 +2051,7 @@ var LavalinkNode = class {
|
|
|
2013
2051
|
this.handleEvent(payload);
|
|
2014
2052
|
break;
|
|
2015
2053
|
case "ready":
|
|
2054
|
+
this.resetReconnectionAttempts();
|
|
2016
2055
|
this.sessionId = payload.sessionId;
|
|
2017
2056
|
this.resuming.enabled = payload.resumed;
|
|
2018
2057
|
if (payload.resumed === true) {
|
|
@@ -2691,13 +2730,19 @@ var bandCampSearch = async (player, query, requestUser) => {
|
|
|
2691
2730
|
"Cookie": "$Version=1"
|
|
2692
2731
|
}
|
|
2693
2732
|
});
|
|
2694
|
-
|
|
2733
|
+
if (!data.ok) throw new Error(`Bandcamp Error: ${data.statusText}`);
|
|
2734
|
+
let json = null;
|
|
2735
|
+
try {
|
|
2736
|
+
json = await data.json();
|
|
2737
|
+
} catch {
|
|
2738
|
+
throw new Error("Invalid JSON response from Bandcamp");
|
|
2739
|
+
}
|
|
2695
2740
|
tracks = json?.results?.filter((x) => !!x && typeof x === "object" && "type" in x && x.type === "t").map?.((item) => player.LavalinkManager.utils.buildUnresolvedTrack({
|
|
2696
2741
|
uri: item.url || item.uri,
|
|
2697
2742
|
artworkUrl: item.img,
|
|
2698
2743
|
author: item.band_name,
|
|
2699
2744
|
title: item.name,
|
|
2700
|
-
identifier: item.id ? `${item.id}` : item.url?.split("/")
|
|
2745
|
+
identifier: item.id ? `${item.id}` : item.url?.split("/")?.reverse()[0]
|
|
2701
2746
|
}, requestUser));
|
|
2702
2747
|
} catch (e) {
|
|
2703
2748
|
error = e;
|
|
@@ -2906,15 +2951,15 @@ var FilterManager = class {
|
|
|
2906
2951
|
const lavalinkFilterData = this.data.pluginFilters?.["lavalink-filter-plugin"] || { echo: { decay: this.data.pluginFilters?.echo?.decay && !this.data.pluginFilters?.echo?.echoLength ? this.data.pluginFilters.echo.decay : 0, delay: this.data.pluginFilters?.echo?.delay || 0 }, reverb: { gains: [], delays: [], ...this.data.pluginFilters.reverb } };
|
|
2907
2952
|
this.filters.lavalinkFilterPlugin.echo = lavalinkFilterData.echo.decay !== 0 || lavalinkFilterData.echo.delay !== 0;
|
|
2908
2953
|
this.filters.lavalinkFilterPlugin.reverb = lavalinkFilterData.reverb?.delays?.length !== 0 || lavalinkFilterData.reverb?.gains?.length !== 0;
|
|
2909
|
-
this.filters.lavalinkLavaDspxPlugin.highPass = Object.values(this.data.pluginFilters["high-pass"] || {}).length > 0;
|
|
2910
|
-
this.filters.lavalinkLavaDspxPlugin.lowPass = Object.values(this.data.pluginFilters["low-pass"] || {}).length > 0;
|
|
2911
|
-
this.filters.lavalinkLavaDspxPlugin.normalization = Object.values(this.data.pluginFilters
|
|
2912
|
-
this.filters.lavalinkLavaDspxPlugin.echo = Object.values(this.data.pluginFilters
|
|
2913
|
-
this.filters.lowPass = this.data.lowPass
|
|
2914
|
-
this.filters.karaoke = Object.values(this.data.karaoke).some((v) => v !== 0);
|
|
2954
|
+
this.filters.lavalinkLavaDspxPlugin.highPass = Object.values(this.data.pluginFilters?.["high-pass"] || {}).length > 0;
|
|
2955
|
+
this.filters.lavalinkLavaDspxPlugin.lowPass = Object.values(this.data.pluginFilters?.["low-pass"] || {}).length > 0;
|
|
2956
|
+
this.filters.lavalinkLavaDspxPlugin.normalization = Object.values(this.data.pluginFilters?.normalization || {}).length > 0;
|
|
2957
|
+
this.filters.lavalinkLavaDspxPlugin.echo = Object.values(this.data.pluginFilters?.echo || {}).length > 0 && typeof this.data.pluginFilters?.echo?.delay === "undefined";
|
|
2958
|
+
this.filters.lowPass = this.privateNot0(this.data.lowPass?.smoothing);
|
|
2959
|
+
this.filters.karaoke = Object.values(this.data.karaoke ?? {}).some((v) => v !== 0);
|
|
2915
2960
|
if ((this.filters.nightcore || this.filters.vaporwave) && oldFilterTimescale) {
|
|
2916
|
-
if (oldFilterTimescale.pitch !== this.data.timescale
|
|
2917
|
-
this.filters.custom = Object.values(this.data.timescale).some((v) => v !== 1);
|
|
2961
|
+
if (oldFilterTimescale.pitch !== this.data.timescale?.pitch || oldFilterTimescale.rate !== this.data.timescale?.rate || oldFilterTimescale.speed !== this.data.timescale?.speed) {
|
|
2962
|
+
this.filters.custom = Object.values(this.data.timescale || {}).some((v) => v !== 1);
|
|
2918
2963
|
this.filters.nightcore = false;
|
|
2919
2964
|
this.filters.vaporwave = false;
|
|
2920
2965
|
}
|
|
@@ -3727,8 +3772,11 @@ var Queue = class {
|
|
|
3727
3772
|
this.queueChanges.tracksAdd(this.guildId, (Array.isArray(TrackOrTracks) ? TrackOrTracks : [TrackOrTracks]).flat(2).filter((v) => this.managerUtils.isTrack(v) || this.managerUtils.isUnresolvedTrack(v)), index, oldStored, this.utils.toJSON());
|
|
3728
3773
|
} catch {
|
|
3729
3774
|
}
|
|
3730
|
-
|
|
3731
|
-
|
|
3775
|
+
const spliced = TrackOrTracks ? this.tracks.splice(
|
|
3776
|
+
index,
|
|
3777
|
+
amount,
|
|
3778
|
+
...(Array.isArray(TrackOrTracks) ? TrackOrTracks : [TrackOrTracks]).flat(2).filter((v) => this.managerUtils.isTrack(v) || this.managerUtils.isUnresolvedTrack(v))
|
|
3779
|
+
) : this.tracks.splice(index, amount);
|
|
3732
3780
|
if (typeof this.queueChanges?.tracksRemoved === "function") try {
|
|
3733
3781
|
this.queueChanges.tracksRemoved(this.guildId, spliced, index, oldStored, this.utils.toJSON());
|
|
3734
3782
|
} catch {
|
|
@@ -3741,6 +3789,7 @@ var Queue = class {
|
|
|
3741
3789
|
* - single Track | UnresolvedTrack
|
|
3742
3790
|
* - multiple Track | UnresovedTrack
|
|
3743
3791
|
* - at the index or multiple indexes
|
|
3792
|
+
* - Since v2.7 the removed tracks get unshifted into the previous queue state instead of pushed (indexed at the start instead of end - as it should)
|
|
3744
3793
|
* @param removeQueryTrack
|
|
3745
3794
|
* @returns null (if nothing was removed) / { removed } where removed is an array with all removed elements
|
|
3746
3795
|
*
|
|
@@ -3786,9 +3835,10 @@ var Queue = class {
|
|
|
3786
3835
|
if (Array.isArray(removeQueryTrack)) {
|
|
3787
3836
|
if (removeQueryTrack.every((v) => typeof v === "number")) {
|
|
3788
3837
|
const removed3 = [];
|
|
3789
|
-
|
|
3838
|
+
const sortedIndexes = removeQueryTrack.sort((a, b) => b - a);
|
|
3839
|
+
for (const i of sortedIndexes) {
|
|
3790
3840
|
if (this.tracks[i]) {
|
|
3791
|
-
removed3.
|
|
3841
|
+
removed3.unshift(...this.tracks.splice(i, 1));
|
|
3792
3842
|
}
|
|
3793
3843
|
}
|
|
3794
3844
|
if (!removed3.length) return null;
|
|
@@ -3804,9 +3854,10 @@ var Queue = class {
|
|
|
3804
3854
|
));
|
|
3805
3855
|
if (!tracksToRemove.length) return null;
|
|
3806
3856
|
const removed2 = [];
|
|
3857
|
+
tracksToRemove.sort((a, b) => b.i - a.i);
|
|
3807
3858
|
for (const { i } of tracksToRemove) {
|
|
3808
3859
|
if (this.tracks[i]) {
|
|
3809
|
-
removed2.
|
|
3860
|
+
removed2.unshift(...this.tracks.splice(i, 1));
|
|
3810
3861
|
}
|
|
3811
3862
|
}
|
|
3812
3863
|
if (typeof this.queueChanges?.tracksRemoved === "function") try {
|
|
@@ -4029,7 +4080,7 @@ var Player = class {
|
|
|
4029
4080
|
this.queue.current = options.clientTrack || null;
|
|
4030
4081
|
this.queue.utils.save();
|
|
4031
4082
|
if (typeof options?.volume === "number" && !isNaN(options?.volume)) {
|
|
4032
|
-
this.volume = Math.max(Math.min(options?.volume,
|
|
4083
|
+
this.volume = Math.max(Math.min(options?.volume, 1e3), 0);
|
|
4033
4084
|
let vol = Number(this.volume);
|
|
4034
4085
|
if (this.LavalinkManager.options.playerOptions.volumeDecrementer) vol *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
4035
4086
|
this.lavalinkVolume = Math.round(vol);
|
|
@@ -4099,7 +4150,7 @@ var Player = class {
|
|
|
4099
4150
|
}
|
|
4100
4151
|
if (!this.queue.current) throw new Error(`There is no Track in the Queue, nor provided in the PlayOptions`);
|
|
4101
4152
|
if (typeof options?.volume === "number" && !isNaN(options?.volume)) {
|
|
4102
|
-
this.volume = Math.max(Math.min(options?.volume,
|
|
4153
|
+
this.volume = Math.max(Math.min(options?.volume, 1e3), 0);
|
|
4103
4154
|
let vol = Number(this.volume);
|
|
4104
4155
|
if (this.LavalinkManager.options.playerOptions.volumeDecrementer) vol *= this.LavalinkManager.options.playerOptions.volumeDecrementer;
|
|
4105
4156
|
this.lavalinkVolume = Math.round(vol);
|
|
@@ -4122,9 +4173,9 @@ var Player = class {
|
|
|
4122
4173
|
paused: options?.paused ?? void 0,
|
|
4123
4174
|
voice: options?.voice ?? void 0
|
|
4124
4175
|
}).filter((v) => typeof v[1] !== "undefined"));
|
|
4125
|
-
if (typeof finalOptions.position !== "undefined" && isNaN(finalOptions.position) || typeof finalOptions.position === "number" &&
|
|
4176
|
+
if (typeof finalOptions.position !== "undefined" && isNaN(finalOptions.position) || typeof finalOptions.position === "number" && finalOptions.position < 0 || typeof finalOptions.position === "number" && this.queue.current.info.duration > 0 && finalOptions.position >= this.queue.current.info.duration) throw new Error("PlayerOption#position must be a positive number, less than track's duration");
|
|
4126
4177
|
if (typeof finalOptions.volume !== "undefined" && isNaN(finalOptions.volume) || typeof finalOptions.volume === "number" && finalOptions.volume < 0) throw new Error("PlayerOption#volume must be a positive number");
|
|
4127
|
-
if (typeof finalOptions.endTime !== "undefined" && isNaN(finalOptions.endTime) || typeof finalOptions.endTime === "number" &&
|
|
4178
|
+
if (typeof finalOptions.endTime !== "undefined" && isNaN(finalOptions.endTime) || typeof finalOptions.endTime === "number" && finalOptions.endTime < 0 || typeof finalOptions.endTime === "number" && this.queue.current.info.duration > 0 && finalOptions.endTime >= this.queue.current.info.duration) throw new Error("PlayerOption#endTime must be a positive number, less than track's duration");
|
|
4128
4179
|
if (typeof finalOptions.position === "number" && typeof finalOptions.endTime === "number" && finalOptions.endTime < finalOptions.position) throw new Error("PlayerOption#endTime must be bigger than PlayerOption#position");
|
|
4129
4180
|
const now = performance.now();
|
|
4130
4181
|
await this.node.updatePlayer({
|
|
@@ -4199,7 +4250,7 @@ var Player = class {
|
|
|
4199
4250
|
*/
|
|
4200
4251
|
async search(query, requestUser, throwOnEmpty = false) {
|
|
4201
4252
|
const Query = this.LavalinkManager.utils.transformQuery(query);
|
|
4202
|
-
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info
|
|
4253
|
+
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info?.sourceManagers.includes("bandcamp")) {
|
|
4203
4254
|
if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
4204
4255
|
this.LavalinkManager.emit("debug", "BandcampSearchLokalEngine" /* BandcampSearchLokalEngine */, {
|
|
4205
4256
|
state: "log",
|
|
@@ -4290,6 +4341,7 @@ var Player = class {
|
|
|
4290
4341
|
else this.set("internal_autoplayStopPlaying", void 0);
|
|
4291
4342
|
const now = performance.now();
|
|
4292
4343
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { track: { encoded: null } } });
|
|
4344
|
+
this.paused = false;
|
|
4293
4345
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
4294
4346
|
return this;
|
|
4295
4347
|
}
|
|
@@ -4454,7 +4506,7 @@ var Player = class {
|
|
|
4454
4506
|
if (this.queue.current || this.queue.tracks.length) {
|
|
4455
4507
|
const trackSources = new Set([this.queue.current, ...this.queue.tracks].map((track) => track.info.sourceName));
|
|
4456
4508
|
const missingSources = [...trackSources].filter(
|
|
4457
|
-
(source) => !updateNode.info
|
|
4509
|
+
(source) => !updateNode.info?.sourceManagers.includes(source)
|
|
4458
4510
|
);
|
|
4459
4511
|
if (missingSources.length)
|
|
4460
4512
|
throw new RangeError(`Sources missing for Node ${updateNode.id}: ${missingSources.join(", ")}`);
|
|
@@ -4876,7 +4928,7 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4876
4928
|
deletePlayer(guildId) {
|
|
4877
4929
|
const oldPlayer = this.getPlayer(guildId);
|
|
4878
4930
|
if (!oldPlayer) return;
|
|
4879
|
-
if (oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
4931
|
+
if (typeof oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
4880
4932
|
if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError) throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${safeStringify(oldPlayer.toJSON?.())}`);
|
|
4881
4933
|
else if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
4882
4934
|
this.emit("debug", "PlayerDeleteInsteadOfDestroy" /* PlayerDeleteInsteadOfDestroy */, {
|
|
@@ -5092,6 +5144,7 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5092
5144
|
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)}`);
|
|
5093
5145
|
}
|
|
5094
5146
|
player.voiceChannelId = update.channel_id;
|
|
5147
|
+
player.options.voiceChannelId = update.channel_id;
|
|
5095
5148
|
const selfMuteChanged = typeof update.self_mute === "boolean" && player.voiceState.selfMute !== update.self_mute;
|
|
5096
5149
|
const serverMuteChanged = typeof update.mute === "boolean" && player.voiceState.serverMute !== update.mute;
|
|
5097
5150
|
const selfDeafChanged = typeof update.self_deaf === "boolean" && player.voiceState.selfDeaf !== update.self_deaf;
|
|
@@ -5134,11 +5187,14 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
5134
5187
|
if (player.queue.tracks.length) {
|
|
5135
5188
|
return void await player.play({ paused: previousPaused });
|
|
5136
5189
|
}
|
|
5137
|
-
this.
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5190
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
5191
|
+
this.emit("debug", "PlayerAutoReconnect" /* PlayerAutoReconnect */, {
|
|
5192
|
+
state: "log",
|
|
5193
|
+
message: `Auto reconnected, but nothing to play`,
|
|
5194
|
+
functionLayer: "LavalinkManager > sendRawData()"
|
|
5195
|
+
});
|
|
5196
|
+
}
|
|
5197
|
+
return;
|
|
5142
5198
|
} catch (e) {
|
|
5143
5199
|
console.error(e);
|
|
5144
5200
|
return void await player.destroy("PlayerReconnectFail" /* PlayerReconnectFail */);
|