Skip to content

Comments

Add includeChats property#323

Open
CodeRedDev wants to merge 2 commits intoTeam-Silver-Sphere:masterfrom
CodeRedDev:includeChats-property
Open

Add includeChats property#323
CodeRedDev wants to merge 2 commits intoTeam-Silver-Sphere:masterfrom
CodeRedDev:includeChats-property

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.

@CodeRedDev CodeRedDev force-pushed the includeChats-property branch from 59405d2 to 84c28b1 Compare February 22, 2024 23:50
@lbzepoqo
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

<ul><li><h4>commands</h4>
<h6>Description</h6>
<p>An array of objects containing the following properties: <ul><li><code>command</code> - The command that initiates the message.</li><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></ul></p>
<p>An array of objects containing the following properties: <ul><li><code>command</code> - The command that initiates the message.</li><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/includeChats</code> - Either one can be used to limit to specific in-game chats, being <code>ChatAll</code>, <code>ChatTeam</code>, <code>ChatSquad</code> and <code>ChatAdmin</code></li></ul></p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these changes made manually? If so, they will be overwritten when the readme is regenerated from the plugin option specification.

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.

3 participants