Command System
TwiWorks also offers a built-in system for commands. These commands can be set up by opening up your Project Settings (Edit -> Project Settings), and adding Commands to the Commands section in the TwiWorks settings (Plugins > TwiWorks). Every command needs a name, optionally a description (if you want auto generated help messages), and optionally parameters. These parameters will need a name, a description if you want the help message, and a delimiter to find out where the parameter ends and the next one will start (this will generally be a space character (" ")). Each parameter also has a checkbox to toggle if it should show up in the auto-generated help menu.
Setting Up Commands
Next, you'll need to set up a prefix that your commands will use. A prefix consists of one or more characters, and is a way to separate your commands from regular chat messages. Examples of prefixes include "!", "$", "$$", and any other prefix you may want. We recommend that you use symbols, and not numbers or letters here.
TwiWorks's command system also offers a built-in way to generate a small help menu users can use to find out how they can interact with your game. The help menu can be enabled by ticking the "Is Command Help Enabled" checkbox, and setting a help command name in the "Help Command" textbox. We recommend that you stick with the default of "help" here, as this is what most users will be used to. When using this help menu, please ensure your commands/parameters are set up for use with the help system as mentioned in the paragraph about them.
Now that you've set up your commands, you'll most likely want to use them! To use the commands you have set up in the settings, use the "Bind To Twitch Command" node. Enter the command's name, connect your Twitch Chat, and drag out of the Delegate pin to create your OnCommand event. We will get in to using this event in a later paragraph.
You can also dynamically create commands, to do this, use the "Create Twitch Command" node. You will need to pass in your Twitch Chat, and a Command Binding. To create a command binding, use the "Make TwitchCommandBinding" node, and create the Binding in the same way as the above. For the command, drag out of this pin, and use the "Make TwitchCommand" node. This will reveal the options required to create a command. You can enter the command's name (Command Name; BE SURE TO GIVE THIS A UNIQUE NAME YOU HAVEN'T YET REGISTERED IN THE SETTINGS OR USING THE CREATE TWITCH COMMAND NODE), a description of what the command will do (Command Description; only relevant if you are interested in the auto-generated help command), the parameters (an array of TwitchCommandParameter structs, use the "MakeArray" and "Make TwitchCommandParameter" nodes for this), and a checkbox for whether it should show up in the help message or not (Shows Up In Help).
Using Commands
Now that you've created/set up your commands, we're ready to really start using them. Remember the event we set up when binding to or creating the command we said we'd get back to? Well, we'll need that now. This event will be called every time the user (successfully) executes a command that we've bound to, or have created. The "Parameters" parameter is an ordered array of all of the parameters you have set up when creating the command. The first parameter will be the first index of the array (Don't forget about 0-indexing!), and the last parameter will be the last index in the array. The "Sender" parameter is a MessageAuthor struct, which holds information about who tried to execute the command. You can read more about this in the Nodes section, or in the Chat 101 section.