diff --git a/README.md b/README.md
index 162e7b4b..60f1a169 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
commands
Description
- An array of objects containing the following properties:
command
- The command that initiates the message.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.
+ An array of objects containing the following properties:
command
- The command that initiates the message.type
- Either warn
or broadcast
.response
- The message to respond with.ignoreChats/includeChats
- Either one can be used to limit to specific in-game chats, being ChatAll
, ChatTeam
, ChatSquad
and ChatAdmin
Default
[
{
"command": "squadjs",
"type": "warn",
"response": "This server is powered by SquadJS.",
- "ignoreChats": []
+ "ignoreChats": [],
+ "includeChats": []
}
]
diff --git a/config.json b/config.json
index 1cde20cd..db417ef2 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": []
}
]
},
diff --git a/squad-server/plugins/chat-commands.js b/squad-server/plugins/chat-commands.js
index 9f0ca0f8..a16d1393 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);