magmastream 2.10.2-dev.4 → 2.10.3-dev.0
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/dist/structures/Node.js
CHANGED
|
@@ -295,8 +295,6 @@ class Node {
|
|
|
295
295
|
* @returns {Promise<void>} A promise that resolves when the node and its resources have been destroyed.
|
|
296
296
|
*/
|
|
297
297
|
async destroy() {
|
|
298
|
-
if (!this.connected)
|
|
299
|
-
return;
|
|
300
298
|
const debugInfo = {
|
|
301
299
|
connected: this.connected,
|
|
302
300
|
identifier: this.options.identifier,
|
|
@@ -310,10 +308,16 @@ class Node {
|
|
|
310
308
|
if (players.size) {
|
|
311
309
|
await Promise.all(Array.from(players.values(), (player) => player.autoMoveNode()));
|
|
312
310
|
}
|
|
313
|
-
|
|
314
|
-
this.socket.removeAllListeners();
|
|
315
|
-
this.reconnectAttempts = 1;
|
|
311
|
+
// Always clear reconnect state regardless of connection status
|
|
316
312
|
clearTimeout(this.reconnectTimeout);
|
|
313
|
+
this.reconnectTimeout = undefined;
|
|
314
|
+
this.reconnectAttempts = 1;
|
|
315
|
+
// Only close the socket if it is actually open
|
|
316
|
+
if (this.connected) {
|
|
317
|
+
this.socket.close(1000, "destroy");
|
|
318
|
+
this.socket.removeAllListeners();
|
|
319
|
+
}
|
|
320
|
+
this.socket = null;
|
|
317
321
|
this.manager.emit(Enums_1.ManagerEventTypes.NodeDestroy, this);
|
|
318
322
|
this.manager.nodes.delete(this.options.identifier);
|
|
319
323
|
}
|
|
@@ -943,7 +943,12 @@ class Player {
|
|
|
943
943
|
context: { guildId: this.guildId },
|
|
944
944
|
});
|
|
945
945
|
}
|
|
946
|
-
|
|
946
|
+
// Only destroy the player on the old node if it is still reachable.
|
|
947
|
+
// If the server is down the REST call would fail anyway; skipping it
|
|
948
|
+
// also prevents a spurious error when switching nodes during an outage.
|
|
949
|
+
if (this.node.connected) {
|
|
950
|
+
await this.node.rest.destroyPlayer(this.guildId).catch(() => { });
|
|
951
|
+
}
|
|
947
952
|
this.manager.players.delete(this.guildId);
|
|
948
953
|
this.node = node;
|
|
949
954
|
this.manager.players.set(this.guildId, this);
|