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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { DestroyReasons } from "./Constants.js";
|
|
2
|
+
import { DestroyReasons, DisconnectReasons } from "./Constants.js";
|
|
3
3
|
import { LavalinkNode } from "./Node.js";
|
|
4
4
|
import { MiniMap } from "./Utils.js";
|
|
5
5
|
export class NodeManager extends EventEmitter {
|
|
@@ -70,18 +70,24 @@ export class NodeManager extends EventEmitter {
|
|
|
70
70
|
/**
|
|
71
71
|
* Disconnects all Nodes from lavalink ws sockets
|
|
72
72
|
* @param deleteAllNodes if the nodes should also be deleted from nodeManager.nodes
|
|
73
|
+
* @param destroyPlayers if the players should be destroyed
|
|
73
74
|
* @returns amount of disconnected Nodes
|
|
74
75
|
*/
|
|
75
|
-
async disconnectAll(deleteAllNodes = false) {
|
|
76
|
+
async disconnectAll(deleteAllNodes = false, destroyPlayers = true) {
|
|
76
77
|
if (!this.nodes.size)
|
|
77
78
|
throw new Error("There are no nodes to disconnect (no nodes in the nodemanager)");
|
|
78
79
|
if (!this.nodes.filter(v => v.connected).size)
|
|
79
80
|
throw new Error("There are no nodes to disconnect (all nodes disconnected)");
|
|
80
81
|
let counter = 0;
|
|
81
|
-
for (const node of
|
|
82
|
+
for (const node of this.nodes.values()) {
|
|
82
83
|
if (!node.connected)
|
|
83
84
|
continue;
|
|
84
|
-
|
|
85
|
+
if (destroyPlayers) {
|
|
86
|
+
await node.destroy(DestroyReasons.DisconnectAllNodes, deleteAllNodes);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
await node.disconnect(DisconnectReasons.DisconnectAllNodes);
|
|
90
|
+
}
|
|
85
91
|
counter++;
|
|
86
92
|
}
|
|
87
93
|
return counter;
|
|
@@ -96,7 +102,7 @@ export class NodeManager extends EventEmitter {
|
|
|
96
102
|
if (!this.nodes.filter(v => !v.connected).size)
|
|
97
103
|
throw new Error("There are no nodes to connect (all nodes connected)");
|
|
98
104
|
let counter = 0;
|
|
99
|
-
for (const node of
|
|
105
|
+
for (const node of this.nodes.values()) {
|
|
100
106
|
if (node.connected)
|
|
101
107
|
continue;
|
|
102
108
|
await node.connect();
|
|
@@ -112,7 +118,7 @@ export class NodeManager extends EventEmitter {
|
|
|
112
118
|
if (!this.nodes.size)
|
|
113
119
|
throw new Error("There are no nodes to reconnect (no nodes in the nodemanager)");
|
|
114
120
|
let counter = 0;
|
|
115
|
-
for (const node of
|
|
121
|
+
for (const node of this.nodes.values()) {
|
|
116
122
|
const sessionId = node.sessionId ? `${node.sessionId}` : undefined;
|
|
117
123
|
await node.destroy(DestroyReasons.ReconnectAllNodes, false);
|
|
118
124
|
await node.connect(sessionId);
|
|
@@ -138,53 +144,47 @@ export class NodeManager extends EventEmitter {
|
|
|
138
144
|
* @returns
|
|
139
145
|
*/
|
|
140
146
|
leastUsedNodes(sortType = "players") {
|
|
147
|
+
const connectedNodes = Array.from(this.nodes.values()).filter((node) => node.connected);
|
|
141
148
|
switch (sortType) {
|
|
142
149
|
case "memory":
|
|
143
150
|
{
|
|
144
|
-
return
|
|
145
|
-
.filter((node) => node.connected)
|
|
151
|
+
return connectedNodes
|
|
146
152
|
.sort((a, b) => (a.stats?.memory?.used || 0) - (b.stats?.memory?.used || 0)); // sort after memor
|
|
147
153
|
}
|
|
148
154
|
break;
|
|
149
155
|
case "cpuLavalink":
|
|
150
156
|
{
|
|
151
|
-
return
|
|
152
|
-
.filter((node) => node.connected)
|
|
157
|
+
return connectedNodes
|
|
153
158
|
.sort((a, b) => (a.stats?.cpu?.lavalinkLoad || 0) - (b.stats?.cpu?.lavalinkLoad || 0)); // sort after memor
|
|
154
159
|
}
|
|
155
160
|
break;
|
|
156
161
|
case "cpuSystem":
|
|
157
162
|
{
|
|
158
|
-
return
|
|
159
|
-
.filter((node) => node.connected)
|
|
163
|
+
return connectedNodes
|
|
160
164
|
.sort((a, b) => (a.stats?.cpu?.systemLoad || 0) - (b.stats?.cpu?.systemLoad || 0)); // sort after memor
|
|
161
165
|
}
|
|
162
166
|
break;
|
|
163
167
|
case "calls":
|
|
164
168
|
{
|
|
165
|
-
return
|
|
166
|
-
.filter((node) => node.connected)
|
|
169
|
+
return connectedNodes
|
|
167
170
|
.sort((a, b) => a.calls - b.calls); // client sided sorting
|
|
168
171
|
}
|
|
169
172
|
break;
|
|
170
173
|
case "playingPlayers":
|
|
171
174
|
{
|
|
172
|
-
return
|
|
173
|
-
.filter((node) => node.connected)
|
|
175
|
+
return connectedNodes
|
|
174
176
|
.sort((a, b) => (a.stats?.playingPlayers || 0) - (b.stats?.playingPlayers || 0));
|
|
175
177
|
}
|
|
176
178
|
break;
|
|
177
179
|
case "players":
|
|
178
180
|
{
|
|
179
|
-
return
|
|
180
|
-
.filter((node) => node.connected)
|
|
181
|
+
return connectedNodes
|
|
181
182
|
.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
182
183
|
}
|
|
183
184
|
break;
|
|
184
185
|
default:
|
|
185
186
|
{
|
|
186
|
-
return
|
|
187
|
-
.filter((node) => node.connected)
|
|
187
|
+
return connectedNodes
|
|
188
188
|
.sort((a, b) => (a.stats?.players || 0) - (b.stats?.players || 0));
|
|
189
189
|
}
|
|
190
190
|
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
|
|
@@ -56,6 +56,13 @@ export class Player {
|
|
|
56
56
|
sessionId: null,
|
|
57
57
|
token: null
|
|
58
58
|
};
|
|
59
|
+
voiceState = {
|
|
60
|
+
selfDeaf: false,
|
|
61
|
+
selfMute: false,
|
|
62
|
+
serverDeaf: false,
|
|
63
|
+
serverMute: false,
|
|
64
|
+
suppress: false,
|
|
65
|
+
};
|
|
59
66
|
/** Custom data for the player */
|
|
60
67
|
data = {};
|
|
61
68
|
/**
|
|
@@ -142,6 +149,7 @@ export class Player {
|
|
|
142
149
|
functionLayer: "Player > play()",
|
|
143
150
|
});
|
|
144
151
|
}
|
|
152
|
+
this.LavalinkManager.emit("playerQueueEmptyCancel", this);
|
|
145
153
|
clearTimeout(this.get("internal_queueempty"));
|
|
146
154
|
this.set("internal_queueempty", undefined);
|
|
147
155
|
}
|
|
@@ -540,6 +548,10 @@ export class Player {
|
|
|
540
548
|
async destroy(reason, disconnect = true) {
|
|
541
549
|
if (this.LavalinkManager.options.advancedOptions?.debugOptions.playerDestroy.debugLog)
|
|
542
550
|
console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Destroy-Reason: ${String(reason)}`);
|
|
551
|
+
if (this.get("internal_queueempty")) {
|
|
552
|
+
clearTimeout(this.get("internal_queueempty"));
|
|
553
|
+
this.set("internal_queueempty", undefined);
|
|
554
|
+
}
|
|
543
555
|
if (this.get("internal_destroystatus") === true) {
|
|
544
556
|
if (this.LavalinkManager.options?.advancedOptions?.enableDebugEvents) {
|
|
545
557
|
this.LavalinkManager.emit("debug", DebugEvents.PlayerDestroyingSomewhereElse, {
|
|
@@ -571,6 +583,56 @@ export class Player {
|
|
|
571
583
|
// return smt
|
|
572
584
|
return this;
|
|
573
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* Get the current lyrics of the track currently playing on the guild
|
|
588
|
+
* @param guildId The guild id to get the current lyrics for
|
|
589
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
590
|
+
* @returns The current lyrics
|
|
591
|
+
* @example
|
|
592
|
+
* ```ts
|
|
593
|
+
* const lyrics = await player.getCurrentLyrics();
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
async getCurrentLyrics(skipTrackSource) {
|
|
597
|
+
return await this.node.lyrics.getCurrent(this.guildId, skipTrackSource);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Get the lyrics of a specific track
|
|
601
|
+
* @param track The track to get the lyrics for
|
|
602
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
603
|
+
* @returns The lyrics of the track
|
|
604
|
+
* @example
|
|
605
|
+
* ```ts
|
|
606
|
+
* const lyrics = await player.getLyrics(player.queue.tracks[0], true);
|
|
607
|
+
* ```
|
|
608
|
+
*/
|
|
609
|
+
async getLyrics(track, skipTrackSource) {
|
|
610
|
+
return await this.node.lyrics.get(track, skipTrackSource);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
614
|
+
* @param guildId The guild id to subscribe to
|
|
615
|
+
* @returns The unsubscribe function
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* const lyrics = await player.subscribeLyrics();
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
621
|
+
subscribeLyrics() {
|
|
622
|
+
return this.node.lyrics.subscribe(this.guildId);
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
626
|
+
* @param guildId The guild id to unsubscribe from
|
|
627
|
+
* @returns The unsubscribe function
|
|
628
|
+
* @example
|
|
629
|
+
* ```ts
|
|
630
|
+
* const lyrics = await player.unsubscribeLyrics();
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
633
|
+
unsubscribeLyrics(guildId) {
|
|
634
|
+
return this.node.lyrics.unsubscribe(guildId);
|
|
635
|
+
}
|
|
574
636
|
/**
|
|
575
637
|
* Move the player on a different Audio-Node
|
|
576
638
|
* @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
|
*/
|
|
@@ -57,7 +57,7 @@ export class DefaultQueueStore {
|
|
|
57
57
|
* @returns The queue for the guild
|
|
58
58
|
*/
|
|
59
59
|
async get(guildId) {
|
|
60
|
-
return
|
|
60
|
+
return this.data.get(guildId);
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Set the queue for a guild
|
|
@@ -66,7 +66,7 @@ export class DefaultQueueStore {
|
|
|
66
66
|
* @returns The queue for the guild
|
|
67
67
|
*/
|
|
68
68
|
async set(guildId, valueToStringify) {
|
|
69
|
-
return
|
|
69
|
+
return this.data.set(guildId, valueToStringify) ? true : false;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Delete the queue for a guild
|
|
@@ -74,7 +74,7 @@ export class DefaultQueueStore {
|
|
|
74
74
|
* @returns The queue for the guild
|
|
75
75
|
*/
|
|
76
76
|
async delete(guildId) {
|
|
77
|
-
return
|
|
77
|
+
return this.data.delete(guildId);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* 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;
|