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 slash command macro functions #4249

Merged
merged 14 commits into from
Sep 5, 2023
Merged

Conversation

cwisniew
Copy link
Member

@cwisniew cwisniew commented Aug 16, 2023

Identify the Bug or Feature request

resolves #1691

Description of the Change

Adds the following macro functions
Set an alias

[slash.setAlias("alias", "command")]

Returns a JSON Object withe the defined aliases (defined by macro or /alias)

[slash.getAliases()]

Clears an alias

[slash.clearAlias()]

Add-ons can also define aliases in a file
slash_commands.json
With the following format

{
  "slashCommands": [
    {
      "name": "testSlashCommand",
      "description": "A Test Slash Command",
      "command": "This is a test"
    }, 
    {
      "name": "testSlashCommand1",
      "description": "A Test Slash Command 1",
      "command": "This is a test 1"
    } 

  ]
}

This will take care of registering the aliases for you so that you do not need to create any onCampaignLoad macro, it will also separate the commands for your add on in the /alias command listing into their own heading like

CleanShot 2023-08-17 at 20 30 28@2x

Aliases set via macros and add ons have a different "lifetime" to those set using the /alias command.
When set by macro, the aliases are cleared when a new campaign is created, or a campaign is loaded. This is so campaign set aliases will not pollute each other. They are not saved as part of the campaign, so they must be recreated each time if not defined the slash_commands.json file in an add-on.

To maintain functional compatibility, aliases created with /alias command will persist across campaign load/creation and /savealias will not save alises created with slash.setAlias() or add-ons.

Possible Drawbacks

See the above discussion about differences between aliases set with new macro functions and /alias

Documentation Notes

See above

Release Notes

  • Add new macro functions for dealing with slash commands
  • Add ability for add-ons to define slash commands

This change is Reviewable

@cwisniew cwisniew added the feature Adding functionality that adds value label Aug 16, 2023
@cwisniew cwisniew marked this pull request as ready for review August 17, 2023 11:11
@thelsing
Copy link
Collaborator

I didn't find any references to MtScript2Lexer. Is it already used or was it added accidentally?

@cwisniew
Copy link
Member Author

cwisniew commented Sep 1, 2023

I didn't find any references to MtScript2Lexer. Is it already used or was it added accidentally?

yeah it was something I was working on in another branch when I switched back to implement a few extra things people on discord wanted (those are IDE generated files) no idea why it wasn't cleaned up properly and made it into this PR will make sure its not there when I complete the changes requested and push final PR

@cwisniew cwisniew added this pull request to the merge queue Sep 5, 2023
Merged via the queue into RPTools:develop with commit e4b48ff Sep 5, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding functionality that adds value
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Alias for macro coding
3 participants