lavalink-client 2.3.6 → 2.4.1
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 +75 -30
- 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 +75 -30
- 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 +23 -18
|
@@ -42,29 +42,29 @@ export class FilterManager {
|
|
|
42
42
|
filterWidth: 0
|
|
43
43
|
},
|
|
44
44
|
timescale: {
|
|
45
|
-
speed: 1,
|
|
46
|
-
pitch: 1,
|
|
45
|
+
speed: 1, // 0 = x
|
|
46
|
+
pitch: 1, // 0 = x
|
|
47
47
|
rate: 1 // 0 = x
|
|
48
48
|
},
|
|
49
49
|
rotation: {
|
|
50
50
|
rotationHz: 0
|
|
51
51
|
},
|
|
52
52
|
tremolo: {
|
|
53
|
-
frequency: 0,
|
|
53
|
+
frequency: 0, // 0 < x
|
|
54
54
|
depth: 0 // 0 < x = 1
|
|
55
55
|
},
|
|
56
56
|
vibrato: {
|
|
57
|
-
frequency: 0,
|
|
57
|
+
frequency: 0, // 0 < x <= 14
|
|
58
58
|
depth: 0 // 0 < x <= 1
|
|
59
59
|
},
|
|
60
60
|
pluginFilters: {
|
|
61
61
|
"lavalink-filter-plugin": {
|
|
62
62
|
echo: {
|
|
63
|
-
delay: 0,
|
|
63
|
+
delay: 0, // in seconds
|
|
64
64
|
decay: 0 // 0 < 1
|
|
65
65
|
},
|
|
66
66
|
reverb: {
|
|
67
|
-
delays: [],
|
|
67
|
+
delays: [], // [0.037, 0.042, 0.048, 0.053]
|
|
68
68
|
gains: [] // [0.84, 0.83, 0.82, 0.81]
|
|
69
69
|
}
|
|
70
70
|
},
|
|
@@ -228,8 +228,8 @@ export class FilterManager {
|
|
|
228
228
|
filterWidth: 0
|
|
229
229
|
},
|
|
230
230
|
timescale: {
|
|
231
|
-
speed: 1,
|
|
232
|
-
pitch: 1,
|
|
231
|
+
speed: 1, // 0 = x
|
|
232
|
+
pitch: 1, // 0 = x
|
|
233
233
|
rate: 1 // 0 = x
|
|
234
234
|
},
|
|
235
235
|
pluginFilters: {
|
|
@@ -264,11 +264,11 @@ export class FilterManager {
|
|
|
264
264
|
rotationHz: 0
|
|
265
265
|
},
|
|
266
266
|
tremolo: {
|
|
267
|
-
frequency: 0,
|
|
267
|
+
frequency: 0, // 0 < x
|
|
268
268
|
depth: 0 // 0 < x = 1
|
|
269
269
|
},
|
|
270
270
|
vibrato: {
|
|
271
|
-
frequency: 0,
|
|
271
|
+
frequency: 0, // 0 < x = 14
|
|
272
272
|
depth: 0 // 0 < x = 1
|
|
273
273
|
},
|
|
274
274
|
channelMix: audioOutputsData.stereo,
|
|
@@ -428,6 +428,12 @@ export class FilterManager {
|
|
|
428
428
|
return this.filters.lowPass;
|
|
429
429
|
}
|
|
430
430
|
lavalinkLavaDspxPlugin = {
|
|
431
|
+
/**
|
|
432
|
+
* Enables / Disables the LowPass effect, (Optional: provide your Own Data)
|
|
433
|
+
* @param boostFactor
|
|
434
|
+
* @param cutoffFrequency
|
|
435
|
+
* @returns
|
|
436
|
+
*/
|
|
431
437
|
toggleLowPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
432
438
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
433
439
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -452,6 +458,12 @@ export class FilterManager {
|
|
|
452
458
|
await this.applyPlayerFilters();
|
|
453
459
|
return this.filters.lavalinkLavaDspxPlugin.lowPass;
|
|
454
460
|
},
|
|
461
|
+
/**
|
|
462
|
+
* Enables / Disables the HighPass effect, (Optional: provide your Own Data)
|
|
463
|
+
* @param boostFactor
|
|
464
|
+
* @param cutoffFrequency
|
|
465
|
+
* @returns
|
|
466
|
+
*/
|
|
455
467
|
toggleHighPass: async (boostFactor = 1.0, cutoffFrequency = 80) => {
|
|
456
468
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
457
469
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -476,6 +488,12 @@ export class FilterManager {
|
|
|
476
488
|
await this.applyPlayerFilters();
|
|
477
489
|
return this.filters.lavalinkLavaDspxPlugin.highPass;
|
|
478
490
|
},
|
|
491
|
+
/**
|
|
492
|
+
* Enables / Disables the Normalization effect.
|
|
493
|
+
* @param {number} [maxAmplitude=0.75] - The maximum amplitude of the audio.
|
|
494
|
+
* @param {boolean} [adaptive=true] - Whether to use adaptive normalization or not.
|
|
495
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
496
|
+
*/
|
|
479
497
|
toggleNormalization: async (maxAmplitude = 0.75, adaptive = true) => {
|
|
480
498
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
481
499
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -500,6 +518,12 @@ export class FilterManager {
|
|
|
500
518
|
await this.applyPlayerFilters();
|
|
501
519
|
return this.filters.lavalinkLavaDspxPlugin.normalization;
|
|
502
520
|
},
|
|
521
|
+
/**
|
|
522
|
+
* Enables / Disables the Echo effect, IMPORTANT! Only works with the correct Lavalink Plugin installed. (Optional: provide your Own Data)
|
|
523
|
+
* @param {number} [decay=0.5] - The decay of the echo effect.
|
|
524
|
+
* @param {number} [echoLength=0.5] - The length of the echo effect.
|
|
525
|
+
* @returns {Promise<boolean>} - The state of the filter after execution.
|
|
526
|
+
*/
|
|
503
527
|
toggleEcho: async (decay = 0.5, echoLength = 0.5) => {
|
|
504
528
|
if (this.player.node.info && !this.player.node.info?.plugins?.find(v => v.name === "lavadspx-plugin"))
|
|
505
529
|
throw new Error("Node#Info#plugins does not include the lavadspx plugin");
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { EventEmitter } from "events";
|
|
3
2
|
import { NodeManager } from "./NodeManager.js";
|
|
4
3
|
import { Player } from "./Player.js";
|
|
@@ -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
|
|
@@ -89,9 +89,9 @@ export class LavalinkManager extends EventEmitter {
|
|
|
89
89
|
volumeDecrementer: options?.playerOptions?.volumeDecrementer ?? 1,
|
|
90
90
|
requesterTransformer: options?.playerOptions?.requesterTransformer ?? null,
|
|
91
91
|
useUnresolvedData: options?.playerOptions?.useUnresolvedData ?? false,
|
|
92
|
-
minAutoPlayMs: options?.playerOptions?.minAutoPlayMs ??
|
|
92
|
+
minAutoPlayMs: options?.playerOptions?.minAutoPlayMs ?? 10_000,
|
|
93
93
|
maxErrorsPerTime: {
|
|
94
|
-
threshold: options?.playerOptions?.maxErrorsPerTime?.threshold ??
|
|
94
|
+
threshold: options?.playerOptions?.maxErrorsPerTime?.threshold ?? 35_000,
|
|
95
95
|
maxAmount: options?.playerOptions?.maxErrorsPerTime?.maxAmount ?? 3
|
|
96
96
|
}
|
|
97
97
|
},
|
|
@@ -108,7 +108,7 @@ export class LavalinkManager extends EventEmitter {
|
|
|
108
108
|
},
|
|
109
109
|
advancedOptions: {
|
|
110
110
|
enableDebugEvents: options?.advancedOptions?.enableDebugEvents ?? false,
|
|
111
|
-
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ??
|
|
111
|
+
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ?? 600_000,
|
|
112
112
|
debugOptions: {
|
|
113
113
|
logCustomSearches: options?.advancedOptions?.debugOptions?.logCustomSearches ?? false,
|
|
114
114
|
noAudio: options?.advancedOptions?.debugOptions?.noAudio ?? false,
|
|
@@ -483,34 +483,51 @@ export class LavalinkManager extends EventEmitter {
|
|
|
483
483
|
if ("token" in update) {
|
|
484
484
|
if (!player.node?.sessionId)
|
|
485
485
|
throw new Error("Lavalink Node is either not ready or not up to date");
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
playerOptions: {
|
|
489
|
-
voice: {
|
|
490
|
-
token: update.token,
|
|
491
|
-
endpoint: update.endpoint,
|
|
492
|
-
sessionId: player.voice?.sessionId,
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
486
|
+
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : undefined);
|
|
487
|
+
if (!sessionId2Use) {
|
|
497
488
|
this.emit("debug", DebugEvents.NoAudioDebug, {
|
|
498
|
-
state: "
|
|
499
|
-
message: `
|
|
489
|
+
state: "error",
|
|
490
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${JSON.stringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, }, update, playerVoice: player.voice }, null, 2)}`,
|
|
500
491
|
functionLayer: "LavalinkManager > sendRawData()",
|
|
501
492
|
});
|
|
493
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
494
|
+
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session", { voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, }, playerVoice: player.voice, update });
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
await player.node.updatePlayer({
|
|
498
|
+
guildId: player.guildId,
|
|
499
|
+
playerOptions: {
|
|
500
|
+
voice: {
|
|
501
|
+
token: update.token,
|
|
502
|
+
endpoint: update.endpoint,
|
|
503
|
+
sessionId: sessionId2Use,
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
508
|
+
this.emit("debug", DebugEvents.NoAudioDebug, {
|
|
509
|
+
state: "log",
|
|
510
|
+
message: `Sent updatePlayer for voice token session :: ${JSON.stringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, }, update, playerVoice: player.voice }, null, 2)}`,
|
|
511
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
515
|
+
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Can't send updatePlayer for voice token session - Missing sessionId", { voice: { token: update.token, endpoint: update.endpoint, sessionId: sessionId2Use, } });
|
|
502
516
|
}
|
|
503
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
504
|
-
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Sent updatePlayer for voice token session", { voice: { token: update.token, endpoint: update.endpoint, sessionId: player.voice?.sessionId, } });
|
|
505
517
|
return;
|
|
506
518
|
}
|
|
507
519
|
/* voice state update */
|
|
508
520
|
if (update.user_id !== this.options?.client.id) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
521
|
+
if (update.user_id && player.voiceChannelId) {
|
|
522
|
+
this.emit(update.channel_id === player.voiceChannelId ? "playerVoiceJoin" : "playerVoiceLeave", player, update.user_id);
|
|
523
|
+
}
|
|
524
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
525
|
+
this.emit("debug", DebugEvents.NoAudioDebug, {
|
|
526
|
+
state: "warn",
|
|
527
|
+
message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
|
|
528
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
529
|
+
});
|
|
530
|
+
}
|
|
514
531
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
515
532
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, voice update user is not equal to provided client id of the manageroptions#client#id", "user:", update.user_id, "manager client id:", this.options?.client.id);
|
|
516
533
|
return;
|
|
@@ -518,8 +535,35 @@ export class LavalinkManager extends EventEmitter {
|
|
|
518
535
|
if (update.channel_id) {
|
|
519
536
|
if (player.voiceChannelId !== update.channel_id)
|
|
520
537
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
521
|
-
player.voice.sessionId = update.session_id;
|
|
538
|
+
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
539
|
+
if (!player.voice.sessionId) {
|
|
540
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
541
|
+
this.emit("debug", DebugEvents.NoAudioDebug, {
|
|
542
|
+
state: "warn",
|
|
543
|
+
message: `Function to assing sessionId provided, but no found in Payload: ${JSON.stringify({ update, playerVoice: player.voice }, null, 2)}`,
|
|
544
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
548
|
+
console.debug(`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${JSON.stringify(update, null, 2)}`);
|
|
549
|
+
}
|
|
522
550
|
player.voiceChannelId = update.channel_id;
|
|
551
|
+
const selfMuteChanged = typeof update.self_mute === "boolean" && player.voiceState.selfMute !== update.self_mute;
|
|
552
|
+
const serverMuteChanged = typeof update.mute === "boolean" && player.voiceState.serverMute !== update.mute;
|
|
553
|
+
const selfDeafChanged = typeof update.self_deaf === "boolean" && player.voiceState.selfDeaf !== update.self_deaf;
|
|
554
|
+
const serverDeafChanged = typeof update.deaf === "boolean" && player.voiceState.serverDeaf !== update.deaf;
|
|
555
|
+
const suppressChange = typeof update.suppress === "boolean" && player.voiceState.suppress !== update.suppress;
|
|
556
|
+
player.voiceState.selfDeaf = update.self_deaf ?? player.voiceState?.selfDeaf;
|
|
557
|
+
player.voiceState.selfMute = update.self_mute ?? player.voiceState?.selfMute;
|
|
558
|
+
player.voiceState.serverDeaf = update.deaf ?? player.voiceState?.serverDeaf;
|
|
559
|
+
player.voiceState.serverMute = update.mute ?? player.voiceState?.serverMute;
|
|
560
|
+
player.voiceState.suppress = update.suppress ?? player.voiceState?.suppress;
|
|
561
|
+
if (selfMuteChanged || serverMuteChanged)
|
|
562
|
+
this.emit("playerMuteChange", player, player.voiceState.selfMute, player.voiceState.serverMute);
|
|
563
|
+
if (selfDeafChanged || serverDeafChanged)
|
|
564
|
+
this.emit("playerDeafChange", player, player.voiceState.selfDeaf, player.voiceState.serverDeaf);
|
|
565
|
+
if (suppressChange)
|
|
566
|
+
this.emit("playerSuppressChange", player, player.voiceState.suppress);
|
|
523
567
|
}
|
|
524
568
|
else {
|
|
525
569
|
if (this.options?.playerOptions?.onDisconnect?.destroyPlayer === true) {
|
|
@@ -529,11 +573,13 @@ export class LavalinkManager extends EventEmitter {
|
|
|
529
573
|
if (this.options?.playerOptions?.onDisconnect?.autoReconnect === true) {
|
|
530
574
|
try {
|
|
531
575
|
const positionPrevios = player.position;
|
|
532
|
-
this.
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
576
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
577
|
+
this.emit("debug", DebugEvents.PlayerAutoReconnect, {
|
|
578
|
+
state: "log",
|
|
579
|
+
message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
|
|
580
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
581
|
+
});
|
|
582
|
+
}
|
|
537
583
|
await player.connect();
|
|
538
584
|
// replay the current playing stream
|
|
539
585
|
await player.play({
|
|
@@ -551,7 +597,6 @@ export class LavalinkManager extends EventEmitter {
|
|
|
551
597
|
player.voice = Object.assign({});
|
|
552
598
|
return;
|
|
553
599
|
}
|
|
554
|
-
return;
|
|
555
600
|
}
|
|
556
601
|
}
|
|
557
602
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Player } from "./Player.js";
|
|
2
|
-
import type { DestroyReasonsType } from "./Types/Player.js";
|
|
2
|
+
import type { DestroyReasonsType, DisconnectReasonsType } from "./Types/Player.js";
|
|
3
3
|
import type { Track } from "./Types/Track.js";
|
|
4
4
|
import type { Base64, InvalidLavalinkRestRequest, LavalinkPlayer, LavaSearchQuery, LavaSearchResponse, PlayerUpdateInfo, RoutePlanner, SearchQuery, SearchResult, Session } from "./Types/Utils.js";
|
|
5
5
|
import type { NodeManager } from "./NodeManager.js";
|
|
@@ -13,6 +13,7 @@ export declare class LavalinkNode {
|
|
|
13
13
|
get heartBeatPing(): number;
|
|
14
14
|
private heartBeatInterval?;
|
|
15
15
|
private pingTimeout?;
|
|
16
|
+
isAlive: boolean;
|
|
16
17
|
/** The provided Options of the Node */
|
|
17
18
|
options: LavalinkNodeOptions;
|
|
18
19
|
/** The amount of rest calls the node has made. */
|
|
@@ -88,7 +89,8 @@ export declare class LavalinkNode {
|
|
|
88
89
|
* player.node.request(`/loadtracks?identifier=Never gonna give you up`, (options) => options.method = "GET", false);
|
|
89
90
|
* ```
|
|
90
91
|
*/
|
|
91
|
-
request(endpoint: string, modify
|
|
92
|
+
request(endpoint: string, modify: ModifyRequest | undefined, parseAsText: true): Promise<string>;
|
|
93
|
+
request(endpoint: string, modify?: ModifyRequest, parseAsText?: false): Promise<any>;
|
|
92
94
|
/**
|
|
93
95
|
* Search something raw on the node, please note only add tracks to players of that node
|
|
94
96
|
* @param query SearchQuery Object
|
|
@@ -109,7 +111,7 @@ export declare class LavalinkNode {
|
|
|
109
111
|
* @param query LavaSearchQuery Object
|
|
110
112
|
* @param requestUser Request User for creating the player(s)
|
|
111
113
|
* @param throwOnEmpty Wether to throw on an empty result or not
|
|
112
|
-
* @returns LavaSearchresult
|
|
114
|
+
* @returns LavaSearchresult (SearchResult if link is provided)
|
|
113
115
|
*
|
|
114
116
|
* @example
|
|
115
117
|
* ```ts
|
|
@@ -117,7 +119,7 @@ export declare class LavalinkNode {
|
|
|
117
119
|
* player.node.lavaSearch({ types: ["playlist", "album"], query: "Rick Astley", source: "spotify" }, interaction.user);
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
|
-
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<
|
|
122
|
+
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<LavaSearchResponse | SearchResult>;
|
|
121
123
|
/**
|
|
122
124
|
* Update the Player State on the Lavalink Server
|
|
123
125
|
* @param data data to send to lavalink and sync locally
|
|
@@ -141,7 +143,7 @@ export declare class LavalinkNode {
|
|
|
141
143
|
* player.node.destroyPlayer(player.guildId);
|
|
142
144
|
* ```
|
|
143
145
|
*/
|
|
144
|
-
destroyPlayer(guildId: any): Promise<
|
|
146
|
+
destroyPlayer(guildId: any): Promise<void>;
|
|
145
147
|
/**
|
|
146
148
|
* Connect to the Lavalink Node
|
|
147
149
|
* @param sessionId Provide the Session Id of the previous connection, to resume the node and it's player(s)
|
|
@@ -169,7 +171,7 @@ export declare class LavalinkNode {
|
|
|
169
171
|
get id(): string;
|
|
170
172
|
/**
|
|
171
173
|
* Destroys the Node-Connection (Websocket) and all player's of the node
|
|
172
|
-
* @param destroyReason
|
|
174
|
+
* @param destroyReason Destroy Reason to use when destroying the players
|
|
173
175
|
* @param deleteNode wether to delete the nodte from the nodes list too, if false it will emit a disconnect. @default true
|
|
174
176
|
* @returns void
|
|
175
177
|
*
|
|
@@ -179,6 +181,19 @@ export declare class LavalinkNode {
|
|
|
179
181
|
* ```
|
|
180
182
|
*/
|
|
181
183
|
destroy(destroyReason?: DestroyReasonsType, deleteNode?: boolean): void;
|
|
184
|
+
/**
|
|
185
|
+
* Disconnects the Node-Connection (Websocket)
|
|
186
|
+
* @param disconnectReason Disconnect Reason to use when disconnecting Node
|
|
187
|
+
* @returns void
|
|
188
|
+
*
|
|
189
|
+
* Also the node will not get re-connected again.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* player.node.destroy("custom Player Destroy Reason", true);
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
disconnect(disconnectReason?: DisconnectReasonsType): void;
|
|
182
197
|
/**
|
|
183
198
|
* Returns if connected to the Node.
|
|
184
199
|
*
|
|
@@ -189,7 +204,6 @@ export declare class LavalinkNode {
|
|
|
189
204
|
* ```
|
|
190
205
|
*/
|
|
191
206
|
get connected(): boolean;
|
|
192
|
-
isAlive: boolean;
|
|
193
207
|
/**
|
|
194
208
|
* Returns the current ConnectionStatus
|
|
195
209
|
*
|
|
@@ -214,7 +228,7 @@ export declare class LavalinkNode {
|
|
|
214
228
|
* const playersOfLavalink = await node?.fetchAllPlayers();
|
|
215
229
|
* ```
|
|
216
230
|
*/
|
|
217
|
-
fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest>;
|
|
231
|
+
fetchAllPlayers(): Promise<LavalinkPlayer[] | InvalidLavalinkRestRequest | null>;
|
|
218
232
|
/**
|
|
219
233
|
* Gets specific Player Information
|
|
220
234
|
* @returns lavalink player object if player exists on lavalink
|
|
@@ -225,7 +239,7 @@ export declare class LavalinkNode {
|
|
|
225
239
|
* const playerInformation = await node?.fetchPlayer("guildId");
|
|
226
240
|
* ```
|
|
227
241
|
*/
|
|
228
|
-
fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest>;
|
|
242
|
+
fetchPlayer(guildId: string): Promise<LavalinkPlayer | InvalidLavalinkRestRequest | null>;
|
|
229
243
|
/**
|
|
230
244
|
* Updates the session with and enables/disables resuming and timeout
|
|
231
245
|
* @param resuming Whether resuming is enabled for this session or not
|
|
@@ -238,7 +252,7 @@ export declare class LavalinkNode {
|
|
|
238
252
|
* await node?.updateSession(true, 180e3); // will enable resuming for 180seconds
|
|
239
253
|
* ```
|
|
240
254
|
*/
|
|
241
|
-
updateSession(resuming?: boolean, timeout?: number): Promise<InvalidLavalinkRestRequest |
|
|
255
|
+
updateSession(resuming?: boolean, timeout?: number): Promise<Session | InvalidLavalinkRestRequest | null>;
|
|
242
256
|
/**
|
|
243
257
|
* Decode Track or Tracks
|
|
244
258
|
*/
|
|
@@ -285,7 +299,7 @@ export declare class LavalinkNode {
|
|
|
285
299
|
* // const lyrics = await player.getLyrics(track, true);
|
|
286
300
|
* ```
|
|
287
301
|
*/
|
|
288
|
-
get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
302
|
+
get: (track: Track, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
|
|
289
303
|
/**
|
|
290
304
|
* Get the lyrics of the current playing track
|
|
291
305
|
*
|
|
@@ -299,7 +313,7 @@ export declare class LavalinkNode {
|
|
|
299
313
|
* // const lyrics = await player.getCurrentLyrics();
|
|
300
314
|
* ```
|
|
301
315
|
*/
|
|
302
|
-
getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult>;
|
|
316
|
+
getCurrent: (guildId: string, skipTrackSource?: boolean) => Promise<LyricsResult | null>;
|
|
303
317
|
/**
|
|
304
318
|
* subscribe to lyrics updates for a guild
|
|
305
319
|
* @param guildId the guild id of the player
|
|
@@ -312,7 +326,7 @@ export declare class LavalinkNode {
|
|
|
312
326
|
* // const lyrics = await player.subscribeLyrics();
|
|
313
327
|
* ```
|
|
314
328
|
*/
|
|
315
|
-
subscribe: (guildId: string) => Promise<
|
|
329
|
+
subscribe: (guildId: string) => Promise<unknown>;
|
|
316
330
|
/**
|
|
317
331
|
* unsubscribe from lyrics updates for a guild
|
|
318
332
|
* @param guildId the guild id of the player
|
|
@@ -325,7 +339,7 @@ export declare class LavalinkNode {
|
|
|
325
339
|
* // const lyrics = await player.unsubscribeLyrics();
|
|
326
340
|
* ```
|
|
327
341
|
*/
|
|
328
|
-
unsubscribe: (guildId: string) => Promise<
|
|
342
|
+
unsubscribe: (guildId: string) => Promise<void>;
|
|
329
343
|
};
|
|
330
344
|
/**
|
|
331
345
|
* Request Lavalink statistics.
|
|
@@ -385,7 +399,7 @@ export declare class LavalinkNode {
|
|
|
385
399
|
* await player.node.routePlannerApi.unmarkFailedAddress("ipv6address");
|
|
386
400
|
* ```
|
|
387
401
|
*/
|
|
388
|
-
unmarkFailedAddress: (address: string) => Promise<
|
|
402
|
+
unmarkFailedAddress: (address: string) => Promise<unknown>;
|
|
389
403
|
/**
|
|
390
404
|
* Release all blacklisted IP addresses into pool of IPs
|
|
391
405
|
* @returns request data of the request
|
|
@@ -395,7 +409,7 @@ export declare class LavalinkNode {
|
|
|
395
409
|
* await player.node.routePlannerApi.unmarkAllFailedAddresses();
|
|
396
410
|
* ```
|
|
397
411
|
*/
|
|
398
|
-
unmarkAllFailedAddresses: () => Promise<
|
|
412
|
+
unmarkAllFailedAddresses: () => Promise<unknown>;
|
|
399
413
|
};
|
|
400
414
|
/** @private Utils for validating the */
|
|
401
415
|
private validate;
|