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 · 4 comments
Open

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

D4n2021 opened this issue May 1, 2024 · 4 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
@sergelouie6
Copy link
Contributor

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.

@sergelouie6
Copy link
Contributor

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
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

When branches are created from issues, their pull requests are automatically linked.

3 participants