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' + ); + } } }