From 84c28b1856ffddb80a71e2127182d8fd906af154 Mon Sep 17 00:00:00 2001 From: CodeRedDev Date: Sat, 18 Nov 2023 22:15:40 +0100 Subject: [PATCH 1/2] Add includeChats to ChatCommands --- squad-server/plugins/chat-commands.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/squad-server/plugins/chat-commands.js b/squad-server/plugins/chat-commands.js index 9f0ca0f85..a16d1393e 100644 --- a/squad-server/plugins/chat-commands.js +++ b/squad-server/plugins/chat-commands.js @@ -23,13 +23,15 @@ export default class ChatCommands extends BasePlugin { '
  • type - Either warn or broadcast.
  • ' + '
  • response - The message to respond with.
  • ' + '
  • ignoreChats - A list of chats to ignore the commands in. Use this to limit it to admins.
  • ' + + '
  • includeChats - A list of chats to include the commands in. Use this to limit it to admins.
  • ' + '', default: [ { command: 'squadjs', type: 'warn', response: 'This server is powered by SquadJS.', - ignoreChats: [] + ignoreChats: [], + includeChats: [] } ] } @@ -39,7 +41,11 @@ export default class ChatCommands extends BasePlugin { async mount() { for (const command of this.options.commands) { this.server.on(`CHAT_COMMAND:${command.command.toLowerCase()}`, async (data) => { - if (command.ignoreChats.includes(data.chat)) return; + let ignoreChats = command.ignoreChats ?? []; + let includeChats = command.includeChats ?? []; + + if (ignoreChats.includes(data.chat)) return; + if (includeChats.length > 0 && !includeChats.includes(data.chat)) return; if (command.type === 'broadcast') { await this.server.rcon.broadcast(command.response); From 79030b6d85d724290cd4055a63fbd63c686b9814 Mon Sep 17 00:00:00 2001 From: CodeRedDev Date: Fri, 23 Feb 2024 01:00:24 +0100 Subject: [PATCH 2/2] Add ChatCommands includeChats to config and README --- README.md | 5 +++-- config.json | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 162e7b4bd..60f1a1695 100644 --- a/README.md +++ b/README.md @@ -295,14 +295,15 @@ Interested in creating your own plugin? [See more here](./squad-server/plugins/r

    Options

    diff --git a/config.json b/config.json index 1cde20cdb..db417ef2c 100644 --- a/config.json +++ b/config.json @@ -73,7 +73,8 @@ "command": "squadjs", "type": "warn", "response": "This server is powered by SquadJS.", - "ignoreChats": [] + "ignoreChats": [], + "includeChats": [] } ] },