magmastream 2.10.2-alpha.4 → 2.10.2-alpha.5

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.
@@ -143,13 +143,13 @@ export declare class Manager extends EventEmitter {
143
143
  */
144
144
  get useableNode(): Node;
145
145
  /**
146
- * Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
146
+ * Handles the shutdown of the process by saving all active players' states.
147
147
  * This function is called when the process is about to exit.
148
148
  * It iterates through all players and calls {@link savePlayerState} to save their states.
149
- * Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
150
- * After saving and cleaning up, it exits the process.
149
+ * After saving, it exits the process.
150
+ * @param stopProcess - A function to stop the process.
151
151
  */
152
- handleShutdown(): Promise<void>;
152
+ handleShutdown(stopProcess?: () => Promise<void>): Promise<void>;
153
153
  /**
154
154
  * Parses a YouTube title into a clean title and author.
155
155
  * @param title - The original title of the YouTube video.
@@ -736,13 +736,13 @@ class Manager extends events_1.EventEmitter {
736
736
  return this.options.enablePriorityMode ? this.priorityNode : this.options.useNode === Enums_1.UseNodeOptions.LeastLoad ? this.leastLoadNode.first() : this.leastPlayersNode.first();
737
737
  }
738
738
  /**
739
- * Handles the shutdown of the process by saving all active players' states and optionally cleaning up inactive players.
739
+ * Handles the shutdown of the process by saving all active players' states.
740
740
  * This function is called when the process is about to exit.
741
741
  * It iterates through all players and calls {@link savePlayerState} to save their states.
742
- * Optionally, it also calls {@link cleanupInactivePlayers} to remove any stale player state files.
743
- * After saving and cleaning up, it exits the process.
742
+ * After saving, it exits the process.
743
+ * @param stopProcess - A function to stop the process.
744
744
  */
745
- async handleShutdown() {
745
+ async handleShutdown(stopProcess) {
746
746
  this.unloadPlugins();
747
747
  console.warn("\x1b[31m%s\x1b[0m", "MAGMASTREAM WARNING: Shutting down! Please wait, saving active players...");
748
748
  try {
@@ -763,9 +763,12 @@ class Manager extends events_1.EventEmitter {
763
763
  }
764
764
  });
765
765
  await Promise.allSettled(savePromises);
766
- setTimeout(() => {
766
+ setTimeout(async () => {
767
767
  console.warn("\x1b[32m%s\x1b[0m", "MAGMASTREAM INFO: Shutting down complete, exiting...");
768
- process.exit(0);
768
+ if (stopProcess)
769
+ await stopProcess();
770
+ else
771
+ process.exit(0);
769
772
  }, 500);
770
773
  }
771
774
  catch (err) {
@@ -115,9 +115,16 @@ class Rest {
115
115
  if (status >= 200 && status < 300) {
116
116
  return data;
117
117
  }
118
- // Lavalink sometimes returns "Guild not found" for inactive players
119
- if (status === 404 && data?.message === "Guild not found") {
120
- return [];
118
+ if (status === 404) {
119
+ if (data?.message === "Guild not found") {
120
+ // Lavalink sometimes returns "Guild not found" for inactive players
121
+ return [];
122
+ }
123
+ if (data?.message === "Session not found") {
124
+ // Session expired — trigger reconnection instead of crashing
125
+ this.manager.emit(Enums_1.ManagerEventTypes.NodeError, this.node, new MagmastreamError_1.MagmaStreamError({ code: Enums_1.MagmaStreamErrorCode.REST_REQUEST_FAILED, message: "Session not found" }));
126
+ return [];
127
+ }
121
128
  }
122
129
  const message = typeof data === "string"
123
130
  ? data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.10.2-alpha.4",
3
+ "version": "2.10.2-alpha.5",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",