From c2ed54929edb7ee8ee21e524894a5231ea79a907 Mon Sep 17 00:00:00 2001 From: gh0sTedBuddy Date: Sun, 7 Apr 2024 23:44:09 +0100 Subject: [PATCH] fix(plugins) only broadcast plugins with actions --- lib/WetSock/WetSock.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/WetSock/WetSock.js b/lib/WetSock/WetSock.js index 27539c2..02b9ab5 100644 --- a/lib/WetSock/WetSock.js +++ b/lib/WetSock/WetSock.js @@ -69,15 +69,22 @@ export default class WetSock { handleOpen(ws) { const client = new SocketClient(ws.data.clientId, ws); this.#clients.set(client.id, client); - client.send({ - event: 'plugins', - data: [...this.#plugins.keys()].map(key => { - return { - identifier: key, - actions: this.#plugins.get(key).plugin.actions() - }; - }) + + const plugins = [...this.#plugins.keys()].filter(key => { + return typeof(this.#plugins.get(key).plugin.actions) == 'function' + }).map(key => { + return { + identifier: key, + actions: this.#plugins.get(key).plugin.actions() + }; }); + + if(plugins.length > 0) { + client.send({ + event: 'plugins', + data: + }); + } this.emit('open', client); }