lavalink-client 2.3.5 → 2.4.0
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 +73 -6
- package/dist/cjs/structures/Constants.d.ts +4 -0
- package/dist/cjs/structures/Constants.js +7 -2
- package/dist/cjs/structures/Filters.d.ts +24 -0
- package/dist/cjs/structures/Filters.js +34 -10
- package/dist/cjs/structures/LavalinkManager.d.ts +4 -5
- package/dist/cjs/structures/LavalinkManager.js +36 -14
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +2 -0
- package/dist/cjs/structures/LavalinkManagerStatics.js +11 -2
- package/dist/cjs/structures/Node.d.ts +107 -13
- package/dist/cjs/structures/Node.js +294 -76
- package/dist/cjs/structures/NodeManager.d.ts +2 -2
- package/dist/cjs/structures/NodeManager.js +19 -19
- package/dist/cjs/structures/Player.d.ts +51 -1
- package/dist/cjs/structures/Player.js +62 -0
- package/dist/cjs/structures/Queue.d.ts +9 -10
- package/dist/cjs/structures/Queue.js +3 -3
- package/dist/cjs/structures/Types/Manager.d.ts +59 -1
- package/dist/cjs/structures/Types/Node.d.ts +23 -1
- package/dist/cjs/structures/Types/Player.d.ts +5 -1
- package/dist/cjs/structures/Types/Queue.d.ts +6 -6
- package/dist/cjs/structures/Types/Track.d.ts +3 -1
- package/dist/cjs/structures/Types/Utils.d.ts +81 -8
- package/dist/cjs/structures/Utils.js +11 -9
- package/dist/esm/structures/Constants.d.ts +4 -0
- package/dist/esm/structures/Constants.js +6 -1
- package/dist/esm/structures/Filters.d.ts +24 -0
- package/dist/esm/structures/Filters.js +34 -10
- package/dist/esm/structures/LavalinkManager.d.ts +4 -5
- package/dist/esm/structures/LavalinkManager.js +36 -14
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +2 -0
- package/dist/esm/structures/LavalinkManagerStatics.js +11 -2
- package/dist/esm/structures/Node.d.ts +107 -13
- package/dist/esm/structures/Node.js +294 -76
- package/dist/esm/structures/NodeManager.d.ts +2 -2
- package/dist/esm/structures/NodeManager.js +20 -20
- package/dist/esm/structures/Player.d.ts +51 -1
- package/dist/esm/structures/Player.js +62 -0
- package/dist/esm/structures/Queue.d.ts +9 -10
- package/dist/esm/structures/Queue.js +3 -3
- package/dist/esm/structures/Types/Manager.d.ts +59 -1
- package/dist/esm/structures/Types/Node.d.ts +23 -1
- package/dist/esm/structures/Types/Player.d.ts +5 -1
- package/dist/esm/structures/Types/Queue.d.ts +6 -6
- package/dist/esm/structures/Types/Track.d.ts +3 -1
- package/dist/esm/structures/Types/Utils.d.ts +81 -8
- package/dist/esm/structures/Utils.js +8 -6
- package/dist/types/structures/Constants.d.ts +4 -0
- package/dist/types/structures/Filters.d.ts +24 -0
- package/dist/types/structures/LavalinkManager.d.ts +4 -5
- package/dist/types/structures/LavalinkManagerStatics.d.ts +2 -0
- package/dist/types/structures/Node.d.ts +107 -13
- package/dist/types/structures/NodeManager.d.ts +2 -2
- package/dist/types/structures/Player.d.ts +51 -1
- package/dist/types/structures/Queue.d.ts +9 -10
- package/dist/types/structures/Types/Manager.d.ts +59 -1
- package/dist/types/structures/Types/Node.d.ts +23 -1
- package/dist/types/structures/Types/Player.d.ts +5 -1
- package/dist/types/structures/Types/Queue.d.ts +6 -6
- package/dist/types/structures/Types/Track.d.ts +3 -1
- package/dist/types/structures/Types/Utils.d.ts +81 -8
- package/package.json +29 -18
|
@@ -73,18 +73,24 @@ class NodeManager extends events_1.EventEmitter {
|
|
|
73
73
|
/**
|
|
74
74
|
* Disconnects all Nodes from lavalink ws sockets
|
|
75
75
|
* @param deleteAllNodes if the nodes should also be deleted from nodeManager.nodes
|
|
76
|
+
* @param destroyPlayers if the players should be destroyed
|
|
76
77
|
* @returns amount of disconnected Nodes
|
|
77
78
|
*/
|
|
78
|
-
async disconnectAll(deleteAllNodes = false) {
|
|
79
|
+
async disconnectAll(deleteAllNodes = false, destroyPlayers = true) {
|
|
79
80
|
if (!this.nodes.size)
|
|
80
81
|
throw new Error("There are no nodes to disconnect (no nodes in the nodemanager)");
|
|
81
82
|
if (!this.nodes.filter(v => v.connected).size)
|
|
82
83
|
throw new Error("There are no nodes to disconnect (all nodes disconnected)");
|
|
83
84
|
let counter = 0;
|
|
84
|
-
for (const node of
|
|
85
|
+
for (const node of this.nodes.values()) {
|
|
85
86
|
if (!node.connected)
|
|
86
87
|
continue;
|
|
87
|
-
|
|
88
|
+
if (destroyPlayers) {
|
|
89
|
+
await node.destroy(Constants_1.DestroyReasons.DisconnectAllNodes, deleteAllNodes);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
await node.disconnect(Constants_1.DisconnectReasons.DisconnectAllNodes);
|
|
93
|
+
}
|
|
88
94
|
counter++;
|
|
89
95
|
}
|
|
90
96
|
return counter;
|
|
@@ -99,7 +105,7 @@ class NodeManager extends events_1.EventEmitter {
|
|
|
99
105
|
if (!this.nodes.filter(v => !v.connected).size)
|
|
100
106
|
throw new Error("There are no nodes to connect (all nodes connected)");
|
|
101
107
|
let counter = 0;
|
|
102
|
-
for (const node of
|
|
108
|
+
for (const node of this.nodes.values()) {
|
|
103
109
|
if (node.connected)
|
|
104
110
|
continue;
|
|
105
111
|
await node.connect();
|
|
@@ -115,7 +121,7 @@ class NodeManager extends events_1.EventEmitter {
|
|
|
115
121
|
if (!this.nodes.size)
|
|
116
122
|
throw new Error("There are no nodes to reconnect (no nodes in the nodemanager)");
|
|
117
123
|
let counter = 0;
|
|
118
|
-
for (const node of
|
|
124
|
+
for (const node of this.nodes.values()) {
|
|
119
125
|
const sessionId = node.sessionId ? `${node.sessionId}` : undefined;
|
|
120
126
|
await node.destroy(Constants_1.DestroyReasons.ReconnectAllNodes, false);
|
|
121
127
|
await node.connect(sessionId);
|
|
@@ -141,53 +147,47 @@ class NodeManager extends events_1.EventEmitter {
|
|
|
141
147
|
* @returns
|
|
142
148
|
*/
|
|
143
149
|
leastUsedNodes(sortType = "players") {
|
|
150
|
+
const connectedNodes = Array.from(this.nodes.values()).filter((node) => node.connected);
|
|
144
151
|
switch (sortType) {
|
|
145
152
|
case "memory":
|
|
146
153
|
{
|
|
147
|
-
return
|
|
148
|
-
.filter((node) => node.connected)
|
|
154
|
+
return connectedNodes
|
|
149
155
|
.sort((a, b) => (a.stats?.memory?.used || 0) - (b.stats?.memory?.used || 0)); // sort after memor
|
|
150
156
|
}
|
|
151
157
|
break;
|
|
152
158
|
case "cpuLavalink":
|
|
153
159
|
{
|
|
154
|
-
return
|
|
155
|
-
.filter((node) => node.connected)
|
|
160
|
+
return connectedNodes
|
|
156
161
|
.sort((a, b) => (a.stats?.cpu?.lavalinkLoad || 0) - (b.stats?.cpu?.lavalinkLoad || 0)); // sort after memor
|
|
157
162
|
}
|
|
158
163
|
break;
|
|
159
164
|
case "cpuSystem":
|
|
160
165
|
{
|
|
161
|
-
return
|
|
162
|
-
.filter((node) => node.connected)
|
|
166
|
+
return connectedNodes
|
|
163
167
|
.sort((a, b) => (a.stats?.cpu?.systemLoad || 0) - (b.stats?.cpu?.systemLoad || 0)); // sort after memor
|
|
164
168
|
}
|
|
165
169
|
break;
|
|
166
170
|
case "calls":
|
|
167
171
|
{
|
|
168
|
-
return
|
|
169
|
-
.filter((node) => node.connected)
|
|
172
|
+
return connectedNodes
|
|
170
173
|
.sort((a, b) => a.calls - b.calls); // client sided sorting
|
|
171
174
|
}
|
|
172
175
|
break;
|
|
173
176
|
case "playingPlayers":
|
|
174
177
|
{
|
|
175
|
-
return
|
|
176
|
-
.filter((node) => node.connected)
|
|
178
|
+
return connectedNodes
|
|
177
179
|
.sort((a, b) => (a.stats?.playingPlayers || 0) - (b.stats?.playingPlayers || 0));
|
|
178
180
|
}
|
|
179
181
|
break;
|
|
180
182
|
case "players":
|
|
181
183
|
{
|
|
182
|
-
return
|
|
183
|
-
.filter((node) => node.connected)
|
|
184
|
+
return connectedNodes
|
|
184
185
|
.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
185
186
|
}
|
|
186
187
|
break;
|
|
187
188
|
default:
|
|
188
189
|
{
|
|
189
|
-
return
|
|
190
|
-
.filter((node) => node.connected)
|
|
190
|
+
return connectedNodes
|
|
191
191
|
.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
192
192
|
}
|
|
193
193
|
break;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FilterManager } from "./Filters.js";
|
|
2
2
|
import { Queue } from "./Queue.js";
|
|
3
3
|
import type { DestroyReasons } from "./Constants.js";
|
|
4
|
+
import type { Track } from "./Types/Track.js";
|
|
4
5
|
import type { LavalinkNode } from "./Node.js";
|
|
5
6
|
import type { SponsorBlockSegment } from "./Types/Node.js";
|
|
6
7
|
import type { PlayerJson, PlayerOptions, PlayOptions, RepeatMode } from "./Types/Player.js";
|
|
@@ -51,6 +52,13 @@ export declare class Player {
|
|
|
51
52
|
connected: boolean | undefined;
|
|
52
53
|
/** Voice Server Data (from Lavalink) */
|
|
53
54
|
voice: LavalinkPlayerVoiceOptions;
|
|
55
|
+
voiceState: {
|
|
56
|
+
selfDeaf: boolean;
|
|
57
|
+
selfMute: boolean;
|
|
58
|
+
serverDeaf: boolean;
|
|
59
|
+
serverMute: boolean;
|
|
60
|
+
suppress: boolean;
|
|
61
|
+
};
|
|
54
62
|
/** Custom data for the player */
|
|
55
63
|
private readonly data;
|
|
56
64
|
/**
|
|
@@ -96,7 +104,7 @@ export declare class Player {
|
|
|
96
104
|
* @param throwOnEmpty If an error should be thrown if no track is found
|
|
97
105
|
* @returns The search result
|
|
98
106
|
*/
|
|
99
|
-
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils.js").
|
|
107
|
+
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Types/Utils.js").LavaSearchResponse | import("./Types/Utils.js").SearchResult>;
|
|
100
108
|
/**
|
|
101
109
|
* Set the SponsorBlock
|
|
102
110
|
* @param segments The segments to set
|
|
@@ -164,6 +172,48 @@ export declare class Player {
|
|
|
164
172
|
* Destroy the player and disconnect from the voice channel
|
|
165
173
|
*/
|
|
166
174
|
destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
|
|
175
|
+
/**
|
|
176
|
+
* Get the current lyrics of the track currently playing on the guild
|
|
177
|
+
* @param guildId The guild id to get the current lyrics for
|
|
178
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
179
|
+
* @returns The current lyrics
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const lyrics = await player.getCurrentLyrics();
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
getCurrentLyrics(skipTrackSource?: boolean): Promise<import("./Types/Node.js").LyricsResult>;
|
|
186
|
+
/**
|
|
187
|
+
* Get the lyrics of a specific track
|
|
188
|
+
* @param track The track to get the lyrics for
|
|
189
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
190
|
+
* @returns The lyrics of the track
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const lyrics = await player.getLyrics(player.queue.tracks[0], true);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
getLyrics(track: Track, skipTrackSource?: boolean): Promise<import("./Types/Node.js").LyricsResult>;
|
|
197
|
+
/**
|
|
198
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
199
|
+
* @param guildId The guild id to subscribe to
|
|
200
|
+
* @returns The unsubscribe function
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const lyrics = await player.subscribeLyrics();
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
subscribeLyrics(): Promise<unknown>;
|
|
207
|
+
/**
|
|
208
|
+
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
209
|
+
* @param guildId The guild id to unsubscribe from
|
|
210
|
+
* @returns The unsubscribe function
|
|
211
|
+
* @example
|
|
212
|
+
* ```ts
|
|
213
|
+
* const lyrics = await player.unsubscribeLyrics();
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
unsubscribeLyrics(guildId: string): Promise<void>;
|
|
167
217
|
/**
|
|
168
218
|
* Move the player on a different Audio-Node
|
|
169
219
|
* @param newNode New Node / New Node Id
|
|
@@ -59,6 +59,13 @@ class Player {
|
|
|
59
59
|
sessionId: null,
|
|
60
60
|
token: null
|
|
61
61
|
};
|
|
62
|
+
voiceState = {
|
|
63
|
+
selfDeaf: false,
|
|
64
|
+
selfMute: false,
|
|
65
|
+
serverDeaf: false,
|
|
66
|
+
serverMute: false,
|
|
67
|
+
suppress: false,
|
|
68
|
+
};
|
|
62
69
|
/** Custom data for the player */
|
|
63
70
|
data = {};
|
|
64
71
|
/**
|
|
@@ -145,6 +152,7 @@ class Player {
|
|
|
145
152
|
functionLayer: "Player > play()",
|
|
146
153
|
});
|
|
147
154
|
}
|
|
155
|
+
this.LavalinkManager.emit("playerQueueEmptyCancel", this);
|
|
148
156
|
clearTimeout(this.get("internal_queueempty"));
|
|
149
157
|
this.set("internal_queueempty", undefined);
|
|
150
158
|
}
|
|
@@ -543,6 +551,10 @@ class Player {
|
|
|
543
551
|
async destroy(reason, disconnect = true) {
|
|
544
552
|
if (this.LavalinkManager.options.advancedOptions?.debugOptions.playerDestroy.debugLog)
|
|
545
553
|
console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Destroy-Reason: ${String(reason)}`);
|
|
554
|
+
if (this.get("internal_queueempty")) {
|
|
555
|
+
clearTimeout(this.get("internal_queueempty"));
|
|
556
|
+
this.set("internal_queueempty", undefined);
|
|
557
|
+
}
|
|
546
558
|
if (this.get("internal_destroystatus") === true) {
|
|
547
559
|
if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
548
560
|
this.LavalinkManager.emit("debug", Constants_1.DebugEvents.PlayerDestroyingSomewhereElse, {
|
|
@@ -574,6 +586,56 @@ class Player {
|
|
|
574
586
|
// return smt
|
|
575
587
|
return this;
|
|
576
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Get the current lyrics of the track currently playing on the guild
|
|
591
|
+
* @param guildId The guild id to get the current lyrics for
|
|
592
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
593
|
+
* @returns The current lyrics
|
|
594
|
+
* @example
|
|
595
|
+
* ```ts
|
|
596
|
+
* const lyrics = await player.getCurrentLyrics();
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
async getCurrentLyrics(skipTrackSource) {
|
|
600
|
+
return await this.node.lyrics.getCurrent(this.guildId, skipTrackSource);
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Get the lyrics of a specific track
|
|
604
|
+
* @param track The track to get the lyrics for
|
|
605
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
606
|
+
* @returns The lyrics of the track
|
|
607
|
+
* @example
|
|
608
|
+
* ```ts
|
|
609
|
+
* const lyrics = await player.getLyrics(player.queue.tracks[0], true);
|
|
610
|
+
* ```
|
|
611
|
+
*/
|
|
612
|
+
async getLyrics(track, skipTrackSource) {
|
|
613
|
+
return await this.node.lyrics.get(track, skipTrackSource);
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
617
|
+
* @param guildId The guild id to subscribe to
|
|
618
|
+
* @returns The unsubscribe function
|
|
619
|
+
* @example
|
|
620
|
+
* ```ts
|
|
621
|
+
* const lyrics = await player.subscribeLyrics();
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
subscribeLyrics() {
|
|
625
|
+
return this.node.lyrics.subscribe(this.guildId);
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
629
|
+
* @param guildId The guild id to unsubscribe from
|
|
630
|
+
* @returns The unsubscribe function
|
|
631
|
+
* @example
|
|
632
|
+
* ```ts
|
|
633
|
+
* const lyrics = await player.unsubscribeLyrics();
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
636
|
+
unsubscribeLyrics(guildId) {
|
|
637
|
+
return this.node.lyrics.unsubscribe(guildId);
|
|
638
|
+
}
|
|
577
639
|
/**
|
|
578
640
|
* Move the player on a different Audio-Node
|
|
579
641
|
* @param newNode New Node / New Node Id
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MiniMap } from "./Utils.js";
|
|
2
1
|
import type { Track, UnresolvedTrack } from "./Types/Track.js";
|
|
3
2
|
import type { ManagerQueueOptions, QueueStoreManager, StoredQueue } from "./Types/Queue.js";
|
|
4
3
|
export declare class QueueSaver {
|
|
@@ -24,14 +23,14 @@ export declare class QueueSaver {
|
|
|
24
23
|
* @param guildId The guild ID
|
|
25
24
|
* @returns The queue for the guild
|
|
26
25
|
*/
|
|
27
|
-
delete(guildId: string): Promise<
|
|
26
|
+
delete(guildId: string): Promise<boolean | void>;
|
|
28
27
|
/**
|
|
29
28
|
* Set the queue for a guild
|
|
30
29
|
* @param guildId The guild ID
|
|
31
30
|
* @param valueToStringify The queue to set
|
|
32
31
|
* @returns The queue for the guild
|
|
33
32
|
*/
|
|
34
|
-
set(guildId: string, valueToStringify: StoredQueue): Promise<
|
|
33
|
+
set(guildId: string, valueToStringify: StoredQueue): Promise<boolean | void>;
|
|
35
34
|
/**
|
|
36
35
|
* Sync the queue for a guild
|
|
37
36
|
* @param guildId The guild ID
|
|
@@ -47,32 +46,32 @@ export declare class DefaultQueueStore implements QueueStoreManager {
|
|
|
47
46
|
* @param guildId The guild ID
|
|
48
47
|
* @returns The queue for the guild
|
|
49
48
|
*/
|
|
50
|
-
get(guildId:
|
|
49
|
+
get(guildId: string): Promise<StoredQueue>;
|
|
51
50
|
/**
|
|
52
51
|
* Set the queue for a guild
|
|
53
52
|
* @param guildId The guild ID
|
|
54
53
|
* @param valueToStringify The queue to set
|
|
55
54
|
* @returns The queue for the guild
|
|
56
55
|
*/
|
|
57
|
-
set(guildId:
|
|
56
|
+
set(guildId: string, valueToStringify: any): Promise<boolean>;
|
|
58
57
|
/**
|
|
59
58
|
* Delete the queue for a guild
|
|
60
59
|
* @param guildId The guild ID
|
|
61
60
|
* @returns The queue for the guild
|
|
62
61
|
*/
|
|
63
|
-
delete(guildId:
|
|
62
|
+
delete(guildId: string): Promise<boolean>;
|
|
64
63
|
/**
|
|
65
64
|
* Stringify the queue for a guild
|
|
66
65
|
* @param value The queue to stringify
|
|
67
66
|
* @returns The stringified queue
|
|
68
67
|
*/
|
|
69
|
-
stringify(value:
|
|
68
|
+
stringify(value: StoredQueue): Promise<StoredQueue>;
|
|
70
69
|
/**
|
|
71
70
|
* Parse the queue for a guild
|
|
72
71
|
* @param value The queue to parse
|
|
73
72
|
* @returns The parsed queue
|
|
74
73
|
*/
|
|
75
|
-
parse(value:
|
|
74
|
+
parse(value: StoredQueue): Promise<StoredQueue>;
|
|
76
75
|
}
|
|
77
76
|
export declare class Queue {
|
|
78
77
|
readonly tracks: (Track | UnresolvedTrack)[];
|
|
@@ -100,13 +99,13 @@ export declare class Queue {
|
|
|
100
99
|
/**
|
|
101
100
|
* Save the current cached Queue on the database/server (overides the server)
|
|
102
101
|
*/
|
|
103
|
-
save: () => Promise<
|
|
102
|
+
save: () => Promise<boolean | void>;
|
|
104
103
|
/**
|
|
105
104
|
* Sync the current queue database/server with the cached one
|
|
106
105
|
* @returns {void}
|
|
107
106
|
*/
|
|
108
107
|
sync: (override?: boolean, dontSyncCurrent?: boolean) => Promise<void>;
|
|
109
|
-
destroy: () => Promise<
|
|
108
|
+
destroy: () => Promise<boolean | void>;
|
|
110
109
|
/**
|
|
111
110
|
* @returns {{current:Track|null, previous:Track[], tracks:Track[]}}The Queue, but in a raw State, which allows easier handling for the QueueStoreManager
|
|
112
111
|
*/
|
|
@@ -61,7 +61,7 @@ class DefaultQueueStore {
|
|
|
61
61
|
* @returns The queue for the guild
|
|
62
62
|
*/
|
|
63
63
|
async get(guildId) {
|
|
64
|
-
return
|
|
64
|
+
return this.data.get(guildId);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* Set the queue for a guild
|
|
@@ -70,7 +70,7 @@ class DefaultQueueStore {
|
|
|
70
70
|
* @returns The queue for the guild
|
|
71
71
|
*/
|
|
72
72
|
async set(guildId, valueToStringify) {
|
|
73
|
-
return
|
|
73
|
+
return this.data.set(guildId, valueToStringify) ? true : false;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Delete the queue for a guild
|
|
@@ -78,7 +78,7 @@ class DefaultQueueStore {
|
|
|
78
78
|
* @returns The queue for the guild
|
|
79
79
|
*/
|
|
80
80
|
async delete(guildId) {
|
|
81
|
-
return
|
|
81
|
+
return this.data.delete(guildId);
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Stringify the queue for a guild
|
|
@@ -4,7 +4,7 @@ import type { LavalinkNodeOptions } from "./Node.js";
|
|
|
4
4
|
import type { DestroyReasonsType, PlayerJson } from "./Player.js";
|
|
5
5
|
import type { ManagerQueueOptions } from "./Queue.js";
|
|
6
6
|
import type { Track, UnresolvedTrack } from "./Track.js";
|
|
7
|
-
import type { GuildShardPayload, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackExceptionEvent, TrackEndEvent, TrackStuckEvent, WebSocketClosedEvent, TrackStartEvent } from "./Utils.js";
|
|
7
|
+
import type { GuildShardPayload, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackExceptionEvent, TrackEndEvent, TrackStuckEvent, WebSocketClosedEvent, TrackStartEvent, LyricsFoundEvent, LyricsNotFoundEvent, LyricsLineEvent } from "./Utils.js";
|
|
8
8
|
/**
|
|
9
9
|
* The events from the lavalink Manager
|
|
10
10
|
*/
|
|
@@ -73,6 +73,46 @@ export interface LavalinkManagerEvents {
|
|
|
73
73
|
* @event Manager#playerUpdate
|
|
74
74
|
*/
|
|
75
75
|
"playerUpdate": (oldPlayerJson: PlayerJson, newPlayer: Player) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Emitted when the player's selfMuted or serverMuted state changed (true -> false | false -> true)
|
|
78
|
+
* @event Manager#playerMuteChange
|
|
79
|
+
*/
|
|
80
|
+
"playerMuteChange": (player: Player, selfMuted: boolean, serverMuted: boolean) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Emitted when the player's selfDeafed or serverDeafed state changed (true -> false | false -> true)
|
|
83
|
+
* @event Manager#playerDeafChange
|
|
84
|
+
*/
|
|
85
|
+
"playerDeafChange": (player: Player, selfDeafed: boolean, serverDeafed: boolean) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Emitted when the player's suppressed (true -> false | false -> true)
|
|
88
|
+
* @event Manager#playerSuppressChange
|
|
89
|
+
*/
|
|
90
|
+
"playerSuppressChange": (player: Player, suppress: boolean) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Emitted when the player's queue got empty, and the timeout started
|
|
93
|
+
* @event Manager#playerQueueEmptyStart
|
|
94
|
+
*/
|
|
95
|
+
"playerQueueEmptyStart": (player: Player, timeoutMs: number) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Emitted when the player's queue got empty, and the timeout finished leading to destroying the player
|
|
98
|
+
* @event Manager#playerQueueEmptyEnd
|
|
99
|
+
*/
|
|
100
|
+
"playerQueueEmptyEnd": (player: Player) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Emitted when the player's queue got empty, and the timeout got cancelled becuase a track got re-added to it.
|
|
103
|
+
* @event Manager#playerQueueEmptyEnd
|
|
104
|
+
*/
|
|
105
|
+
"playerQueueEmptyCancel": (player: Player) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Emitted, when a user joins the voice channel, while there is a player existing
|
|
108
|
+
* @event Manager#playerQueueEmptyStart
|
|
109
|
+
*/
|
|
110
|
+
"playerVoiceJoin": (player: Player, userId: string) => void;
|
|
111
|
+
/**
|
|
112
|
+
* Emitted, when a user leaves the voice channel, while there is a player existing
|
|
113
|
+
* @event Manager#playerQueueEmptyEnd
|
|
114
|
+
*/
|
|
115
|
+
"playerVoiceLeave": (player: Player, userId: string) => void;
|
|
76
116
|
/**
|
|
77
117
|
* SPONSORBLOCK-PLUGIN EVENT
|
|
78
118
|
* Emitted when Segments are loaded
|
|
@@ -114,6 +154,24 @@ export interface LavalinkManagerEvents {
|
|
|
114
154
|
error?: Error | string;
|
|
115
155
|
functionLayer: string;
|
|
116
156
|
}) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Emitted when a Lyrics line is received
|
|
159
|
+
* @link https://github.com/topi314/LavaLyrics
|
|
160
|
+
* @event Manager#LyricsLine
|
|
161
|
+
*/
|
|
162
|
+
"LyricsLine": (player: Player, track: Track | UnresolvedTrack | null, payload: LyricsLineEvent) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Emitted when a Lyrics is found
|
|
165
|
+
* @link https://github.com/topi314/LavaLyrics
|
|
166
|
+
* @event Manager#LyricsFound
|
|
167
|
+
*/
|
|
168
|
+
"LyricsFound": (player: Player, track: Track | UnresolvedTrack | null, payload: LyricsFoundEvent) => void;
|
|
169
|
+
/**
|
|
170
|
+
* Emitted when a Lyrics is not found
|
|
171
|
+
* @link https://github.com/topi314/LavaLyrics
|
|
172
|
+
* @event Manager#LyricsNotFound
|
|
173
|
+
*/
|
|
174
|
+
"LyricsNotFound": (player: Player, track: Track | UnresolvedTrack | null, payload: LyricsNotFoundEvent) => void;
|
|
117
175
|
}
|
|
118
176
|
/**
|
|
119
177
|
* The Bot client Options needed for the manager
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type internal from "stream";
|
|
3
2
|
import type { LavalinkNode } from "../Node.js";
|
|
4
3
|
import type { DestroyReasonsType } from "./Player.js";
|
|
5
4
|
import type { InvalidLavalinkRestRequest, LavalinkPlayer } from "./Utils.js";
|
|
5
|
+
import type { PluginInfo } from "./Track.js";
|
|
6
6
|
/** Ability to manipulate fetch requests */
|
|
7
7
|
export type ModifyRequest = (options: RequestInit & {
|
|
8
8
|
path: string;
|
|
@@ -157,6 +157,28 @@ export interface PluginObject {
|
|
|
157
157
|
/** The version of the plugin */
|
|
158
158
|
version: string;
|
|
159
159
|
}
|
|
160
|
+
export interface LyricsResult {
|
|
161
|
+
/**The name of the source */
|
|
162
|
+
sourceName: string;
|
|
163
|
+
/**The name of the provider */
|
|
164
|
+
provider: string;
|
|
165
|
+
/**The result text */
|
|
166
|
+
text: string | null;
|
|
167
|
+
/**The lyrics lines */
|
|
168
|
+
lines: LyricsLine[];
|
|
169
|
+
/**Information about the plugin */
|
|
170
|
+
plugin: PluginInfo;
|
|
171
|
+
}
|
|
172
|
+
export interface LyricsLine {
|
|
173
|
+
/**The millisecond timestamp */
|
|
174
|
+
timestamp: number;
|
|
175
|
+
/**The line duration in milliseconds */
|
|
176
|
+
duration: number | null;
|
|
177
|
+
/**The line text */
|
|
178
|
+
line: string;
|
|
179
|
+
/**Information about the plugin */
|
|
180
|
+
plugin: PluginInfo;
|
|
181
|
+
}
|
|
160
182
|
export type LavalinkNodeIdentifier = string;
|
|
161
183
|
export interface NodeManagerEvents {
|
|
162
184
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { DestroyReasons } from "../Constants.js";
|
|
1
|
+
import type { DestroyReasons, DisconnectReasons } from "../Constants.js";
|
|
2
2
|
import type { LavalinkNode } from "../Node.js";
|
|
3
3
|
import type { EQBand, FilterData, LavalinkFilterData } from "./Filters.js";
|
|
4
|
+
import type { StoredQueue } from "./Queue.js";
|
|
4
5
|
import type { Track, UnresolvedTrack } from "./Track.js";
|
|
5
6
|
import type { Base64, LavalinkPlayerVoiceOptions } from "./Utils.js";
|
|
6
7
|
export type DestroyReasonsType = keyof typeof DestroyReasons | string;
|
|
8
|
+
export type DisconnectReasonsType = keyof typeof DisconnectReasons | string;
|
|
7
9
|
export interface PlayerJson {
|
|
8
10
|
/** Guild Id where the player was playing in */
|
|
9
11
|
guildId: string;
|
|
@@ -46,6 +48,8 @@ export interface PlayerJson {
|
|
|
46
48
|
nodeId?: string;
|
|
47
49
|
/** The SessionId of the node */
|
|
48
50
|
nodeSessionId?: string;
|
|
51
|
+
/** The stored queue */
|
|
52
|
+
queue?: StoredQueue;
|
|
49
53
|
}
|
|
50
54
|
export type RepeatMode = "queue" | "track" | "off";
|
|
51
55
|
export interface PlayerOptions {
|
|
@@ -4,17 +4,17 @@ export interface StoredQueue {
|
|
|
4
4
|
previous: Track[];
|
|
5
5
|
tracks: (Track | UnresolvedTrack)[];
|
|
6
6
|
}
|
|
7
|
-
export interface QueueStoreManager
|
|
7
|
+
export interface QueueStoreManager {
|
|
8
8
|
/** @async get a Value (MUST RETURN UNPARSED!) */
|
|
9
|
-
get: (guildId:
|
|
9
|
+
get: (guildId: string) => Promise<StoredQueue | string>;
|
|
10
10
|
/** @async Set a value inside a guildId (MUST BE UNPARSED) */
|
|
11
|
-
set: (guildId:
|
|
11
|
+
set: (guildId: string, value: StoredQueue | string) => Promise<void | boolean>;
|
|
12
12
|
/** @async Delete a Database Value based of it's guildId */
|
|
13
|
-
delete: (guildId:
|
|
13
|
+
delete: (guildId: string) => Promise<void | boolean>;
|
|
14
14
|
/** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
15
|
-
stringify: (value:
|
|
15
|
+
stringify: (value: StoredQueue | string) => Promise<StoredQueue | string>;
|
|
16
16
|
/** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
17
|
-
parse: (value:
|
|
17
|
+
parse: (value: StoredQueue | string) => Promise<Partial<StoredQueue>>;
|
|
18
18
|
}
|
|
19
19
|
export interface ManagerQueueOptions {
|
|
20
20
|
/** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
|
|
@@ -5,8 +5,10 @@ import type { Base64 } from "./Utils.js";
|
|
|
5
5
|
export type LavalinkSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
|
|
6
6
|
/** Source Names provided by lava src plugin */
|
|
7
7
|
export type LavalinkPlugin_LavaSrc_SourceNames = "deezer" | "spotify" | "applemusic" | "yandexmusic" | "flowery-tts";
|
|
8
|
+
/** Source Names provided by jiosaavan plugin */
|
|
9
|
+
export type LavalinkPlugin_JioSaavn_SourceNames = "jiosaavn";
|
|
8
10
|
/** The SourceNames provided by lavalink */
|
|
9
|
-
export type SourceNames = LavalinkSourceNames | LavalinkPlugin_LavaSrc_SourceNames;
|
|
11
|
+
export type SourceNames = LavalinkSourceNames | LavalinkPlugin_LavaSrc_SourceNames | LavalinkPlugin_JioSaavn_SourceNames;
|
|
10
12
|
export interface LavalinkTrackInfo {
|
|
11
13
|
/** The Identifier of the Track */
|
|
12
14
|
identifier: string;
|