lavalink-client 2.3.1 → 2.3.4

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.
Files changed (33) hide show
  1. package/README.md +35 -22
  2. package/dist/cjs/package.json +3 -0
  3. package/dist/cjs/structures/Constants.d.ts +44 -1
  4. package/dist/cjs/structures/Constants.js +45 -1
  5. package/dist/cjs/structures/LavalinkManager.js +80 -5
  6. package/dist/cjs/structures/Node.js +202 -20
  7. package/dist/cjs/structures/NodeManager.d.ts +1 -1
  8. package/dist/cjs/structures/NodeManager.js +2 -2
  9. package/dist/cjs/structures/Player.d.ts +0 -1
  10. package/dist/cjs/structures/Player.js +98 -8
  11. package/dist/cjs/structures/Queue.js +29 -2
  12. package/dist/cjs/structures/Types/Manager.d.ts +25 -0
  13. package/dist/cjs/structures/Types/Queue.d.ts +1 -1
  14. package/dist/cjs/structures/Utils.js +89 -23
  15. package/dist/esm/package.json +3 -0
  16. package/dist/esm/structures/Constants.d.ts +44 -1
  17. package/dist/esm/structures/Constants.js +44 -0
  18. package/dist/esm/structures/LavalinkManager.js +81 -6
  19. package/dist/esm/structures/Node.js +203 -21
  20. package/dist/esm/structures/NodeManager.d.ts +1 -1
  21. package/dist/esm/structures/NodeManager.js +1 -1
  22. package/dist/esm/structures/Player.d.ts +0 -1
  23. package/dist/esm/structures/Player.js +98 -8
  24. package/dist/esm/structures/Queue.js +29 -2
  25. package/dist/esm/structures/Types/Manager.d.ts +25 -0
  26. package/dist/esm/structures/Types/Queue.d.ts +1 -1
  27. package/dist/esm/structures/Utils.js +89 -23
  28. package/dist/types/structures/Constants.d.ts +44 -1
  29. package/dist/types/structures/NodeManager.d.ts +1 -1
  30. package/dist/types/structures/Player.d.ts +0 -1
  31. package/dist/types/structures/Types/Manager.d.ts +25 -0
  32. package/dist/types/structures/Types/Queue.d.ts +1 -1
  33. package/package.json +13 -6
package/README.md CHANGED
@@ -189,28 +189,10 @@ client.lavalink = new LavalinkManager({
189
189
 
190
190
  ## How to do resuming
191
191
 
192
- ```js
193
- // 1. while the player is playing, make sure to enable it:
194
- const durationToKeepPlayingInMS = 600_000;
195
- await player.node.updateSession(true, durationToKeepPlayingInMS);
196
- ```
197
-
198
- ```js
199
- // 2. make sure to have an eventlistener for resuming events somewhere
200
- client.lavalink.nodeManager.on("resumed", (node, payload, fetchedPlayers) => {
201
- // create players:
202
- for(const fetchedPlayer of fetchedPlayers) {
203
- const player = client.lavalink.createPlayer({
204
- guildId: fetchedPlayer.guildId,
205
- });
206
- player.setVolume(fetchedPlayer.volume);
207
- // and apply other things (e.g. paused, voice, filters, state, ...) (stuff like vc channel, text channel you need to store somewhere)
208
- await player.queue.utils.sync(); // only works with a queuestore
209
- // you can now overwride the player.queue.current track from the fetchedPlayer, or use the one from the queue.uztils.sync function
210
- // continue with your resuming code...
211
- }
212
- })
213
- ```
192
+ 1. You need to enable resuming on a __connected__ Lavalink node : **` node.updateSession(true, 360e3) `**
193
+ 2. The NodeManager#resumed event will emit when the node resumes, you retrieves all fetchedPlayers (fetched by the client), and thus all you need to do is re-create all player instances (and possibly the queues too)
194
+ - For that is the queuestore useful
195
+ - To save the playerData you can utilize smt like playerUpdate event.
214
196
 
215
197
  ## Resuming full Example
216
198
  Full code sample: can be found on the [Testbot in here](https://github.com/Tomato6966/lavalink-client/blob/main/testBot/Utils/handleResuming.ts)
@@ -504,3 +486,34 @@ if(previousTrack) {
504
486
  - *This is technically better than skipping to a track but i wanted to point it out.*
505
487
  - You can play with clientTrack like this: `player.play({ clientTrack: searchResult.tracks[0] })`
506
488
  - You can play with just track like this: `player.play({ track: { encoded: "base64string..." }, requester: interaction.user })`
489
+
490
+
491
+ ## **Version 2.3.1**
492
+
493
+ - Fixed Export, where types of Manager weren't exported correctly
494
+ - Fixed Dist Folder containing old, left over not needed files
495
+
496
+ ## **Version 2.3.2**
497
+ - Added Missing function calls for the QueueWatcher of tracksRemoved within the queue.remove() function:
498
+ - Added new DestroyReasons:
499
+ - TrackStuckMaxTracksErroredPerTime
500
+ - TrackErrorMaxTracksErroredPerTime
501
+ - Added new Prevention Systems for CrashbackLoop recognitions:
502
+ - `this.NodeManager.LavalinkManager.options.playerOptions.maxErrorsPerTime`:
503
+ - object: `{ threshold: number, maxAmount: number }` (set threshold to 0 or maxAmount to -1 to disable)
504
+ - Default: `{ threshold: 10_000, maxAmount: 3 }`
505
+ - If there are trackError or trackStuck Events > maxAmount within the given treshhold, the player will be destroyed prevent more errors and thus potential ratelimits.
506
+ - `this.NodeManager.LavalinkManager.options.playerOptions.minAutoPlayMs`:
507
+ - number: `10_000` (default)
508
+ - 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)*
509
+ - This prevents autoplays from happeneing on a crashbackloop
510
+ - Set to `0` to disable
511
+ - **Added new Event "debug":**
512
+ - `LavalinkManager#debug(event:DebugEvents, data:{ state: "log" | "warn" | "error", message:string, functionLayer:string, error?:Error })`
513
+ - This function Event will emit, when the following option is set to **` true `**: `LavalinkManager.options.advancedOptions.enableDebugEvents`
514
+ - You can use the **` DebugEvents `** Enum to listen to specific events and only show those you care
515
+ - You can filter for the **` data.state `** to only show the certain log-level state
516
+ - The **` functionLayer `** string will show you where the debug event was triggered from
517
+ - The **` message `** string will show what is debugged
518
+ - The **` error `** object will show you the error that happened, if there was one.
519
+ - *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!*
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -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
- console.error("Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player", oldPlayer.toJSON?.());
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
- console.error("Could not connect to at least 1 Node");
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
- console.debug("Auto reconnect", positionPrevios, player.lastPosition);
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({