lavalink-client 2.3.0 → 2.3.3
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 +31 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/structures/Constants.d.ts +44 -1
- package/dist/cjs/structures/Constants.js +45 -1
- package/dist/cjs/structures/LavalinkManager.js +80 -5
- package/dist/cjs/structures/Node.js +202 -20
- package/dist/cjs/structures/Player.d.ts +0 -1
- package/dist/cjs/structures/Player.js +73 -6
- package/dist/cjs/structures/Queue.js +29 -2
- package/dist/cjs/structures/Types/Manager.d.ts +25 -0
- package/dist/cjs/structures/Types/Queue.d.ts +1 -1
- package/dist/cjs/structures/Utils.js +68 -18
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/structures/Constants.d.ts +44 -1
- package/dist/esm/structures/Constants.js +44 -0
- package/dist/esm/structures/LavalinkManager.js +81 -6
- package/dist/esm/structures/Node.js +203 -21
- package/dist/esm/structures/Player.d.ts +0 -1
- package/dist/esm/structures/Player.js +73 -6
- package/dist/esm/structures/Queue.js +29 -2
- package/dist/esm/structures/Types/Manager.d.ts +25 -0
- package/dist/esm/structures/Types/Queue.d.ts +1 -1
- package/dist/esm/structures/Utils.js +68 -18
- package/dist/types/index.d.ts +1 -0
- package/dist/types/structures/Constants.d.ts +44 -1
- package/dist/types/structures/Player.d.ts +0 -1
- package/dist/types/structures/Types/Manager.d.ts +25 -0
- package/dist/types/structures/Types/Queue.d.ts +1 -1
- package/package.json +1 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -13
- package/dist/structures/Filters.d.ts +0 -230
- package/dist/structures/Filters.js +0 -472
- package/dist/structures/LavalinkManager.d.ts +0 -47
- package/dist/structures/LavalinkManager.js +0 -36
- package/dist/structures/LavalinkManagerStatics.d.ts +0 -3
- package/dist/structures/LavalinkManagerStatics.js +0 -76
- package/dist/structures/Node.d.ts +0 -171
- package/dist/structures/Node.js +0 -462
- package/dist/structures/NodeManager.d.ts +0 -58
- package/dist/structures/NodeManager.js +0 -25
- package/dist/structures/Player.d.ts +0 -101
- package/dist/structures/Player.js +0 -232
- package/dist/structures/PlayerManager.d.ts +0 -62
- package/dist/structures/PlayerManager.js +0 -26
- package/dist/structures/Queue.d.ts +0 -93
- package/dist/structures/Queue.js +0 -160
- package/dist/structures/QueueManager.d.ts +0 -77
- package/dist/structures/QueueManager.js +0 -74
- package/dist/structures/Track.d.ts +0 -27
- package/dist/structures/Track.js +0 -2
- package/dist/structures/Utils.d.ts +0 -183
- package/dist/structures/Utils.js +0 -43
package/README.md
CHANGED
|
@@ -504,3 +504,34 @@ if(previousTrack) {
|
|
|
504
504
|
- *This is technically better than skipping to a track but i wanted to point it out.*
|
|
505
505
|
- You can play with clientTrack like this: `player.play({ clientTrack: searchResult.tracks[0] })`
|
|
506
506
|
- You can play with just track like this: `player.play({ track: { encoded: "base64string..." }, requester: interaction.user })`
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
## **Version 2.3.1**
|
|
510
|
+
|
|
511
|
+
- Fixed Export, where types of Manager weren't exported correctly
|
|
512
|
+
- Fixed Dist Folder containing old, left over not needed files
|
|
513
|
+
|
|
514
|
+
## **Version 2.3.2**
|
|
515
|
+
- Added Missing function calls for the QueueWatcher of tracksRemoved within the queue.remove() function:
|
|
516
|
+
- Added new DestroyReasons:
|
|
517
|
+
- TrackStuckMaxTracksErroredPerTime
|
|
518
|
+
- TrackErrorMaxTracksErroredPerTime
|
|
519
|
+
- Added new Prevention Systems for CrashbackLoop recognitions:
|
|
520
|
+
- `this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime`:
|
|
521
|
+
- object: `{ threshold: number, maxAmount: number }` (set threshold to 0 or maxAmount to -1 to disable)
|
|
522
|
+
- Default: `{ threshold: 10_000, maxAmount: 3 }`
|
|
523
|
+
- If there are trackError or trackStuck Events > maxAmount within the given treshhold, the player will be destroyed prevent more errors and thus potential ratelimits.
|
|
524
|
+
- `this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs`:
|
|
525
|
+
- number: `10_000` (default)
|
|
526
|
+
- If there is an AutoplayFunction, and it get's executed before that threshold, than it won't trigger the autoplay function again. *(this is ignored for when the player is skipped)*
|
|
527
|
+
- This prevents autoplays from happeneing on a crashbackloop
|
|
528
|
+
- Set to `0` to disable
|
|
529
|
+
- **Added new Event "debug":**
|
|
530
|
+
- `LavalinkManager#debug(event:DebugEvents, data:{ state: "log" | "warn" | "error", message:string, functionLayer:string, error?:Error })`
|
|
531
|
+
- This function Event will emit, when the following option is set to **` true `**: `LavalinkManager.options.advancedOptions.enableDebugEvents`
|
|
532
|
+
- You can use the **` DebugEvents `** Enum to listen to specific events and only show those you care
|
|
533
|
+
- You can filter for the **` data.state `** to only show the certain log-level state
|
|
534
|
+
- The **` functionLayer `** string will show you where the debug event was triggered from
|
|
535
|
+
- The **` message `** string will show what is debugged
|
|
536
|
+
- The **` error `** object will show you the error that happened, if there was one.
|
|
537
|
+
- *This took quite some time to code, and i am sure there are still many logs you might want, feel free to open an issue or commit with an PR, if you think something is missing!*
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -16,3 +16,4 @@ tslib_1.__exportStar(require("./structures/Types/Player"), exports);
|
|
|
16
16
|
tslib_1.__exportStar(require("./structures/Types/Queue"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./structures/Types/Node"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./structures/Constants"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./structures/Types/Manager"), exports);
|
|
@@ -1,4 +1,45 @@
|
|
|
1
1
|
import type { AudioOutputs, ChannelMixFilter, EQBand } from "./Types/Filters";
|
|
2
|
+
export declare enum DebugEvents {
|
|
3
|
+
SetSponsorBlock = "SetSponsorBlock",
|
|
4
|
+
DeleteSponsorBlock = "DeleteSponsorBlock",
|
|
5
|
+
TrackEndReplaced = "TrackEndReplaced",
|
|
6
|
+
AutoplayNoSongsAdded = "AutoplayNoSongsAdded",
|
|
7
|
+
AutoplayThresholdSpamLimiter = "AutoplayThresholdSpamLimiter",
|
|
8
|
+
TriggerQueueEmptyInterval = "TriggerQueueEmptyInterval",
|
|
9
|
+
QueueEnded = "QueueEnded",
|
|
10
|
+
TrackStartNewSongsOnly = "TrackStartNewSongsOnly",
|
|
11
|
+
TrackStartNoTrack = "TrackStartNoTrack",
|
|
12
|
+
ResumingFetchingError = "ResumingFetchingError",
|
|
13
|
+
PlayerUpdateNoPlayer = "PlayerUpdateNoPlayer",
|
|
14
|
+
PlayerUpdateFilterFixApply = "PlayerUpdateFilterFixApply",
|
|
15
|
+
PlayerUpdateSuccess = "PlayerUpdateSuccess",
|
|
16
|
+
HeartBeatTriggered = "HeartBeatTriggered",
|
|
17
|
+
NoSocketOnDestroy = "NoSocketOnDestroy",
|
|
18
|
+
SocketTerminateHeartBeatTimeout = "SocketTerminateHeartBeatTimeout",
|
|
19
|
+
TryingConnectWhileConnected = "TryingConnectWhileConnected",
|
|
20
|
+
LavaSearchNothingFound = "LavaSearchNothingFound",
|
|
21
|
+
SearchNothingFound = "SearchNothingFound",
|
|
22
|
+
ValidatingBlacklistLinks = "ValidatingBlacklistLinks",
|
|
23
|
+
ValidatingWhitelistLinks = "ValidatingWhitelistLinks",
|
|
24
|
+
TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
|
|
25
|
+
TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime",
|
|
26
|
+
PlayerDestroyingSomewhereElse = "PlayerDestroyingSomewhereElse",
|
|
27
|
+
PlayerCreateNodeNotFound = "PlayerCreateNodeNotFound",
|
|
28
|
+
PlayerPlayQueueEmptyTimeoutClear = "PlayerPlayQueueEmptyTimeoutClear",
|
|
29
|
+
PlayerPlayWithTrackReplace = "PlayerPlayWithTrackReplace",
|
|
30
|
+
PlayerPlayUnresolvedTrack = "PlayerPlayUnresolvedTrack",
|
|
31
|
+
PlayerPlayUnresolvedTrackFailed = "PlayerPlayUnresolvedTrackFailed",
|
|
32
|
+
PlayerVolumeAsFilter = "PlayerVolumeAsFilter",
|
|
33
|
+
BandcampSearchLokalEngine = "BandcampSearchLokalEngine",
|
|
34
|
+
PlayerChangeNode = "PlayerChangeNode",
|
|
35
|
+
BuildTrackError = "BuildTrackError",
|
|
36
|
+
TransformRequesterFunctionFailed = "TransformRequesterFunctionFailed",
|
|
37
|
+
GetClosestTrackFailed = "GetClosestTrackFailed",
|
|
38
|
+
PlayerDeleteInsteadOfDestroy = "PlayerDeleteInsteadOfDestroy",
|
|
39
|
+
FailedToConnectToNodes = "FailedToConnectToNodes",
|
|
40
|
+
NoAudioDebug = "NoAudioDebug",
|
|
41
|
+
PlayerAutoReconnect = "PlayerAutoReconnect"
|
|
42
|
+
}
|
|
2
43
|
export declare enum DestroyReasons {
|
|
3
44
|
QueueEmpty = "QueueEmpty",
|
|
4
45
|
NodeDestroy = "NodeDestroy",
|
|
@@ -9,7 +50,9 @@ export declare enum DestroyReasons {
|
|
|
9
50
|
PlayerReconnectFail = "PlayerReconnectFail",
|
|
10
51
|
ChannelDeleted = "ChannelDeleted",
|
|
11
52
|
DisconnectAllNodes = "DisconnectAllNodes",
|
|
12
|
-
ReconnectAllNodes = "ReconnectAllNodes"
|
|
53
|
+
ReconnectAllNodes = "ReconnectAllNodes",
|
|
54
|
+
TrackErrorMaxTracksErroredPerTime = "TrackErrorMaxTracksErroredPerTime",
|
|
55
|
+
TrackStuckMaxTracksErroredPerTime = "TrackStuckMaxTracksErroredPerTime"
|
|
13
56
|
}
|
|
14
57
|
export declare const validSponsorBlocks: string[];
|
|
15
58
|
/** The audio Outputs Data map declaration */
|
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EQList = exports.audioOutputsData = exports.validSponsorBlocks = exports.DestroyReasons = void 0;
|
|
3
|
+
exports.EQList = exports.audioOutputsData = exports.validSponsorBlocks = exports.DestroyReasons = exports.DebugEvents = void 0;
|
|
4
|
+
var DebugEvents;
|
|
5
|
+
(function (DebugEvents) {
|
|
6
|
+
DebugEvents["SetSponsorBlock"] = "SetSponsorBlock";
|
|
7
|
+
DebugEvents["DeleteSponsorBlock"] = "DeleteSponsorBlock";
|
|
8
|
+
DebugEvents["TrackEndReplaced"] = "TrackEndReplaced";
|
|
9
|
+
DebugEvents["AutoplayNoSongsAdded"] = "AutoplayNoSongsAdded";
|
|
10
|
+
DebugEvents["AutoplayThresholdSpamLimiter"] = "AutoplayThresholdSpamLimiter";
|
|
11
|
+
DebugEvents["TriggerQueueEmptyInterval"] = "TriggerQueueEmptyInterval";
|
|
12
|
+
DebugEvents["QueueEnded"] = "QueueEnded";
|
|
13
|
+
DebugEvents["TrackStartNewSongsOnly"] = "TrackStartNewSongsOnly";
|
|
14
|
+
DebugEvents["TrackStartNoTrack"] = "TrackStartNoTrack";
|
|
15
|
+
DebugEvents["ResumingFetchingError"] = "ResumingFetchingError";
|
|
16
|
+
DebugEvents["PlayerUpdateNoPlayer"] = "PlayerUpdateNoPlayer";
|
|
17
|
+
DebugEvents["PlayerUpdateFilterFixApply"] = "PlayerUpdateFilterFixApply";
|
|
18
|
+
DebugEvents["PlayerUpdateSuccess"] = "PlayerUpdateSuccess";
|
|
19
|
+
DebugEvents["HeartBeatTriggered"] = "HeartBeatTriggered";
|
|
20
|
+
DebugEvents["NoSocketOnDestroy"] = "NoSocketOnDestroy";
|
|
21
|
+
DebugEvents["SocketTerminateHeartBeatTimeout"] = "SocketTerminateHeartBeatTimeout";
|
|
22
|
+
DebugEvents["TryingConnectWhileConnected"] = "TryingConnectWhileConnected";
|
|
23
|
+
DebugEvents["LavaSearchNothingFound"] = "LavaSearchNothingFound";
|
|
24
|
+
DebugEvents["SearchNothingFound"] = "SearchNothingFound";
|
|
25
|
+
DebugEvents["ValidatingBlacklistLinks"] = "ValidatingBlacklistLinks";
|
|
26
|
+
DebugEvents["ValidatingWhitelistLinks"] = "ValidatingWhitelistLinks";
|
|
27
|
+
DebugEvents["TrackErrorMaxTracksErroredPerTime"] = "TrackErrorMaxTracksErroredPerTime";
|
|
28
|
+
DebugEvents["TrackStuckMaxTracksErroredPerTime"] = "TrackStuckMaxTracksErroredPerTime";
|
|
29
|
+
DebugEvents["PlayerDestroyingSomewhereElse"] = "PlayerDestroyingSomewhereElse";
|
|
30
|
+
DebugEvents["PlayerCreateNodeNotFound"] = "PlayerCreateNodeNotFound";
|
|
31
|
+
DebugEvents["PlayerPlayQueueEmptyTimeoutClear"] = "PlayerPlayQueueEmptyTimeoutClear";
|
|
32
|
+
DebugEvents["PlayerPlayWithTrackReplace"] = "PlayerPlayWithTrackReplace";
|
|
33
|
+
DebugEvents["PlayerPlayUnresolvedTrack"] = "PlayerPlayUnresolvedTrack";
|
|
34
|
+
DebugEvents["PlayerPlayUnresolvedTrackFailed"] = "PlayerPlayUnresolvedTrackFailed";
|
|
35
|
+
DebugEvents["PlayerVolumeAsFilter"] = "PlayerVolumeAsFilter";
|
|
36
|
+
DebugEvents["BandcampSearchLokalEngine"] = "BandcampSearchLokalEngine";
|
|
37
|
+
DebugEvents["PlayerChangeNode"] = "PlayerChangeNode";
|
|
38
|
+
DebugEvents["BuildTrackError"] = "BuildTrackError";
|
|
39
|
+
DebugEvents["TransformRequesterFunctionFailed"] = "TransformRequesterFunctionFailed";
|
|
40
|
+
DebugEvents["GetClosestTrackFailed"] = "GetClosestTrackFailed";
|
|
41
|
+
DebugEvents["PlayerDeleteInsteadOfDestroy"] = "PlayerDeleteInsteadOfDestroy";
|
|
42
|
+
DebugEvents["FailedToConnectToNodes"] = "FailedToConnectToNodes";
|
|
43
|
+
DebugEvents["NoAudioDebug"] = "NoAudioDebug";
|
|
44
|
+
DebugEvents["PlayerAutoReconnect"] = "PlayerAutoReconnect";
|
|
45
|
+
})(DebugEvents || (exports.DebugEvents = DebugEvents = {}));
|
|
4
46
|
var DestroyReasons;
|
|
5
47
|
(function (DestroyReasons) {
|
|
6
48
|
DestroyReasons["QueueEmpty"] = "QueueEmpty";
|
|
@@ -13,6 +55,8 @@ var DestroyReasons;
|
|
|
13
55
|
DestroyReasons["ChannelDeleted"] = "ChannelDeleted";
|
|
14
56
|
DestroyReasons["DisconnectAllNodes"] = "DisconnectAllNodes";
|
|
15
57
|
DestroyReasons["ReconnectAllNodes"] = "ReconnectAllNodes";
|
|
58
|
+
DestroyReasons["TrackErrorMaxTracksErroredPerTime"] = "TrackErrorMaxTracksErroredPerTime";
|
|
59
|
+
DestroyReasons["TrackStuckMaxTracksErroredPerTime"] = "TrackStuckMaxTracksErroredPerTime";
|
|
16
60
|
})(DestroyReasons || (exports.DestroyReasons = DestroyReasons = {}));
|
|
17
61
|
;
|
|
18
62
|
exports.validSponsorBlocks = ["sponsor", "selfpromo", "interaction", "intro", "outro", "preview", "music_offtopic", "filler"];
|
|
@@ -92,9 +92,15 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
92
92
|
volumeDecrementer: options?.playerOptions?.volumeDecrementer ?? 1,
|
|
93
93
|
requesterTransformer: options?.playerOptions?.requesterTransformer ?? null,
|
|
94
94
|
useUnresolvedData: options?.playerOptions?.useUnresolvedData ?? false,
|
|
95
|
+
minAutoPlayMs: options?.playerOptions?.minAutoPlayMs ?? 10000,
|
|
96
|
+
maxErrorsPerTime: {
|
|
97
|
+
threshold: options?.playerOptions?.maxErrorsPerTime?.threshold ?? 35000,
|
|
98
|
+
maxAmount: options?.playerOptions?.maxErrorsPerTime?.maxAmount ?? 3
|
|
99
|
+
}
|
|
95
100
|
},
|
|
96
101
|
linksWhitelist: options?.linksWhitelist ?? [],
|
|
97
102
|
linksBlacklist: options?.linksBlacklist ?? [],
|
|
103
|
+
linksAllowed: options?.linksAllowed ?? true,
|
|
98
104
|
autoSkip: options?.autoSkip ?? true,
|
|
99
105
|
autoSkipOnResolveError: options?.autoSkipOnResolveError ?? true,
|
|
100
106
|
emitNewSongsOnly: options?.emitNewSongsOnly ?? false,
|
|
@@ -104,6 +110,7 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
104
110
|
queueStore: options?.queueOptions?.queueStore ?? new Queue_1.DefaultQueueStore(),
|
|
105
111
|
},
|
|
106
112
|
advancedOptions: {
|
|
113
|
+
enableDebugEvents: options?.advancedOptions?.enableDebugEvents ?? false,
|
|
107
114
|
maxFilterFixDuration: options?.advancedOptions?.maxFilterFixDuration ?? 600000,
|
|
108
115
|
debugOptions: {
|
|
109
116
|
logCustomSearches: options?.advancedOptions?.debugOptions?.logCustomSearches ?? false,
|
|
@@ -307,8 +314,13 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
307
314
|
if (oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
308
315
|
if (!this.options?.advancedOptions?.debugOptions?.playerDestroy?.dontThrowError)
|
|
309
316
|
throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${JSON.stringify(oldPlayer.toJSON?.())}`);
|
|
310
|
-
else
|
|
311
|
-
|
|
317
|
+
else if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
318
|
+
this.emit("debug", Constants_1.DebugEvents.PlayerDeleteInsteadOfDestroy, {
|
|
319
|
+
state: "warn",
|
|
320
|
+
message: "Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player",
|
|
321
|
+
functionLayer: "LavalinkManager > deletePlayer()",
|
|
322
|
+
});
|
|
323
|
+
}
|
|
312
324
|
}
|
|
313
325
|
return this.players.delete(guildId);
|
|
314
326
|
}
|
|
@@ -361,8 +373,13 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
361
373
|
}
|
|
362
374
|
if (success > 0)
|
|
363
375
|
this.initiated = true;
|
|
364
|
-
else
|
|
365
|
-
|
|
376
|
+
else if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
377
|
+
this.emit("debug", Constants_1.DebugEvents.FailedToConnectToNodes, {
|
|
378
|
+
state: "error",
|
|
379
|
+
message: "Failed to connect to at least 1 Node",
|
|
380
|
+
functionLayer: "LavalinkManager > init()",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
366
383
|
return this;
|
|
367
384
|
}
|
|
368
385
|
/**
|
|
@@ -382,11 +399,25 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
382
399
|
*/
|
|
383
400
|
async sendRawData(data) {
|
|
384
401
|
if (!this.initiated) {
|
|
402
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
403
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
404
|
+
state: "log",
|
|
405
|
+
message: "Manager is not initated yet",
|
|
406
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
407
|
+
});
|
|
408
|
+
}
|
|
385
409
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
386
410
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet");
|
|
387
411
|
return;
|
|
388
412
|
}
|
|
389
413
|
if (!("t" in data)) {
|
|
414
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
415
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
416
|
+
state: "error",
|
|
417
|
+
message: "No 't' in payload-data of the raw event:",
|
|
418
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
419
|
+
});
|
|
420
|
+
}
|
|
390
421
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
391
422
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 't' in payload-data of the raw event:", data);
|
|
392
423
|
return;
|
|
@@ -404,22 +435,50 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
404
435
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
405
436
|
const update = ("d" in data ? data.d : data);
|
|
406
437
|
if (!update) {
|
|
438
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
439
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
440
|
+
state: "warn",
|
|
441
|
+
message: `No Update data found in payload :: ${JSON.stringify(data, null, 2)}`,
|
|
442
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
443
|
+
});
|
|
444
|
+
}
|
|
407
445
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
408
446
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no update data found in payload:", data);
|
|
409
447
|
return;
|
|
410
448
|
}
|
|
411
449
|
if (!("token" in update) && !("session_id" in update)) {
|
|
450
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
451
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
452
|
+
state: "error",
|
|
453
|
+
message: `No 'token' nor 'session_id' found in payload :: ${JSON.stringify(data, null, 2)}`,
|
|
454
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
455
|
+
});
|
|
456
|
+
}
|
|
412
457
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
413
458
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, no 'token' nor 'session_id' found in payload:", data);
|
|
414
459
|
return;
|
|
415
460
|
}
|
|
416
461
|
const player = this.getPlayer(update.guild_id);
|
|
417
462
|
if (!player) {
|
|
463
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
464
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
465
|
+
state: "warn",
|
|
466
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${JSON.stringify(update, null, 2)}`,
|
|
467
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
468
|
+
});
|
|
469
|
+
}
|
|
418
470
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
419
471
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, No Lavalink Player found via key: 'guild_id' of update-data:", update);
|
|
420
472
|
return;
|
|
421
473
|
}
|
|
422
474
|
if (player.get("internal_destroystatus") === true) {
|
|
475
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
476
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
477
|
+
state: "warn",
|
|
478
|
+
message: `Player is in a destroying state. can't signal the voice states`,
|
|
479
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
480
|
+
});
|
|
481
|
+
}
|
|
423
482
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
424
483
|
console.debug("Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states");
|
|
425
484
|
return;
|
|
@@ -437,12 +496,24 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
437
496
|
}
|
|
438
497
|
}
|
|
439
498
|
});
|
|
499
|
+
if (this.options?.advancedOptions?.enableDebugEvents) {
|
|
500
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
501
|
+
state: "log",
|
|
502
|
+
message: `Sent updatePlayer for voice token session :: ${JSON.stringify({ voice: { token: update.token, endpoint: update.endpoint, sessionId: player.voice?.sessionId, }, update }, null, 2)}`,
|
|
503
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
504
|
+
});
|
|
505
|
+
}
|
|
440
506
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
441
507
|
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, } });
|
|
442
508
|
return;
|
|
443
509
|
}
|
|
444
510
|
/* voice state update */
|
|
445
511
|
if (update.user_id !== this.options?.client.id) {
|
|
512
|
+
this.emit("debug", Constants_1.DebugEvents.NoAudioDebug, {
|
|
513
|
+
state: "warn",
|
|
514
|
+
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}"`,
|
|
515
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
516
|
+
});
|
|
446
517
|
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
447
518
|
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);
|
|
448
519
|
return;
|
|
@@ -461,7 +532,11 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
461
532
|
if (this.options?.playerOptions?.onDisconnect?.autoReconnect === true) {
|
|
462
533
|
try {
|
|
463
534
|
const positionPrevios = player.position;
|
|
464
|
-
|
|
535
|
+
this.emit("debug", Constants_1.DebugEvents.PlayerAutoReconnect, {
|
|
536
|
+
state: "log",
|
|
537
|
+
message: `Auto reconnecting player because LavalinkManager.options.playerOptions.onDisconnect.autoReconnect is true`,
|
|
538
|
+
functionLayer: "LavalinkManager > sendRawData()",
|
|
539
|
+
});
|
|
465
540
|
await player.connect();
|
|
466
541
|
// replay the current playing stream
|
|
467
542
|
await player.play({
|