Team-Silver-Sphere / SquadJS

Squad Server Script Framework
Boost Software License 1.0
163 stars 123 forks source link

Allow a few more commands for chat-commands.js #357

Open D4n2021 opened 4 months ago

D4n2021 commented 4 months ago

What is the issue, e.g. map voting, you would like to solve?

Currently only supports "command", and not "command2", "command3" for example.

How would you like us to solve this issue?

To make this work like this (example words "version" and "website". Project Reality servers also support those commands iirc)

grafik

Additional Info

It currently outright ignores command2 and command3 variables.

lbzepoqo commented 4 months ago

I will try to submit a PR about this if I finally figure it out how

image

If you want to try it, here's what I changed in the mount function

  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);
          }
        });
      }
    }
  }

This way I don't have to reconfigure the existing config and must convert each existing command one I made. As an example:

                  {
                    "command": "clear",
                    "type": "broadcast",
                    "response": "Please clear the chat. Thank you!.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n 󠀡󠀡",
                    "ignoreChats": [
                        "ChatAll",
                        "ChatTeam",
                        "ChatSquad"
                    ]
                },
                {
                    "command": [
                        "nomaincamp",
                        "maincamp",
                        "main",
                        "mainbase",
                        "nomain",
                        "nocamp",
                        "mainbasecamp"
                    ],
                    "type": "broadcast",
                    "response": "Main Camping violates the server rules. Please keep a safe distance from the enemy's main base.",
                    "ignoreChats": [
                        "ChatAll",
                        "ChatTeam",
                        "ChatSquad"
                    ]
                }
werewolfboy13 commented 4 months ago

If not I can attempt to push one for you. All we ask is not to modify flags as they are tied to GitHub actions.

lbzepoqo commented 4 months ago

If not I can attempt to push one for you. All we ask is not to modify flags as they are tied to GitHub actions.

Please do thank you!

werewolfboy13 commented 4 months ago

If not I can attempt to push one for you. All we ask is not to modify flags as they are tied to GitHub actions.

Please do thank you!

Haven’t forgotten still plan on doing this. Going to make a branch here for it.

Thomas-Smyth commented 1 month ago

What is the issue, e.g. map voting, you would like to solve?

Currently only supports "command", and not "command2", "command3" for example.

How would you like us to solve this issue?

To make this work like this (example words "version" and "website". Project Reality servers also support those commands iirc)

grafik

Additional Info

It currently outright ignores command2 and command3 variables.

I'm not sure I get what is being suggested here. Do you mean you want aliases for the same command? For example, !web and !website return the same response?

lbzepoqo commented 1 month ago

What is the issue, e.g. map voting, you would like to solve?

Currently only supports "command", and not "command2", "command3" for example.

How would you like us to solve this issue?

To make this work like this (example words "version" and "website". Project Reality servers also support those commands iirc) grafik

Additional Info

It currently outright ignores command2 and command3 variables.

I'm not sure I get what is being suggested here. Do you mean you want aliases for the same command? For example, !web and !website return the same response?

Now that I see Thomas' comment, would it be better to add another option called aliases instead of my suggestion of modifying the command option? @werewolfboy13

D4n2021 commented 1 month ago

Do you mean you want aliases for the same command? For example, !web and !website return the same response?

indeed! Back in the days in PR (and still working nowadays afaik), !r, !report and !calladmin worked for the function to send a message to admins.