Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add includeChats property #323

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CodeRedDev
Copy link
Contributor

This adds a includeChats property to ChatCommands.

This makes limiting commands to one specific channel much easier and cleaner in the configuration.

I saw that there are more modules with the ignoreChats property and if the new includeChats property is desired, I will make efforts to implement it for those other modules too.

@sergelouie6
Copy link
Contributor

I was about to do another PR which might be in conflict to yours, maybe you can add it here too instead?

Add the ability for "commands" option to accept an array or just a single string.

  {
      "command": [
          "claim",
          "claimrule"
      ],
      "type": "broadcast",
      "response": "To make a valid claim, name your squad after the vehicle you want to claim.\nIf there are multiple vehicles of the same type, the first squad to claim it gets priority.",
      "ignoreChats": [
          "ChatAll",
          "ChatTeam",
          "ChatSquad"
      ]
  },
  async mount() {
    for (const command of this.options.commands) {
      const commands = Array.isArray(command.command) ? command.command : [command.command];
      for (const cmd of commands) {
        this.server.on(`CHAT_COMMAND:${cmd.toLowerCase()}`, async (data) => {
          if (command.ignoreChats.includes(data.chat)) return;
  
          if (command.type === 'broadcast') {
            await this.server.rcon.broadcast(command.response);
          } else if (command.type === 'warn') {
            await this.server.rcon.warn(data.player.steamID, command.response);
          }
        });
      }
    }
  }

@CodeRedDev
Copy link
Contributor Author

@sergelouie6 although it's a nice feature I doubt that they should be mixed in one PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants