magmastream 2.10.6-alpha.4 → 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 +21 -45
- 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
|
}
|
|
@@ -1170,7 +1154,7 @@ class Node {
|
|
|
1170
1154
|
* @param {string} guildId - The ID of the guild to subscribe to lyrics for.
|
|
1171
1155
|
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
1172
1156
|
* @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
|
|
1173
|
-
* @throws {
|
|
1157
|
+
* @throws {MagmaStreamError} If the node is not connected to the lavalink server or if the lavalyrics-plugin is not available.
|
|
1174
1158
|
*/
|
|
1175
1159
|
async lyricsSubscribe(guildId, skipTrackSource = false) {
|
|
1176
1160
|
if (!this.connected) {
|
|
@@ -1182,23 +1166,7 @@ class Node {
|
|
|
1182
1166
|
}
|
|
1183
1167
|
if (this.isNodeLink)
|
|
1184
1168
|
return await this.rest.post(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource}`, {});
|
|
1185
|
-
|
|
1186
|
-
for (const plugin of requiredPlugins) {
|
|
1187
|
-
if (!(this.info?.plugins ?? []).some((p) => p.name === plugin)) {
|
|
1188
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1189
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1190
|
-
message: `The plugin "${plugin}" must be present in the lavalink node.`,
|
|
1191
|
-
context: { identifier: this.options.identifier },
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
if (!(this.info?.plugins ?? []).some((p) => p.name === "lavasrc-plugin" || p.name === "java-lyrics-plugin")) {
|
|
1196
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1197
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1198
|
-
message: `One of the following plugins must also be present in the lavalink node: "lavasrc-plugin" or "java-lyrics-plugin".`,
|
|
1199
|
-
context: { identifier: this.options.identifier },
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1169
|
+
this.requireAnyPlugin(["lavalyrics-plugin"], "subscribe to lyrics");
|
|
1202
1170
|
try {
|
|
1203
1171
|
return await this.rest.post(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource}`, {});
|
|
1204
1172
|
}
|
|
@@ -1217,7 +1185,7 @@ class Node {
|
|
|
1217
1185
|
* Unsubscribes from lyrics for a player.
|
|
1218
1186
|
* @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
|
|
1219
1187
|
* @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
|
|
1220
|
-
* @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.
|
|
1221
1189
|
*/
|
|
1222
1190
|
async lyricsUnsubscribe(guildId) {
|
|
1223
1191
|
if (!this.connected) {
|
|
@@ -1229,13 +1197,7 @@ class Node {
|
|
|
1229
1197
|
}
|
|
1230
1198
|
if (this.isNodeLink)
|
|
1231
1199
|
return await this.rest.delete(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`);
|
|
1232
|
-
|
|
1233
|
-
throw new MagmastreamError_1.MagmaStreamError({
|
|
1234
|
-
code: Enums_1.MagmaStreamErrorCode.NODE_PLUGIN_ERROR,
|
|
1235
|
-
message: `The plugin "java-lyrics-plugin" must be present in the lavalink node to unsubscribe.`,
|
|
1236
|
-
context: { identifier: this.options.identifier },
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1200
|
+
this.requireAnyPlugin(["lavalyrics-plugin", "java-lyrics-plugin"], "unsubscribe from lyrics");
|
|
1239
1201
|
try {
|
|
1240
1202
|
return await this.rest.delete(`/v4/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`);
|
|
1241
1203
|
}
|
|
@@ -1519,6 +1481,20 @@ class Node {
|
|
|
1519
1481
|
async removeNodeLinkMix(player, mixId) {
|
|
1520
1482
|
return this.removeMix(player, mixId);
|
|
1521
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
|
+
}
|
|
1522
1498
|
assertNodeLinkFeature(action) {
|
|
1523
1499
|
if (this.isNodeLink && this.connected)
|
|
1524
1500
|
return;
|