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
|
@@ -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;
|
|
@@ -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
|
|
@@ -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, {
|
|
@@ -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
|
|
@@ -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;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MiniMap = exports.ManagerUtils = exports.NodeSymbol = exports.QueueSymbol = exports.UnresolvedTrackSymbol = exports.TrackSymbol = void 0;
|
|
4
|
+
exports.parseLavalinkConnUrl = parseLavalinkConnUrl;
|
|
5
|
+
exports.queueTrackEnd = queueTrackEnd;
|
|
4
6
|
const node_url_1 = require("node:url");
|
|
5
7
|
const types_1 = require("node:util/types");
|
|
6
8
|
const Constants_1 = require("./Constants.js");
|
|
@@ -27,7 +29,6 @@ function parseLavalinkConnUrl(connectionUrl) {
|
|
|
27
29
|
port: Number(parsed.port),
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
|
-
exports.parseLavalinkConnUrl = parseLavalinkConnUrl;
|
|
31
32
|
class ManagerUtils {
|
|
32
33
|
LavalinkManager = null;
|
|
33
34
|
constructor(LavalinkManager) {
|
|
@@ -300,9 +301,6 @@ class ManagerUtils {
|
|
|
300
301
|
if (LavalinkManagerStatics_1.SourceLinksRegexes.AllDeezerRegex.test(queryString) && !node.info?.sourceManagers?.includes("deezer")) {
|
|
301
302
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'deezer' enabled");
|
|
302
303
|
}
|
|
303
|
-
if (LavalinkManagerStatics_1.SourceLinksRegexes.AllDeezerRegex.test(queryString) && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
304
|
-
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'http' enabled, which is required to have 'deezer' to work");
|
|
305
|
-
}
|
|
306
304
|
if (LavalinkManagerStatics_1.SourceLinksRegexes.musicYandex.test(queryString) && !node.info?.sourceManagers?.includes("yandexmusic")) {
|
|
307
305
|
throw new Error("Query / Link Provided for this Source but Lavalink Node has not 'yandexmusic' enabled");
|
|
308
306
|
}
|
|
@@ -361,9 +359,6 @@ class ManagerUtils {
|
|
|
361
359
|
if (source === "dzisrc" && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
362
360
|
throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'dzisrc' to work");
|
|
363
361
|
}
|
|
364
|
-
if (source === "dzsearch" && node.info?.sourceManagers?.includes("deezer") && !node.info?.sourceManagers?.includes("http")) {
|
|
365
|
-
throw new Error("Lavalink Node has not 'http' enabled, which is required to have 'dzsearch' to work");
|
|
366
|
-
}
|
|
367
362
|
if (source === "jsrec" && !node.info?.sourceManagers?.includes("jiosaavn")) {
|
|
368
363
|
throw new Error("Lavalink Node has not 'jiosaavn' (via jiosaavn-plugin) enabled, which is required to have 'jsrec' to work");
|
|
369
364
|
}
|
|
@@ -418,7 +413,6 @@ class MiniMap extends Map {
|
|
|
418
413
|
const iter = this.entries();
|
|
419
414
|
return Array.from({ length: this.size }, () => {
|
|
420
415
|
const [key, value] = iter.next().value;
|
|
421
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
422
416
|
return fn(value, key, this);
|
|
423
417
|
});
|
|
424
418
|
}
|
|
@@ -460,7 +454,6 @@ async function queueTrackEnd(player) {
|
|
|
460
454
|
// return the new current Track
|
|
461
455
|
return player.queue.current;
|
|
462
456
|
}
|
|
463
|
-
exports.queueTrackEnd = queueTrackEnd;
|
|
464
457
|
async function applyUnresolvedData(resTrack, data, utils) {
|
|
465
458
|
if (!resTrack?.info || !data?.info)
|
|
466
459
|
return;
|
|
@@ -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>;
|
|
@@ -57,11 +57,16 @@ export var DestroyReasons;
|
|
|
57
57
|
DestroyReasons["TrackStuckMaxTracksErroredPerTime"] = "TrackStuckMaxTracksErroredPerTime";
|
|
58
58
|
})(DestroyReasons || (DestroyReasons = {}));
|
|
59
59
|
;
|
|
60
|
+
export var DisconnectReasons;
|
|
61
|
+
(function (DisconnectReasons) {
|
|
62
|
+
DisconnectReasons["Disconnected"] = "Disconnected";
|
|
63
|
+
DisconnectReasons["DisconnectAllNodes"] = "DisconnectAllNodes";
|
|
64
|
+
})(DisconnectReasons || (DisconnectReasons = {}));
|
|
60
65
|
export const validSponsorBlocks = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "filler"];
|
|
61
66
|
/** The audio Outputs Data map declaration */
|
|
62
67
|
export const audioOutputsData = {
|
|
63
68
|
mono: {
|
|
64
|
-
leftToLeft: 0.5,
|
|
69
|
+
leftToLeft: 0.5, //each channel should in total 0 | 1, 0 === off, 1 === on, 0.5+0.5 === 1
|
|
65
70
|
leftToRight: 0.5,
|
|
66
71
|
rightToLeft: 0.5,
|
|
67
72
|
rightToRight: 0.5,
|
|
@@ -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: {
|