magmastream 2.10.3-alpha.2 → 2.10.3-alpha.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.
@@ -259,7 +259,7 @@ class Manager extends events_1.EventEmitter {
259
259
  break;
260
260
  }
261
261
  default:
262
- result = { loadType: lavalinkResponse.loadType };
262
+ result = { loadType: lavalinkResponse.loadType, tracks: [] };
263
263
  }
264
264
  if (this.options.normalizeYouTubeTitles && "tracks" in result) {
265
265
  const processTrack = (track) => {
@@ -29,7 +29,7 @@ class Node {
29
29
  /** Whether the node is a NodeLink. */
30
30
  isNodeLink = false;
31
31
  reconnectTimeout;
32
- reconnectAttempts = 1;
32
+ reconnectAttempts = 0;
33
33
  redisPrefix;
34
34
  /** Session ID sent in the reconnect header for resumption — cleared once the ready op is received. */
35
35
  pendingResumeSessionId = null;
@@ -313,7 +313,7 @@ class Node {
313
313
  // Always clear reconnect state regardless of connection status
314
314
  clearTimeout(this.reconnectTimeout);
315
315
  this.reconnectTimeout = undefined;
316
- this.reconnectAttempts = 1;
316
+ this.reconnectAttempts = 0;
317
317
  // Only close the socket if it is actually open
318
318
  if (this.connected) {
319
319
  this.socket.close(1000, "destroy");
@@ -349,7 +349,8 @@ class Node {
349
349
  };
350
350
  this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[NODE] Reconnecting node: ${Utils_1.JSONUtils.safe(debugInfo, 2)}`);
351
351
  this.reconnectTimeout = setTimeout(async () => {
352
- if (this.reconnectAttempts >= this.options.maxRetryAttempts) {
352
+ this.reconnectAttempts++;
353
+ if (this.reconnectAttempts > this.options.maxRetryAttempts) {
353
354
  const error = new MagmastreamError_1.MagmaStreamError({
354
355
  code: Enums_1.MagmaStreamErrorCode.NODE_RECONNECT_FAILED,
355
356
  message: `Unable to reconnect after ${this.options.maxRetryAttempts} attempts.`,
@@ -362,7 +363,6 @@ class Node {
362
363
  this.socket = null;
363
364
  this.manager.emit(Enums_1.ManagerEventTypes.NodeReconnect, this);
364
365
  await this.connect();
365
- this.reconnectAttempts++;
366
366
  }, this.options.retryDelayMs);
367
367
  }
368
368
  /**
@@ -384,6 +384,8 @@ class Node {
384
384
  open() {
385
385
  if (this.reconnectTimeout)
386
386
  clearTimeout(this.reconnectTimeout);
387
+ this.reconnectTimeout = undefined;
388
+ this.reconnectAttempts = 0;
387
389
  const debugInfo = {
388
390
  identifier: this.options.identifier,
389
391
  connected: this.connected,
@@ -55,7 +55,7 @@ export declare class Player {
55
55
  /** Should only be used when the node is a NodeLink */
56
56
  protected voiceReceiverWsClient: WebSocket | null;
57
57
  protected isConnectToVoiceReceiver: boolean;
58
- protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
58
+ protected voiceReceiverReconnectTimeout?: NodeJS.Timeout;
59
59
  protected voiceReceiverAttempt: number;
60
60
  protected voiceReceiverReconnectTries: number;
61
61
  /**
@@ -263,7 +263,7 @@ class Player {
263
263
  }
264
264
  if (this.voiceReceiverReconnectTimeout) {
265
265
  clearTimeout(this.voiceReceiverReconnectTimeout);
266
- this.voiceReceiverReconnectTimeout = null;
266
+ this.voiceReceiverReconnectTimeout = undefined;
267
267
  }
268
268
  if (this.voiceReceiverWsClient) {
269
269
  this.voiceReceiverWsClient.removeAllListeners();
@@ -1118,7 +1118,7 @@ class Player {
1118
1118
  async openVoiceReceiver() {
1119
1119
  if (this.voiceReceiverReconnectTimeout)
1120
1120
  clearTimeout(this.voiceReceiverReconnectTimeout);
1121
- this.voiceReceiverReconnectTimeout = null;
1121
+ this.voiceReceiverReconnectTimeout = undefined;
1122
1122
  this.isConnectToVoiceReceiver = true;
1123
1123
  this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[PLAYER] Opened voice receiver for player ${this.guildId}`);
1124
1124
  this.manager.emit(Enums_1.ManagerEventTypes.VoiceReceiverConnect, this);
@@ -497,6 +497,8 @@ export interface LavaPlayer {
497
497
  export interface ErrorOrEmptySearchResult {
498
498
  /** The load type of the result. */
499
499
  loadType: LoadTypes.Empty | LoadTypes.Error;
500
+ /** Always an empty array for error/empty results. */
501
+ tracks: [];
500
502
  }
501
503
  /**
502
504
  * Track Search Result
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.10.3-alpha.2",
3
+ "version": "2.10.3-alpha.4",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",