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

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

Open
D4n2021 opened this issue May 1, 2024 · 7 comments
Open

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

D4n2021 opened this issue May 1, 2024 · 7 comments
Assignees
Labels
plugin feature request Feature request related to the SquadJS plugins

Comments

@D4n2021
Copy link

D4n2021 commented May 1, 2024

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.

@D4n2021 D4n2021 added the plugin feature request Feature request related to the SquadJS plugins label May 1, 2024
@lbzepoqo
Copy link
Contributor

lbzepoqo commented May 1, 2024

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
Copy link
Collaborator

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
Copy link
Contributor

lbzepoqo commented May 1, 2024

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
Copy link
Collaborator

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.

@werewolfboy13 werewolfboy13 self-assigned this May 10, 2024
@Thomas-Smyth
Copy link
Collaborator

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
Copy link
Contributor

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
Copy link
Author

D4n2021 commented Jul 18, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin feature request Feature request related to the SquadJS plugins
Projects
None yet
Development

No branches or pull requests

4 participants