lavalink-client 2.3.4 → 2.3.6
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 +225 -2
- package/dist/cjs/index.d.ts +16 -16
- package/dist/cjs/index.js +16 -16
- package/dist/cjs/structures/Constants.d.ts +2 -1
- package/dist/cjs/structures/Constants.js +1 -0
- package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/cjs/structures/Filters.d.ts +2 -2
- package/dist/cjs/structures/Filters.js +1 -1
- package/dist/cjs/structures/LavalinkManager.d.ts +6 -6
- package/dist/cjs/structures/LavalinkManager.js +5 -5
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +3 -1
- package/dist/cjs/structures/LavalinkManagerStatics.js +11 -2
- package/dist/cjs/structures/Node.d.ts +86 -6
- package/dist/cjs/structures/Node.js +147 -3
- package/dist/cjs/structures/NodeManager.d.ts +4 -4
- package/dist/cjs/structures/NodeManager.js +3 -3
- package/dist/cjs/structures/Player.d.ts +53 -10
- package/dist/cjs/structures/Player.js +55 -5
- package/dist/cjs/structures/Queue.d.ts +3 -3
- package/dist/cjs/structures/Queue.js +1 -1
- package/dist/cjs/structures/Types/Filters.d.ts +1 -1
- package/dist/cjs/structures/Types/Manager.d.ts +25 -7
- package/dist/cjs/structures/Types/Node.d.ts +26 -3
- package/dist/cjs/structures/Types/Player.d.ts +5 -5
- package/dist/cjs/structures/Types/Queue.d.ts +1 -1
- package/dist/cjs/structures/Types/Track.d.ts +3 -3
- package/dist/cjs/structures/Types/Utils.d.ts +68 -10
- package/dist/cjs/structures/Utils.d.ts +6 -6
- package/dist/cjs/structures/Utils.js +11 -2
- package/dist/esm/index.d.ts +16 -16
- package/dist/esm/index.js +16 -16
- package/dist/esm/structures/Constants.d.ts +2 -1
- package/dist/esm/structures/Constants.js +1 -0
- package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/esm/structures/Filters.d.ts +2 -2
- package/dist/esm/structures/Filters.js +1 -1
- package/dist/esm/structures/LavalinkManager.d.ts +6 -6
- package/dist/esm/structures/LavalinkManager.js +5 -5
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +3 -1
- package/dist/esm/structures/LavalinkManagerStatics.js +11 -2
- package/dist/esm/structures/Node.d.ts +86 -6
- package/dist/esm/structures/Node.js +147 -3
- package/dist/esm/structures/NodeManager.d.ts +4 -4
- package/dist/esm/structures/NodeManager.js +3 -3
- package/dist/esm/structures/Player.d.ts +53 -10
- package/dist/esm/structures/Player.js +55 -5
- package/dist/esm/structures/Queue.d.ts +3 -3
- package/dist/esm/structures/Queue.js +1 -1
- package/dist/esm/structures/Types/Filters.d.ts +1 -1
- package/dist/esm/structures/Types/Manager.d.ts +25 -7
- package/dist/esm/structures/Types/Node.d.ts +26 -3
- package/dist/esm/structures/Types/Player.d.ts +5 -5
- package/dist/esm/structures/Types/Queue.d.ts +1 -1
- package/dist/esm/structures/Types/Track.d.ts +3 -3
- package/dist/esm/structures/Types/Utils.d.ts +68 -10
- package/dist/esm/structures/Utils.d.ts +6 -6
- package/dist/esm/structures/Utils.js +11 -2
- package/dist/types/structures/Constants.d.ts +1 -0
- package/dist/types/structures/LavalinkManagerStatics.d.ts +2 -0
- package/dist/types/structures/Node.d.ts +81 -1
- package/dist/types/structures/Player.d.ts +43 -0
- package/dist/types/structures/Types/Manager.d.ts +19 -1
- package/dist/types/structures/Types/Node.d.ts +23 -0
- package/dist/types/structures/Types/Utils.d.ts +64 -6
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LavalinkNodeOptions } from "./Types/Node";
|
|
2
|
-
import type { LavalinkSearchPlatform, LavaSearchQuery, MiniMapConstructor, SearchPlatform, SearchQuery } from "./Types/Utils";
|
|
3
|
-
import type { LavalinkManager } from "./LavalinkManager";
|
|
4
|
-
import type { LavalinkNode } from "./Node";
|
|
5
|
-
import type { Player } from "./Player";
|
|
6
|
-
import type { LavalinkTrack, Track, UnresolvedQuery, UnresolvedTrack } from "./Types/Track";
|
|
1
|
+
import type { LavalinkNodeOptions } from "./Types/Node.js";
|
|
2
|
+
import type { LavalinkSearchPlatform, LavaSearchQuery, MiniMapConstructor, SearchPlatform, SearchQuery } from "./Types/Utils.js";
|
|
3
|
+
import type { LavalinkManager } from "./LavalinkManager.js";
|
|
4
|
+
import type { LavalinkNode } from "./Node.js";
|
|
5
|
+
import type { Player } from "./Player.js";
|
|
6
|
+
import type { LavalinkTrack, Track, UnresolvedQuery, UnresolvedTrack } from "./Types/Track.js";
|
|
7
7
|
export declare const TrackSymbol: unique symbol;
|
|
8
8
|
export declare const UnresolvedTrackSymbol: unique symbol;
|
|
9
9
|
export declare const QueueSymbol: unique symbol;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.queueTrackEnd = exports.MiniMap = exports.ManagerUtils = exports.parseLavalinkConnUrl = exports.NodeSymbol = exports.QueueSymbol = exports.UnresolvedTrackSymbol = exports.TrackSymbol = void 0;
|
|
4
4
|
const node_url_1 = require("node:url");
|
|
5
5
|
const types_1 = require("node:util/types");
|
|
6
|
-
const Constants_1 = require("./Constants");
|
|
7
|
-
const LavalinkManagerStatics_1 = require("./LavalinkManagerStatics");
|
|
6
|
+
const Constants_1 = require("./Constants.js");
|
|
7
|
+
const LavalinkManagerStatics_1 = require("./LavalinkManagerStatics.js");
|
|
8
8
|
exports.TrackSymbol = Symbol("LC-Track");
|
|
9
9
|
exports.UnresolvedTrackSymbol = Symbol("LC-Track-Unresolved");
|
|
10
10
|
exports.QueueSymbol = Symbol("LC-Queue");
|
|
@@ -306,6 +306,9 @@ class ManagerUtils {
|
|
|
306
306
|
if (LavalinkManagerStatics_1.SourceLinksRegexes.musicYandex.test(queryString) && !node.info?.sourceManagers?.includes("yandexmusic")) {
|
|
307
307
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'yandexmusic' enabled");
|
|
308
308
|
}
|
|
309
|
+
if (LavalinkManagerStatics_1.SourceLinksRegexes.jiosaavn.test(queryString) && !node.info?.sourceManagers?.includes("jiosaavn")) {
|
|
310
|
+
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'jiosaavn' (via jiosaavn-plugin) enabled");
|
|
311
|
+
}
|
|
309
312
|
return;
|
|
310
313
|
}
|
|
311
314
|
transformQuery(query) {
|
|
@@ -361,6 +364,12 @@ class ManagerUtils {
|
|
|
361
364
|
if (source === "dzsearch" && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
362
365
|
throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'dzsearch' to work");
|
|
363
366
|
}
|
|
367
|
+
if (source === "jsrec" && !node.info?.sourceManagers?.includes("jiosaavn")) {
|
|
368
|
+
throw new Error("Lavalink Node has not 'jiosaavn' (via jiosaavn-plugin) enabled, which is required to have 'jsrec' to work");
|
|
369
|
+
}
|
|
370
|
+
if (source === "jssearch" && !node.info?.sourceManagers?.includes("jiosaavn")) {
|
|
371
|
+
throw new Error("Lavalink Node has not 'jiosaavn' (via jiosaavn-plugin) enabled, which is required to have 'jssearch' to work");
|
|
372
|
+
}
|
|
364
373
|
if (source === "scsearch" && !node.info?.sourceManagers?.includes("soundcloud")) {
|
|
365
374
|
throw new Error("Lavalink Node has not 'soundcloud' enabled, which is required to have 'scsearch' work");
|
|
366
375
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from "./structures/LavalinkManager";
|
|
2
|
-
export * from "./structures/Filters";
|
|
3
|
-
export * from "./structures/LavalinkManagerStatics";
|
|
4
|
-
export * from "./structures/Node";
|
|
5
|
-
export * from "./structures/NodeManager";
|
|
6
|
-
export * from "./structures/Player";
|
|
7
|
-
export * from "./structures/Queue";
|
|
8
|
-
export * from "./structures/Utils";
|
|
9
|
-
export * from "./structures/Types/Track";
|
|
10
|
-
export * from "./structures/Types/Utils";
|
|
11
|
-
export * from "./structures/Types/Filters";
|
|
12
|
-
export * from "./structures/Types/Player";
|
|
13
|
-
export * from "./structures/Types/Queue";
|
|
14
|
-
export * from "./structures/Types/Node";
|
|
15
|
-
export * from "./structures/Constants";
|
|
16
|
-
export * from "./structures/Types/Manager";
|
|
1
|
+
export * from "./structures/LavalinkManager.js";
|
|
2
|
+
export * from "./structures/Filters.js";
|
|
3
|
+
export * from "./structures/LavalinkManagerStatics.js";
|
|
4
|
+
export * from "./structures/Node.js";
|
|
5
|
+
export * from "./structures/NodeManager.js";
|
|
6
|
+
export * from "./structures/Player.js";
|
|
7
|
+
export * from "./structures/Queue.js";
|
|
8
|
+
export * from "./structures/Utils.js";
|
|
9
|
+
export * from "./structures/Types/Track.js";
|
|
10
|
+
export * from "./structures/Types/Utils.js";
|
|
11
|
+
export * from "./structures/Types/Filters.js";
|
|
12
|
+
export * from "./structures/Types/Player.js";
|
|
13
|
+
export * from "./structures/Types/Queue.js";
|
|
14
|
+
export * from "./structures/Types/Node.js";
|
|
15
|
+
export * from "./structures/Constants.js";
|
|
16
|
+
export * from "./structures/Types/Manager.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export * from "./structures/LavalinkManager";
|
|
2
|
-
export * from "./structures/Filters";
|
|
3
|
-
export * from "./structures/LavalinkManagerStatics";
|
|
4
|
-
export * from "./structures/Node";
|
|
5
|
-
export * from "./structures/NodeManager";
|
|
6
|
-
export * from "./structures/Player";
|
|
7
|
-
export * from "./structures/Queue";
|
|
8
|
-
export * from "./structures/Utils";
|
|
9
|
-
export * from "./structures/Types/Track";
|
|
10
|
-
export * from "./structures/Types/Utils";
|
|
11
|
-
export * from "./structures/Types/Filters";
|
|
12
|
-
export * from "./structures/Types/Player";
|
|
13
|
-
export * from "./structures/Types/Queue";
|
|
14
|
-
export * from "./structures/Types/Node";
|
|
15
|
-
export * from "./structures/Constants";
|
|
16
|
-
export * from "./structures/Types/Manager";
|
|
1
|
+
export * from "./structures/LavalinkManager.js";
|
|
2
|
+
export * from "./structures/Filters.js";
|
|
3
|
+
export * from "./structures/LavalinkManagerStatics.js";
|
|
4
|
+
export * from "./structures/Node.js";
|
|
5
|
+
export * from "./structures/NodeManager.js";
|
|
6
|
+
export * from "./structures/Player.js";
|
|
7
|
+
export * from "./structures/Queue.js";
|
|
8
|
+
export * from "./structures/Utils.js";
|
|
9
|
+
export * from "./structures/Types/Track.js";
|
|
10
|
+
export * from "./structures/Types/Utils.js";
|
|
11
|
+
export * from "./structures/Types/Filters.js";
|
|
12
|
+
export * from "./structures/Types/Player.js";
|
|
13
|
+
export * from "./structures/Types/Queue.js";
|
|
14
|
+
export * from "./structures/Types/Node.js";
|
|
15
|
+
export * from "./structures/Constants.js";
|
|
16
|
+
export * from "./structures/Types/Manager.js";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters";
|
|
1
|
+
import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters.js";
|
|
2
2
|
export declare enum DebugEvents {
|
|
3
3
|
SetSponsorBlock = "SetSponsorBlock",
|
|
4
4
|
DeleteSponsorBlock = "DeleteSponsorBlock",
|
|
5
5
|
TrackEndReplaced = "TrackEndReplaced",
|
|
6
|
+
AutoplayExecution = "AutoplayExecution",
|
|
6
7
|
AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
|
|
7
8
|
AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
|
|
8
9
|
TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
|
|
@@ -3,6 +3,7 @@ export var DebugEvents;
|
|
|
3
3
|
DebugEvents["SetSponsorBlock"] = "SetSponsorBlock";
|
|
4
4
|
DebugEvents["DeleteSponsorBlock"] = "DeleteSponsorBlock";
|
|
5
5
|
DebugEvents["TrackEndReplaced"] = "TrackEndReplaced";
|
|
6
|
+
DebugEvents["AutoplayExecution"] = "AutoplayExecution";
|
|
6
7
|
DebugEvents["AutoplayNoSongsAdded"] = "AutoplayNoSongsAdded";
|
|
7
8
|
DebugEvents["AutoplayThresholdSpamLimiter"] = "AutoplayThresholdSpamLimiter";
|
|
8
9
|
DebugEvents["TriggerQueueEmptyInterval"] = "TriggerQueueEmptyInterval";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Player } from "../Player";
|
|
2
|
-
import type { UnresolvedSearchResult } from "../Types/Utils";
|
|
1
|
+
import type { Player } from "../Player.js";
|
|
2
|
+
import type { UnresolvedSearchResult } from "../Types/Utils.js";
|
|
3
3
|
export declare const bandCampSearch: (player: Player, query: string, requestUser: unknown) => Promise<UnresolvedSearchResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Player } from "./Player";
|
|
2
|
-
import type { AudioOutputs, EQBand, FilterData, PlayerFilters, TimescaleFilter } from "./Types/Filters";
|
|
1
|
+
import type { Player } from "./Player.js";
|
|
2
|
+
import type { AudioOutputs, EQBand, FilterData, PlayerFilters, TimescaleFilter } from "./Types/Filters.js";
|
|
3
3
|
/**
|
|
4
4
|
* The FilterManager for each player
|
|
5
5
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
|
-
import { NodeManager } from "./NodeManager";
|
|
4
|
-
import { Player } from "./Player";
|
|
5
|
-
import { ManagerUtils, MiniMap } from "./Utils";
|
|
6
|
-
import type { BotClientOptions, LavalinkManagerEvents, ManagerOptions } from "./Types/Manager";
|
|
7
|
-
import type { PlayerOptions } from "./Types/Player";
|
|
8
|
-
import type { ChannelDeletePacket, VoicePacket, VoiceServer, VoiceState } from "./Types/Utils";
|
|
3
|
+
import { NodeManager } from "./NodeManager.js";
|
|
4
|
+
import { Player } from "./Player.js";
|
|
5
|
+
import { ManagerUtils, MiniMap } from "./Utils.js";
|
|
6
|
+
import type { BotClientOptions, LavalinkManagerEvents, ManagerOptions } from "./Types/Manager.js";
|
|
7
|
+
import type { PlayerOptions } from "./Types/Player.js";
|
|
8
|
+
import type { ChannelDeletePacket, VoicePacket, VoiceServer, VoiceState } from "./Types/Utils.js";
|
|
9
9
|
export declare class LavalinkManager extends EventEmitter {
|
|
10
10
|
/**
|
|
11
11
|
* Emit an event
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { DebugEvents, DestroyReasons } from "./Constants";
|
|
3
|
-
import { NodeManager } from "./NodeManager";
|
|
4
|
-
import { Player } from "./Player";
|
|
5
|
-
import { DefaultQueueStore } from "./Queue";
|
|
6
|
-
import { ManagerUtils, MiniMap } from "./Utils";
|
|
2
|
+
import { DebugEvents, DestroyReasons } from "./Constants.js";
|
|
3
|
+
import { NodeManager } from "./NodeManager.js";
|
|
4
|
+
import { Player } from "./Player.js";
|
|
5
|
+
import { DefaultQueueStore } from "./Queue.js";
|
|
6
|
+
import { ManagerUtils, MiniMap } from "./Utils.js";
|
|
7
7
|
export class LavalinkManager extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* Emit an event
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Types/Utils";
|
|
1
|
+
import type { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Types/Utils.js";
|
|
2
2
|
/** Default Sources Record, to allow source parsing with multiple inputs. */
|
|
3
3
|
export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
|
|
4
4
|
/** Lavalink Plugins definiton */
|
|
@@ -7,7 +7,9 @@ export declare const LavalinkPlugins: {
|
|
|
7
7
|
LavaSrc: string;
|
|
8
8
|
GoogleCloudTTS: string;
|
|
9
9
|
LavaSearch: string;
|
|
10
|
+
Jiosaavn_Plugin: string;
|
|
10
11
|
LavalinkFilterPlugin: string;
|
|
12
|
+
JavaTimedLyricsPlugin: string;
|
|
11
13
|
};
|
|
12
14
|
/** Lavalink Sources regexes for url validations */
|
|
13
15
|
export declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|
|
@@ -62,7 +62,12 @@ export const DefaultSources = {
|
|
|
62
62
|
"http": "http",
|
|
63
63
|
"https": "https",
|
|
64
64
|
"link": "link",
|
|
65
|
-
"uri": "uri"
|
|
65
|
+
"uri": "uri",
|
|
66
|
+
// jiosaavn
|
|
67
|
+
"jiosaavn": "jssearch",
|
|
68
|
+
"js": "jssearch",
|
|
69
|
+
"jssearch": "jssearch",
|
|
70
|
+
"jsrec": "jsrec"
|
|
66
71
|
};
|
|
67
72
|
/** Lavalink Plugins definiton */
|
|
68
73
|
export const LavalinkPlugins = {
|
|
@@ -70,7 +75,9 @@ export const LavalinkPlugins = {
|
|
|
70
75
|
LavaSrc: "lavasrc-plugin",
|
|
71
76
|
GoogleCloudTTS: "tts-plugin",
|
|
72
77
|
LavaSearch: "lavasearch-plugin",
|
|
73
|
-
|
|
78
|
+
Jiosaavn_Plugin: "jiosaavn-plugin",
|
|
79
|
+
LavalinkFilterPlugin: "lavalink-filter-plugin",
|
|
80
|
+
JavaTimedLyricsPlugin: "java-lyrics-plugin"
|
|
74
81
|
};
|
|
75
82
|
/** Lavalink Sources regexes for url validations */
|
|
76
83
|
export const SourceLinksRegexes = {
|
|
@@ -108,6 +115,8 @@ export const SourceLinksRegexes = {
|
|
|
108
115
|
SpotifyAlbumRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?album\/(?<identifier>[a-zA-Z0-9-_]+)/,
|
|
109
116
|
AllSpotifyRegex: /(https?:\/\/)(www\.)?open\.spotify\.com\/((?<region>[a-zA-Z-]+)\/)?(user\/(?<user>[a-zA-Z0-9-_]+)\/)?(?<type>track|album|playlist|artist|episode|show)\/(?<identifier>[a-zA-Z0-9-_]+)/,
|
|
110
117
|
appleMusic: /https?:\/\/?(?:www\.)?music\.apple\.com\/(\S+)/,
|
|
118
|
+
/** From jiosaavn-plugin */
|
|
119
|
+
jiosaavn: /(https?:\/\/)(www\.)?jiosaavn\.com\/(?<type>song|album|featured|artist)\/([a-zA-Z0-9-_\/,]+)/,
|
|
111
120
|
/** FROM DUNCTE BOT PLUGIN */
|
|
112
121
|
tiktok: /https:\/\/www\.tiktok\.com\//,
|
|
113
122
|
mixcloud: /https:\/\/www\.mixcloud\.com\//,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Player } from "./Player";
|
|
2
|
-
import type { DestroyReasonsType } from "./Types/Player";
|
|
3
|
-
import type { Track } from "./Types/Track";
|
|
4
|
-
import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils";
|
|
5
|
-
import type { NodeManager } from "./NodeManager";
|
|
6
|
-
import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node";
|
|
1
|
+
import type { Player } from "./Player.js";
|
|
2
|
+
import type { DestroyReasonsType } from "./Types/Player.js";
|
|
3
|
+
import type { Track } from "./Types/Track.js";
|
|
4
|
+
import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils.js";
|
|
5
|
+
import type { NodeManager } from "./NodeManager.js";
|
|
6
|
+
import type { BaseNodeStats, LavalinkInfo, LavalinkNodeOptions, LyricsResult, ModifyRequest, NodeStats, SponsorBlockSegment } from "./Types/Node.js";
|
|
7
7
|
/**
|
|
8
8
|
* Lavalink Node creator class
|
|
9
9
|
*/
|
|
@@ -271,6 +271,62 @@ export declare class LavalinkNode {
|
|
|
271
271
|
*/
|
|
272
272
|
multipleTracks: (encodeds: Base64[], requester: unknown) => Promise<Track[]>;
|
|
273
273
|
};
|
|
274
|
+
lyrics: {
|
|
275
|
+
/**
|
|
276
|
+
* Get the lyrics of a track
|
|
277
|
+
* @param track the track to get the lyrics for
|
|
278
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
279
|
+
* @returns the lyrics of the track
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* const lyrics = await player.node.lyrics.get(track, true);
|
|
284
|
+
* // use it of player instead:
|
|
285
|
+
* // const lyrics = await player.getLyrics(track, true);
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
289
|
+
/**
|
|
290
|
+
* Get the lyrics of the current playing track
|
|
291
|
+
*
|
|
292
|
+
* @param guildId the guild id of the player
|
|
293
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
294
|
+
* @returns the lyrics of the current playing track
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const lyrics = await player.node.lyrics.getCurrent(guildId);
|
|
298
|
+
* // use it of player instead:
|
|
299
|
+
* // const lyrics = await player.getCurrentLyrics();
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
303
|
+
/**
|
|
304
|
+
* subscribe to lyrics updates for a guild
|
|
305
|
+
* @param guildId the guild id of the player
|
|
306
|
+
* @returns request data of the request
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* await player.node.lyrics.subscribe(guildId);
|
|
311
|
+
* // use it of player instead:
|
|
312
|
+
* // const lyrics = await player.subscribeLyrics();
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
subscribe: (guildId: string) => Promise<any>;
|
|
316
|
+
/**
|
|
317
|
+
* unsubscribe from lyrics updates for a guild
|
|
318
|
+
* @param guildId the guild id of the player
|
|
319
|
+
* @returns request data of the request
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* await player.node.lyrics.unsubscribe(guildId);
|
|
324
|
+
* // use it of player instead:
|
|
325
|
+
* // const lyrics = await player.unsubscribeLyrics();
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
unsubscribe: (guildId: string) => Promise<any>;
|
|
329
|
+
};
|
|
274
330
|
/**
|
|
275
331
|
* Request Lavalink statistics.
|
|
276
332
|
* @returns the lavalink node stats
|
|
@@ -432,4 +488,28 @@ export declare class LavalinkNode {
|
|
|
432
488
|
deleteSponsorBlock(player: Player): Promise<void>;
|
|
433
489
|
/** private util function for handling the queue end event */
|
|
434
490
|
private queueEnd;
|
|
491
|
+
/**
|
|
492
|
+
* Emitted whenever a line of lyrics gets emitted
|
|
493
|
+
* @event
|
|
494
|
+
* @param {Player} player The player that emitted the event
|
|
495
|
+
* @param {Track} track The track that emitted the event
|
|
496
|
+
* @param {LyricsLineEvent} payload The payload of the event
|
|
497
|
+
*/
|
|
498
|
+
private LyricsLine;
|
|
499
|
+
/**
|
|
500
|
+
* Emitted whenever the lyrics for a track got found
|
|
501
|
+
* @event
|
|
502
|
+
* @param {Player} player The player that emitted the event
|
|
503
|
+
* @param {Track} track The track that emitted the event
|
|
504
|
+
* @param {LyricsFoundEvent} payload The payload of the event
|
|
505
|
+
*/
|
|
506
|
+
private LyricsFound;
|
|
507
|
+
/**
|
|
508
|
+
* Emitted whenever the lyrics for a track got not found
|
|
509
|
+
* @event
|
|
510
|
+
* @param {Player} player The player that emitted the event
|
|
511
|
+
* @param {Track} track The track that emitted the event
|
|
512
|
+
* @param {LyricsNotFoundEvent} payload The payload of the event
|
|
513
|
+
*/
|
|
514
|
+
private LyricsNotFound;
|
|
435
515
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAbsolute } from "path";
|
|
2
2
|
import WebSocket from "ws";
|
|
3
|
-
import { DebugEvents, DestroyReasons, validSponsorBlocks } from "./Constants";
|
|
4
|
-
import { NodeSymbol, queueTrackEnd } from "./Utils";
|
|
3
|
+
import { DebugEvents, DestroyReasons, validSponsorBlocks } from "./Constants.js";
|
|
4
|
+
import { NodeSymbol, queueTrackEnd } from "./Utils.js";
|
|
5
5
|
/**
|
|
6
6
|
* Lavalink Node creator class
|
|
7
7
|
*/
|
|
@@ -586,6 +586,104 @@ export class LavalinkNode {
|
|
|
586
586
|
}).then((r) => r.map(track => this.NodeManager.LavalinkManager.utils.buildTrack(track, requester)));
|
|
587
587
|
}
|
|
588
588
|
};
|
|
589
|
+
lyrics = {
|
|
590
|
+
/**
|
|
591
|
+
* Get the lyrics of a track
|
|
592
|
+
* @param track the track to get the lyrics for
|
|
593
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
594
|
+
* @returns the lyrics of the track
|
|
595
|
+
* @example
|
|
596
|
+
*
|
|
597
|
+
* ```ts
|
|
598
|
+
* const lyrics = await player.node.lyrics.get(track, true);
|
|
599
|
+
* // use it of player instead:
|
|
600
|
+
* // const lyrics = await player.getLyrics(track, true);
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
603
|
+
get: async (track, skipTrackSource = false) => {
|
|
604
|
+
if (!this.sessionId)
|
|
605
|
+
throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
606
|
+
if (!this.info.plugins.find(v => v.name === "lavalyrics-plugin"))
|
|
607
|
+
throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
608
|
+
if (!this.info.plugins.find(v => v.name === "lavasrc-plugin") &&
|
|
609
|
+
!this.info.plugins.find(v => v.name === "java-lyrics-plugin"))
|
|
610
|
+
throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
611
|
+
const url = `/lyrics?track=${track.encoded}&skipTrackSource=${skipTrackSource}`;
|
|
612
|
+
return (await this.request(url));
|
|
613
|
+
},
|
|
614
|
+
/**
|
|
615
|
+
* Get the lyrics of the current playing track
|
|
616
|
+
*
|
|
617
|
+
* @param guildId the guild id of the player
|
|
618
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
619
|
+
* @returns the lyrics of the current playing track
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* const lyrics = await player.node.lyrics.getCurrent(guildId);
|
|
623
|
+
* // use it of player instead:
|
|
624
|
+
* // const lyrics = await player.getCurrentLyrics();
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
627
|
+
getCurrent: async (guildId, skipTrackSource = false) => {
|
|
628
|
+
if (!this.sessionId)
|
|
629
|
+
throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
630
|
+
if (!this.info.plugins.find(v => v.name === "lavalyrics-plugin"))
|
|
631
|
+
throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
632
|
+
if (!this.info.plugins.find(v => v.name === "lavasrc-plugin") &&
|
|
633
|
+
!this.info.plugins.find(v => v.name === "java-lyrics-plugin"))
|
|
634
|
+
throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
635
|
+
const url = `/sessions/${this.sessionId}/players/${guildId}/track/lyrics?skipTrackSource=${skipTrackSource}`;
|
|
636
|
+
return (await this.request(url));
|
|
637
|
+
},
|
|
638
|
+
/**
|
|
639
|
+
* subscribe to lyrics updates for a guild
|
|
640
|
+
* @param guildId the guild id of the player
|
|
641
|
+
* @returns request data of the request
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```ts
|
|
645
|
+
* await player.node.lyrics.subscribe(guildId);
|
|
646
|
+
* // use it of player instead:
|
|
647
|
+
* // const lyrics = await player.subscribeLyrics();
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
subscribe: async (guildId) => {
|
|
651
|
+
if (!this.sessionId)
|
|
652
|
+
throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
653
|
+
if (!this.info.plugins.find(v => v.name === "lavalyrics-plugin"))
|
|
654
|
+
throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
655
|
+
if (!this.info.plugins.find(v => v.name === "lavasrc-plugin") &&
|
|
656
|
+
!this.info.plugins.find(v => v.name === "java-lyrics-plugin"))
|
|
657
|
+
throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
658
|
+
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe`, (options) => {
|
|
659
|
+
options.method = "POST";
|
|
660
|
+
}).catch(() => { });
|
|
661
|
+
},
|
|
662
|
+
/**
|
|
663
|
+
* unsubscribe from lyrics updates for a guild
|
|
664
|
+
* @param guildId the guild id of the player
|
|
665
|
+
* @returns request data of the request
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* ```ts
|
|
669
|
+
* await player.node.lyrics.unsubscribe(guildId);
|
|
670
|
+
* // use it of player instead:
|
|
671
|
+
* // const lyrics = await player.unsubscribeLyrics();
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
unsubscribe: async (guildId) => {
|
|
675
|
+
if (!this.sessionId)
|
|
676
|
+
throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
677
|
+
if (!this.info.plugins.find(v => v.name === "lavalyrics-plugin"))
|
|
678
|
+
throw new RangeError(`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`);
|
|
679
|
+
if (!this.info.plugins.find(v => v.name === "lavasrc-plugin") &&
|
|
680
|
+
!this.info.plugins.find(v => v.name === "java-lyrics-plugin"))
|
|
681
|
+
throw new RangeError(`there is no lyrics source (via lavasrc-plugin / java-lyrics-plugin) available in the lavalink node (required for lyrics): ${this.id}`);
|
|
682
|
+
return await this.request(`/sessions/${this.sessionId}/players/${guildId}/lyrics/unsubscribe`, (options) => {
|
|
683
|
+
options.method = "DELETE";
|
|
684
|
+
}).catch(() => { });
|
|
685
|
+
},
|
|
686
|
+
};
|
|
589
687
|
/**
|
|
590
688
|
* Request Lavalink statistics.
|
|
591
689
|
* @returns the lavalink node stats
|
|
@@ -982,6 +1080,15 @@ export class LavalinkNode {
|
|
|
982
1080
|
case "ChapterStarted":
|
|
983
1081
|
this.SponsorBlockChapterStarted(player, player.queue.current, payload);
|
|
984
1082
|
break;
|
|
1083
|
+
case "LyricsLineEvent":
|
|
1084
|
+
this.LyricsLine(player, player.queue.current, payload);
|
|
1085
|
+
break;
|
|
1086
|
+
case "LyricsFoundEvent":
|
|
1087
|
+
this.LyricsFound(player, player.queue.current, payload);
|
|
1088
|
+
break;
|
|
1089
|
+
case "LyricsNotFoundEvent":
|
|
1090
|
+
this.LyricsNotFound(player, player.queue.current, payload);
|
|
1091
|
+
break;
|
|
985
1092
|
default:
|
|
986
1093
|
this.NodeManager.emit("error", this, new Error(`Node#event unknown event '${payload.type}'.`), payload);
|
|
987
1094
|
break;
|
|
@@ -1252,9 +1359,16 @@ export class LavalinkNode {
|
|
|
1252
1359
|
});
|
|
1253
1360
|
}
|
|
1254
1361
|
if (typeof this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction === "function" && typeof player.get("internal_autoplayStopPlaying") === "undefined") {
|
|
1362
|
+
if (this.NodeManager.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
1363
|
+
this.NodeManager.LavalinkManager.emit("debug", DebugEvents.AutoplayExecution, {
|
|
1364
|
+
state: "log",
|
|
1365
|
+
message: `Now Triggering Autoplay.`,
|
|
1366
|
+
functionLayer: "LavalinkNode > queueEnd() > autoplayFunction",
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1255
1369
|
const previousAutoplayTime = player.get("internal_previousautoplay");
|
|
1256
1370
|
const duration = previousAutoplayTime ? Date.now() - previousAutoplayTime : 0;
|
|
1257
|
-
if (
|
|
1371
|
+
if (!duration || duration > this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs || !!player.get("internal_skipped")) {
|
|
1258
1372
|
await this.NodeManager.LavalinkManager.options?.playerOptions?.onEmptyQueue?.autoPlayFunction(player, track);
|
|
1259
1373
|
player.set("internal_previousautoplay", Date.now());
|
|
1260
1374
|
if (player.queue.tracks.length > 0)
|
|
@@ -1315,4 +1429,34 @@ export class LavalinkNode {
|
|
|
1315
1429
|
}
|
|
1316
1430
|
return this.NodeManager.LavalinkManager.emit("queueEnd", player, track, payload);
|
|
1317
1431
|
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Emitted whenever a line of lyrics gets emitted
|
|
1434
|
+
* @event
|
|
1435
|
+
* @param {Player} player The player that emitted the event
|
|
1436
|
+
* @param {Track} track The track that emitted the event
|
|
1437
|
+
* @param {LyricsLineEvent} payload The payload of the event
|
|
1438
|
+
*/
|
|
1439
|
+
LyricsLine(player, track, payload) {
|
|
1440
|
+
return this.NodeManager.LavalinkManager.emit("LyricsLine", player, track, payload);
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Emitted whenever the lyrics for a track got found
|
|
1444
|
+
* @event
|
|
1445
|
+
* @param {Player} player The player that emitted the event
|
|
1446
|
+
* @param {Track} track The track that emitted the event
|
|
1447
|
+
* @param {LyricsFoundEvent} payload The payload of the event
|
|
1448
|
+
*/
|
|
1449
|
+
LyricsFound(player, track, payload) {
|
|
1450
|
+
return this.NodeManager.LavalinkManager.emit("LyricsFound", player, track, payload);
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Emitted whenever the lyrics for a track got not found
|
|
1454
|
+
* @event
|
|
1455
|
+
* @param {Player} player The player that emitted the event
|
|
1456
|
+
* @param {Track} track The track that emitted the event
|
|
1457
|
+
* @param {LyricsNotFoundEvent} payload The payload of the event
|
|
1458
|
+
*/
|
|
1459
|
+
LyricsNotFound(player, track, payload) {
|
|
1460
|
+
return this.NodeManager.LavalinkManager.emit("LyricsNotFound", player, track, payload);
|
|
1461
|
+
}
|
|
1318
1462
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
|
-
import { LavalinkNode } from "./Node";
|
|
4
|
-
import { MiniMap } from "./Utils";
|
|
5
|
-
import type { LavalinkNodeIdentifier, LavalinkNodeOptions, NodeManagerEvents } from "./Types/Node";
|
|
6
|
-
import type { LavalinkManager } from "./LavalinkManager";
|
|
3
|
+
import { LavalinkNode } from "./Node.js";
|
|
4
|
+
import { MiniMap } from "./Utils.js";
|
|
5
|
+
import type { LavalinkNodeIdentifier, LavalinkNodeOptions, NodeManagerEvents } from "./Types/Node.js";
|
|
6
|
+
import type { LavalinkManager } from "./LavalinkManager.js";
|
|
7
7
|
export declare class NodeManager extends EventEmitter {
|
|
8
8
|
/**
|
|
9
9
|
* Emit an event
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { DestroyReasons } from "./Constants";
|
|
3
|
-
import { LavalinkNode } from "./Node";
|
|
4
|
-
import { MiniMap } from "./Utils";
|
|
2
|
+
import { DestroyReasons } from "./Constants.js";
|
|
3
|
+
import { LavalinkNode } from "./Node.js";
|
|
4
|
+
import { MiniMap } from "./Utils.js";
|
|
5
5
|
export class NodeManager extends EventEmitter {
|
|
6
6
|
/**
|
|
7
7
|
* Emit an event
|