magmastream 2.10.6-alpha.3 → 2.10.6-alpha.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/structures/Node.d.ts +6 -4
- package/dist/structures/Node.js +28 -48
- package/package.json +1 -1
|
@@ -242,8 +242,8 @@ export declare class Node {
|
|
|
242
242
|
*
|
|
243
243
|
* If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
|
|
244
244
|
*
|
|
245
|
-
* Requires the `lavalyrics-plugin` to be present in the Lavalink node.
|
|
246
|
-
*
|
|
245
|
+
* Requires the `lavalyrics-plugin` to be present in the Lavalink node. The lyrics sources come from
|
|
246
|
+
* whichever plugins register them with LavaLyrics (LavaSrc, PulseLink, java-lyrics, ...).
|
|
247
247
|
*
|
|
248
248
|
* @param {Track} track - The track to fetch the lyrics for.
|
|
249
249
|
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
@@ -283,14 +283,14 @@ export declare class Node {
|
|
|
283
283
|
* @param {string} guildId - The ID of the guild to subscribe to lyrics for.
|
|
284
284
|
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
285
285
|
* @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
|
|
286
|
-
* @throws {
|
|
286
|
+
* @throws {MagmaStreamError} If the node is not connected to the lavalink server or if the lavalyrics-plugin is not available.
|
|
287
287
|
*/
|
|
288
288
|
lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
|
|
289
289
|
/**
|
|
290
290
|
* Unsubscribes from lyrics for a player.
|
|
291
291
|
* @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
|
|
292
292
|
* @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
|
|
293
|
-
* @throws {
|
|
293
|
+
* @throws {MagmaStreamError} If the node is not connected to the lavalink server, or if neither the lavalyrics-plugin nor the java-lyrics-plugin is available.
|
|
294
294
|
*/
|
|
295
295
|
lyricsUnsubscribe(guildId: string): Promise<unknown>;
|
|
296
296
|
/**
|
|
@@ -454,6 +454,8 @@ export declare class Node {
|
|
|
454
454
|
* @returns {Promise<void>}
|
|
455
455
|
*/
|
|
456
456
|
removeNodeLinkMix(player: Player, mixId: string): Promise<void>;
|
|
457
|
+
/** Throws NODE_PLUGIN_ERROR unless the node reports at least one of the given plugins. */
|
|
458
|
+
private requireAnyPlugin;
|
|
457
459
|
private assertNodeLinkFeature;
|
|
458
460
|
private assertMixVolume;
|
|
459
461
|
private assertNodeLinkSponsorBlockUpdate;
|
package/dist/structures/Node.js
CHANGED
|
@@ -1034,8 +1034,8 @@ class Node {
|
|
|
1034
1034
|
*
|
|
1035
1035
|
* If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
|
|
1036
1036
|
*
|
|
1037
|
-
* Requires the `lavalyrics-plugin` to be present in the Lavalink node.
|
|
1038
|
-
*
|
|
1037
|
+
* Requires the `lavalyrics-plugin` to be present in the Lavalink node. The lyrics sources come from
|
|
1038
|
+
* whichever plugins register them with LavaLyrics (LavaSrc, PulseLink, java-lyrics, ...).
|
|
1039
1039
|
*
|
|
1040
1040
|
* @param {Track} track - The track to fetch the lyrics for.
|
|
1041
1041
|
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
@@ -1053,23 +1053,7 @@ class Node {
|
|
|
1053
1053
|
if (this.isNodeLink) {
|
|
1054
1054
|
return (await this.rest.get(`/v4/loadlyrics?encodedTrack=${encodeURIComponent(track.track)}${language ? `&lang=${encodeURIComponent(language)}` : ""}`));
|
|
1055
1055
|
}
|
|
1056
|
-
|
|
1057
|
-
for (const plugin of requiredPlugins) {
|
|
1058
|
-
if (!this.info.plugins.some((p) => p.name === plugin)) {
|
|
1059
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1060
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1061
|
-
message: `The plugin "${plugin}" must be present in the lavalink node.`,
|
|
1062
|
-
context: { identifier: this.options.identifier },
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
if (!this.info.plugins.some((p) => p.name === "lavasrc-plugin" || p.name === "java-lyrics-plugin")) {
|
|
1067
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1068
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1069
|
-
message: `One of the following plugins must also be present in the lavalink node: "lavasrc-plugin" or "java-lyrics-plugin".`,
|
|
1070
|
-
context: { identifier: this.options.identifier },
|
|
1071
|
-
});
|
|
1072
|
-
}
|
|
1056
|
+
this.requireAnyPlugin(["lavalyrics-plugin"], "fetch lyrics");
|
|
1073
1057
|
const lyrics = (await this.rest.get(`/v4/lyrics?track=${encodeURIComponent(track.track)}&skipTrackSource=${skipTrackSource}`));
|
|
1074
1058
|
return lyrics || { sourceName: null, source: null, provider: null, text: null, lines: [], plugin: [] };
|
|
1075
1059
|
}
|
|
@@ -1109,6 +1093,10 @@ class Node {
|
|
|
1109
1093
|
catch (error) {
|
|
1110
1094
|
lastError = error;
|
|
1111
1095
|
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[NODE] Lyrics lookup on node ${this.options.identifier} failed (skipTrackSource=${skip}): ${error instanceof Error ? error.message : String(error)}`);
|
|
1096
|
+
// A missing plugin or a disconnected node fails the same way with skipTrackSource=true.
|
|
1097
|
+
if (error instanceof MagmastreamError_1.MagmaStreamError && (error.code === Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR || error.code === Enums_1.MagmaStreamErrorCode.NODE_DISCONNECTED)) {
|
|
1098
|
+
break;
|
|
1099
|
+
}
|
|
1112
1100
|
}
|
|
1113
1101
|
}
|
|
1114
1102
|
if (lrclibFallback) {
|
|
@@ -1166,7 +1154,7 @@ class Node {
|
|
|
1166
1154
|
* @param {string} guildId - The ID of the guild to subscribe to lyrics for.
|
|
1167
1155
|
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
1168
1156
|
* @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
|
|
1169
|
-
* @throws {
|
|
1157
|
+
* @throws {MagmaStreamError} If the node is not connected to the lavalink server or if the lavalyrics-plugin is not available.
|
|
1170
1158
|
*/
|
|
1171
1159
|
async lyricsSubscribe(guildId, skipTrackSource = false) {
|
|
1172
1160
|
if (!this.connected) {
|
|
@@ -1178,23 +1166,7 @@ class Node {
|
|
|
1178
1166
|
}
|
|
1179
1167
|
if (this.isNodeLink)
|
|
1180
1168
|
return await this.rest.post(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource}`, {});
|
|
1181
|
-
|
|
1182
|
-
for (const plugin of requiredPlugins) {
|
|
1183
|
-
if (!this.info.plugins.some((p) => p.name === plugin)) {
|
|
1184
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1185
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1186
|
-
message: `The plugin "${plugin}" must be present in the lavalink node.`,
|
|
1187
|
-
context: { identifier: this.options.identifier },
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
if (!this.info.plugins.some((p) => p.name === "lavasrc-plugin" || p.name === "java-lyrics-plugin")) {
|
|
1192
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1193
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1194
|
-
message: `One of the following plugins must also be present in the lavalink node: "lavasrc-plugin" or "java-lyrics-plugin".`,
|
|
1195
|
-
context: { identifier: this.options.identifier },
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1169
|
+
this.requireAnyPlugin(["lavalyrics-plugin"], "subscribe to lyrics");
|
|
1198
1170
|
try {
|
|
1199
1171
|
return await this.rest.post(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource}`, {});
|
|
1200
1172
|
}
|
|
@@ -1213,7 +1185,7 @@ class Node {
|
|
|
1213
1185
|
* Unsubscribes from lyrics for a player.
|
|
1214
1186
|
* @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
|
|
1215
1187
|
* @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
|
|
1216
|
-
* @throws {
|
|
1188
|
+
* @throws {MagmaStreamError} If the node is not connected to the lavalink server, or if neither the lavalyrics-plugin nor the java-lyrics-plugin is available.
|
|
1217
1189
|
*/
|
|
1218
1190
|
async lyricsUnsubscribe(guildId) {
|
|
1219
1191
|
if (!this.connected) {
|
|
@@ -1225,13 +1197,7 @@ class Node {
|
|
|
1225
1197
|
}
|
|
1226
1198
|
if (this.isNodeLink)
|
|
1227
1199
|
return await this.rest.delete(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`);
|
|
1228
|
-
|
|
1229
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1230
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1231
|
-
message: `The plugin "java-lyrics-plugin" must be present in the lavalink node to unsubscribe.`,
|
|
1232
|
-
context: { identifier: this.options.identifier },
|
|
1233
|
-
});
|
|
1234
|
-
}
|
|
1200
|
+
this.requireAnyPlugin(["lavalyrics-plugin", "java-lyrics-plugin"], "unsubscribe from lyrics");
|
|
1235
1201
|
try {
|
|
1236
1202
|
return await this.rest.delete(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`);
|
|
1237
1203
|
}
|
|
@@ -1387,7 +1353,7 @@ class Node {
|
|
|
1387
1353
|
});
|
|
1388
1354
|
}
|
|
1389
1355
|
}
|
|
1390
|
-
if (!this.info
|
|
1356
|
+
if (!(this.info?.plugins ?? []).some((plugin) => plugin.name === "sponsorblock-plugin")) {
|
|
1391
1357
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
1392
1358
|
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1393
1359
|
message: `The plugin "sponsorblock-plugin" must be present in the lavalink node to fetch SponsorBlock data.`,
|
|
@@ -1515,6 +1481,20 @@ class Node {
|
|
|
1515
1481
|
async removeNodeLinkMix(player, mixId) {
|
|
1516
1482
|
return this.removeMix(player, mixId);
|
|
1517
1483
|
}
|
|
1484
|
+
/** Throws NODE_PLUGIN_ERROR unless the node reports at least one of the given plugins. */
|
|
1485
|
+
requireAnyPlugin(plugins, action) {
|
|
1486
|
+
const installed = this.info?.plugins ?? [];
|
|
1487
|
+
if (installed.some((plugin) => plugins.includes(plugin.name)))
|
|
1488
|
+
return;
|
|
1489
|
+
const names = plugins.map((plugin) => `"${plugin}"`).join(" or ");
|
|
1490
|
+
throw new MagmastreamError_1.MagmaStreamError({
|
|
1491
|
+
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1492
|
+
message: plugins.length === 1
|
|
1493
|
+
? `The plugin ${names} must be present in the lavalink node to ${action}.`
|
|
1494
|
+
: `One of the following plugins must be present in the lavalink node to ${action}: ${names}.`,
|
|
1495
|
+
context: { identifier: this.options.identifier },
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1518
1498
|
assertNodeLinkFeature(action) {
|
|
1519
1499
|
if (this.isNodeLink && this.connected)
|
|
1520
1500
|
return;
|
|
@@ -1617,7 +1597,7 @@ class Node {
|
|
|
1617
1597
|
});
|
|
1618
1598
|
}
|
|
1619
1599
|
}
|
|
1620
|
-
if (!this.info
|
|
1600
|
+
if (!(this.info?.plugins ?? []).some((plugin) => plugin.name === "sponsorblock-plugin")) {
|
|
1621
1601
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
1622
1602
|
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1623
1603
|
message: `The plugin "sponsorblock-plugin" must be present in the lavalink node to set SponsorBlock segments.`,
|
|
@@ -1661,7 +1641,7 @@ class Node {
|
|
|
1661
1641
|
});
|
|
1662
1642
|
}
|
|
1663
1643
|
}
|
|
1664
|
-
if (!this.info
|
|
1644
|
+
if (!(this.info?.plugins ?? []).some((plugin) => plugin.name === "sponsorblock-plugin")) {
|
|
1665
1645
|
throw new MagmastreamError_1.MagmaStreamError({
|
|
1666
1646
|
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1667
1647
|
message: `The plugin "sponsorblock-plugin" must be present in the lavalink node to delete SponsorBlock segments.`,
|