lavalink-client 2.3.6 → 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 +56 -7
- 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/Node.d.ts +30 -16
- package/dist/cjs/structures/Node.js +165 -84
- package/dist/cjs/structures/NodeManager.d.ts +2 -2
- package/dist/cjs/structures/NodeManager.js +19 -19
- package/dist/cjs/structures/Player.d.ts +10 -3
- package/dist/cjs/structures/Player.js +12 -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 +40 -0
- package/dist/cjs/structures/Types/Node.d.ts +0 -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 +17 -2
- package/dist/cjs/structures/Utils.js +3 -10
- 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/Node.d.ts +30 -16
- package/dist/esm/structures/Node.js +165 -84
- package/dist/esm/structures/NodeManager.d.ts +2 -2
- package/dist/esm/structures/NodeManager.js +20 -20
- package/dist/esm/structures/Player.d.ts +10 -3
- package/dist/esm/structures/Player.js +12 -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 +40 -0
- package/dist/esm/structures/Types/Node.d.ts +0 -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 +17 -2
- package/dist/esm/structures/Utils.js +0 -7
- 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/Node.d.ts +30 -16
- package/dist/types/structures/NodeManager.d.ts +2 -2
- package/dist/types/structures/Player.d.ts +10 -3
- package/dist/types/structures/Queue.d.ts +9 -10
- package/dist/types/structures/Types/Manager.d.ts +40 -0
- package/dist/types/structures/Types/Node.d.ts +0 -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 +17 -2
- 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;
|
|
@@ -52,6 +52,13 @@ export declare class Player {
|
|
|
52
52
|
connected: boolean | undefined;
|
|
53
53
|
/** Voice Server Data (from Lavalink) */
|
|
54
54
|
voice: LavalinkPlayerVoiceOptions;
|
|
55
|
+
voiceState: {
|
|
56
|
+
selfDeaf: boolean;
|
|
57
|
+
selfMute: boolean;
|
|
58
|
+
serverDeaf: boolean;
|
|
59
|
+
serverMute: boolean;
|
|
60
|
+
suppress: boolean;
|
|
61
|
+
};
|
|
55
62
|
/** Custom data for the player */
|
|
56
63
|
private readonly data;
|
|
57
64
|
/**
|
|
@@ -97,7 +104,7 @@ export declare class Player {
|
|
|
97
104
|
* @param throwOnEmpty If an error should be thrown if no track is found
|
|
98
105
|
* @returns The search result
|
|
99
106
|
*/
|
|
100
|
-
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>;
|
|
101
108
|
/**
|
|
102
109
|
* Set the SponsorBlock
|
|
103
110
|
* @param segments The segments to set
|
|
@@ -196,7 +203,7 @@ export declare class Player {
|
|
|
196
203
|
* const lyrics = await player.subscribeLyrics();
|
|
197
204
|
* ```
|
|
198
205
|
*/
|
|
199
|
-
subscribeLyrics(): Promise<
|
|
206
|
+
subscribeLyrics(): Promise<unknown>;
|
|
200
207
|
/**
|
|
201
208
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
202
209
|
* @param guildId The guild id to unsubscribe from
|
|
@@ -206,7 +213,7 @@ export declare class Player {
|
|
|
206
213
|
* const lyrics = await player.unsubscribeLyrics();
|
|
207
214
|
* ```
|
|
208
215
|
*/
|
|
209
|
-
unsubscribeLyrics(guildId: string): Promise<
|
|
216
|
+
unsubscribeLyrics(guildId: string): Promise<void>;
|
|
210
217
|
/**
|
|
211
218
|
* Move the player on a different Audio-Node
|
|
212
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, {
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -236,8 +236,7 @@ export interface LavalinkPlayerVoice {
|
|
|
236
236
|
/** The Ping to the voice server */
|
|
237
237
|
ping?: number;
|
|
238
238
|
}
|
|
239
|
-
export
|
|
240
|
-
}
|
|
239
|
+
export type LavalinkPlayerVoiceOptions = Omit<LavalinkPlayerVoice, 'connected' | 'ping'>;
|
|
241
240
|
export interface FailingAddress {
|
|
242
241
|
/** The failing address */
|
|
243
242
|
failingAddress: string;
|
|
@@ -353,6 +352,22 @@ export interface VoiceState {
|
|
|
353
352
|
session_id: string;
|
|
354
353
|
/** Voice Channel Id */
|
|
355
354
|
channel_id: string;
|
|
355
|
+
/** Server Mute status */
|
|
356
|
+
mute: boolean;
|
|
357
|
+
/** Server Deaf status */
|
|
358
|
+
deaf: boolean;
|
|
359
|
+
/** Self Deaf status */
|
|
360
|
+
self_deaf: boolean;
|
|
361
|
+
/** Self Mute status */
|
|
362
|
+
self_mute: boolean;
|
|
363
|
+
/** Self Video (Camera) status */
|
|
364
|
+
self_video: boolean;
|
|
365
|
+
/** Self Stream status */
|
|
366
|
+
self_stream: boolean;
|
|
367
|
+
/** Wether the user requests to speak (stage channel) */
|
|
368
|
+
request_to_speak_timestamp: boolean;
|
|
369
|
+
/** Self suppressed status (stage channel) */
|
|
370
|
+
suppress: boolean;
|
|
356
371
|
}
|
|
357
372
|
/** The Base64 decodes tring by lavalink */
|
|
358
373
|
export type Base64 = string;
|
|
@@ -296,9 +296,6 @@ export class ManagerUtils {
|
|
|
296
296
|
if (SourceLinksRegexes.AllDeezerRegex.test(queryString) && !node.info?.sourceManagers?.includes("deezer")) {
|
|
297
297
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'deezer' enabled");
|
|
298
298
|
}
|
|
299
|
-
if (SourceLinksRegexes.AllDeezerRegex.test(queryString) && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
300
|
-
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'http' enabled, which is required to have 'deezer' to work");
|
|
301
|
-
}
|
|
302
299
|
if (SourceLinksRegexes.musicYandex.test(queryString) && !node.info?.sourceManagers?.includes("yandexmusic")) {
|
|
303
300
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'yandexmusic' enabled");
|
|
304
301
|
}
|
|
@@ -357,9 +354,6 @@ export class ManagerUtils {
|
|
|
357
354
|
if (source === "dzisrc" && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
358
355
|
throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'dzisrc' to work");
|
|
359
356
|
}
|
|
360
|
-
if (source === "dzsearch" && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
361
|
-
throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'dzsearch' to work");
|
|
362
|
-
}
|
|
363
357
|
if (source === "jsrec" && !node.info?.sourceManagers?.includes("jiosaavn")) {
|
|
364
358
|
throw new Error("Lavalink Node has not 'jiosaavn' (via jiosaavn-plugin) enabled, which is required to have 'jsrec' to work");
|
|
365
359
|
}
|
|
@@ -413,7 +407,6 @@ export class MiniMap extends Map {
|
|
|
413
407
|
const iter = this.entries();
|
|
414
408
|
return Array.from({ length: this.size }, () => {
|
|
415
409
|
const [key, value] = iter.next().value;
|
|
416
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
417
410
|
return fn(value, key, this);
|
|
418
411
|
});
|
|
419
412
|
}
|
|
@@ -55,6 +55,10 @@ export declare enum DestroyReasons {
|
|
|
55
55
|
TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
|
|
56
56
|
TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
|
|
57
57
|
}
|
|
58
|
+
export declare enum DisconnectReasons {
|
|
59
|
+
Disconnected = "Disconnected",
|
|
60
|
+
DisconnectAllNodes = "DisconnectAllNodes"
|
|
61
|
+
}
|
|
58
62
|
export declare const validSponsorBlocks: string[];
|
|
59
63
|
/** The audio Outputs Data map declaration */
|
|
60
64
|
export declare const audioOutputsData: Record<AudioOutputs, ChannelMixFilter>;
|
|
@@ -87,9 +87,33 @@ export declare class FilterManager {
|
|
|
87
87
|
*/
|
|
88
88
|
toggleLowPass(smoothing?: number): Promise<boolean>;
|
|
89
89
|
lavalinkLavaDspxPlugin: {
|
|
90
|
+
/**
|
|
91
|
+
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
92
|
+
* @param boostFactor
|
|
93
|
+
* @param cutoffFrequency
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
90
96
|
toggleLowPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
99
|
+
* @param boostFactor
|
|
100
|
+
* @param cutoffFrequency
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
91
103
|
toggleHighPass: (boostFactor?: number, cutoffFrequency?: number) => Promise<boolean>;
|
|
104
|
+
/**
|
|
105
|
+
* Enables / Disables the Normalization effect.
|
|
106
|
+
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
107
|
+
* @param {boolean} [adaptive=true] - Whether to use adaptive normalization or not.
|
|
108
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
109
|
+
*/
|
|
92
110
|
toggleNormalization: (maxAmplitude?: number, adaptive?: boolean) => Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
113
|
+
* @param {number} [decay=0.5] - The decay of the echo effect.
|
|
114
|
+
* @param {number} [echoLength=0.5] - The length of the echo effect.
|
|
115
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
116
|
+
*/
|
|
93
117
|
toggleEcho: (decay?: number, echoLength?: number) => Promise<boolean>;
|
|
94
118
|
};
|
|
95
119
|
lavalinkFilterPlugin: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EventEmitter } from "events";
|
|
3
2
|
import { NodeManager } from "./NodeManager";
|
|
4
3
|
import { Player } from "./Player";
|
|
@@ -137,7 +136,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
137
136
|
* ```
|
|
138
137
|
* @returns
|
|
139
138
|
*/
|
|
140
|
-
getPlayer(guildId: string): Player;
|
|
139
|
+
getPlayer(guildId: string): Player | undefined;
|
|
141
140
|
/**
|
|
142
141
|
* Create a Music-Player. If a player exists, then it returns it before creating a new one
|
|
143
142
|
* @param options
|
|
@@ -175,7 +174,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
175
174
|
* // recommend to do it on the player tho: player.destroy("forcefully destroyed the player");
|
|
176
175
|
* ```
|
|
177
176
|
*/
|
|
178
|
-
destroyPlayer(guildId: string, destroyReason?: string): Promise<Player>;
|
|
177
|
+
destroyPlayer(guildId: string, destroyReason?: string): Promise<void | Player>;
|
|
179
178
|
/**
|
|
180
179
|
* Delete's a player from the cache without destroying it on lavalink (only works when it's disconnected)
|
|
181
180
|
* @param guildId
|
|
@@ -187,7 +186,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
187
186
|
* // shouldn't be used except you know what you are doing.
|
|
188
187
|
* ```
|
|
189
188
|
*/
|
|
190
|
-
deletePlayer(guildId: string): boolean;
|
|
189
|
+
deletePlayer(guildId: string): boolean | void;
|
|
191
190
|
/**
|
|
192
191
|
* Checks wether the the lib is useable based on if any node is connected
|
|
193
192
|
*
|
|
@@ -213,7 +212,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
213
212
|
* });
|
|
214
213
|
* ```
|
|
215
214
|
*/
|
|
216
|
-
init(clientData: BotClientOptions): Promise<
|
|
215
|
+
init(clientData: BotClientOptions): Promise<LavalinkManager>;
|
|
217
216
|
/**
|
|
218
217
|
* Sends voice data to the Lavalink server.
|
|
219
218
|
* ! Without this the library won't work
|