From f9c234e385bfa183d7c8463d65cf13cee09d7b23 Mon Sep 17 00:00:00 2001 From: brblacky <77108939+brblacky@users.noreply.github.com> Date: Sun, 14 Apr 2024 01:29:15 +0530 Subject: [PATCH] Update package.json version to 4.0.9 --- package.json | 2 +- src/events/player/NodeDestroy.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e01bb280c..2909d6387 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lavamusic", - "version": "4.0.8", + "version": "4.0.9", "description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.", "main": "dist/index.js", "type": "module", diff --git a/src/events/player/NodeDestroy.ts b/src/events/player/NodeDestroy.ts index 5dc8f41d4..ee817750c 100644 --- a/src/events/player/NodeDestroy.ts +++ b/src/events/player/NodeDestroy.ts @@ -1,6 +1,8 @@ import { Event, Lavamusic } from '../../structures/index.js'; import BotLog from '../../utils/BotLog.js'; +let destroyCount = 0; + export default class NodeDestroy extends Event { constructor(client: Lavamusic, file: string) { super(client, file, { @@ -14,5 +16,16 @@ export default class NodeDestroy extends Event { `Node ${node} destroyed with code ${code} and reason ${reason}`, 'error' ); + destroyCount++; + if (destroyCount >= 5) { + this.client.shoukaku.removeNode(node); + destroyCount = 0; + this.client.logger.warn(`Node ${node} removed from nodes list due to excessive disconnects`); + BotLog.send( + this.client, + `Node ${node} removed from nodes list due to excessive disconnects`, + 'warn' + ); + } } }