Skip to content

Commit dfb3d40

Browse files
authored
Merge pull request #161 from ductridev/main
fix: not reconnecting after 1st error
2 parents 389e431 + 794b4f2 commit dfb3d40

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/structures/Node.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ export class LavalinkNode {
487487
*/
488488
public destroy(destroyReason?: DestroyReasonsType, deleteNode: boolean = true, movePlayers: boolean = false): void {
489489
// if (!this.connected) return; This Prevents the node from being destroyed if it is not connected, but we want to allow it to be destroyed even if not connected.
490+
this.reconnectionState = ReconnectionState.IDLE;
490491

491492
const players = this.NodeManager.LavalinkManager.players.filter(p => p.node.id === this.id);
492493
if (players.size) {
@@ -583,6 +584,7 @@ export class LavalinkNode {
583584
this.socket?.close(1000, "Node-Disconnect");
584585
this.socket?.removeAllListeners();
585586
this.socket = null;
587+
this.reconnectionState = ReconnectionState.IDLE;
586588

587589
this.resetReconnectionAttempts();
588590

@@ -1203,6 +1205,7 @@ export class LavalinkNode {
12031205
private error(error: Error): void {
12041206
if (!error) return;
12051207
this.NodeManager.emit("error", this, error);
1208+
this.reconnectionState = ReconnectionState.IDLE;
12061209
this.reconnect();
12071210
if (this.options.closeOnError) {
12081211
if (this.heartBeatInterval) clearInterval(this.heartBeatInterval);
@@ -1787,3 +1790,4 @@ export class LavalinkNode {
17871790
return;
17881791
}
17891792
}
1793+

0 commit comments

Comments
 (0)