Skip to content

Commit

Permalink
Add includeChats to ChatCommands
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeRedDev committed Nov 18, 2023
1 parent 06c7e7f commit 59405d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions squad-server/plugins/chat-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export default class ChatCommands extends BasePlugin {
'<li><code>type</code> - Either <code>warn</code> or <code>broadcast</code>.</li>' +
'<li><code>response</code> - The message to respond with.</li>' +
'<li><code>ignoreChats</code> - A list of chats to ignore the commands in. Use this to limit it to admins.</li>' +
'<li><code>includeChats</code> - A list of chats to include the commands in. Use this to limit it to admins.</li>' +
'</ul>',
default: [
{
command: 'squadjs',
type: 'warn',
response: 'This server is powered by SquadJS.',
ignoreChats: []
ignoreChats: [],
includeChats: []
}
]
}
Expand All @@ -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);
Expand Down

0 comments on commit 59405d2

Please sign in to comment.