# Custom Commands

To access these settings:

> Head to your [Dashboard](https://tickettool.xyz/manage-servers)\
> Select your server\
> Go to the **Custom Commands** Tab

Custom Commands are used to send a predefined response to your channels using a text command. Common uses are FAQs, Help Commands, and/or General information.

The Custom Commands tab shows currently configured Custom Commands and allows you to create and edit Custom Commands.

### Creating a Custom Command

To create a Custom Command, press the green `+ New` button in the top left corner of the Custom Commands page. When creating a Custom Command, give it a name to identify your Custom Command.

![Custom Command Page Mockup](https://i.imgur.com/QRE3jj6.jpg)

{% hint style="info" %}

* To delete a custom commands click the Bin icon that's next to the command name.
* You can clone custom commands by clicking the Copy icon next to delete button.
* You must always have at least one custom command on the dashboard. If you plan on deleting your last custom command, create a new custom command first to avoid an error.
  {% endhint %}

{% hint style="warning" %}

* You must have at least one custom command in your server.
* For more information please look at our [Error Documentation](https://docs.tickettool.xyz/debugging/errors/major-mismatch)
  {% endhint %}

### Customizing a Custom Command

![Customization Options](https://i.imgur.com/XbCmVpJ.png)

#### Command Name

You can always set a new name for your Custom Command by editing it on the top left corner of it's settings

#### Command Group

You can create groups to categorize your Custom Commands! Type a name in the box to look for already made groups or click in the name you typed to create a new one!

#### Command Description/Notes

Here you can insert a custom description you had like the command to have, this is only visible on your dashboard and does not affect in any way the output on your Discord server.

#### Dm Ticket Owner instead

If **enabled**, triggering this custom command **in a ticket** will DM the custom command message to the Ticket Owner instead of sending it to the channel.

{% hint style="warning" %}
If the custom command is triggered **outside** of a ticket, the message will **not** be sent to the channel.
{% endhint %}

#### Dm response instead

If **enabled**, the user who triggers the custom command will receive the Message on its Direct Messages (DMs)

#### Admin Only

When **enabled**, only users with a [Dashboard Role](https://docs.tickettool.xyz/server-configs#dashboard-roles), `Administrator` Permission, and the `Server Owner` will be able to trigger this custom command.

#### Command Trigger

You can choose one of 3 trigger types for your commands:

* Strict
* Wildcard
* Regex

{% hint style="warning" %}
Note that the server's prefix won't affect the command trigger **at all**!
{% endhint %}

**Trigger Settings**

* Enabling the **`Case sensitive`** will make the triggers check for the specific case you stated.
* When enabled, the user’s message that triggered the custom command will be deleted after the message has been sent.

**Strict**

This type will be triggered by a match of the command trigger, this is the standard trigger formerly known as Tags which now supports the `Case Sensitive` setting.

**Wildcard**

By inserting the **`*`** character on the trigger, instead of the asterisk, the command will check for any characters, for instance:

> `Fish*` will match any message starting by `Fish` (or `fish` if not case sensitive) e.g `Fishdom`, `Fish11111`, etc...\
> `*fish` will match any message ending by `fish`, e.g `breadfish`, `clownfish`, etc...\
> `f*ish` will match messages that start with `f`, end with `ish` and have any characters in between, e.g. `friedish`, `fbreadish`. etc...

**RegEx**

This is the most advanced type of trigger type, for most of the uses, we recommend you use the Strict and Wildcard types. For instance we'll provide you with some of the most common use cases you'll find for this type of trigger are:

* Multiple triggers for a single custom command. For example, if your trigger is set to `bread|fish` your command will be triggered by any text starting with `bread` or with `fish`.
* If you want the trigger to only match the start of a string, use the `^` character on the beggining of the pattern.

We suggest you test your RegEx triggers by using sites such as [RegExr](https://regexr.com/) in which you'll be able to identify which messages will trigger your command. If you had like to learn more about RegEx you can check [MDN's RegEx Cheatsheet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet)

**RegEx Named Groups**

We also support RegEx named groups, which you can access to by using the `{regex.NAME}` or `{regex.INDEX}` variables (replacing the name or index but it's value). An small sample of how you can use this feature is shown below:

![Dashboard](https://i.imgur.com/w2mOO6T.png) ![Output](https://i.imgur.com/XfqUEay.png)

**Custom Command Arguments**

Command Arguments act as variables that allow you to display information included in the command usage onto the custom command response. This feature is particularly useful as it can be used for many different purposes. To add command arguments, you can click on the green New button. You can then include the variable prompted in your custom command message.

![Creating an Argument](https://i.imgur.com/JKGDgor.png)

You can use an argument on its own, to create a 'say' type command, in which Ticket Tool reposts everything included after the trigger, or use the argument as a placeholder text in a predefined message to be replaced by whatever you include after the trigger.

![Arguments on their own](https://i.imgur.com/9IKpD13.png) ![Dashboard Preview](https://i.imgur.com/esBKsLy.png)

![Arguments within text](https://i.imgur.com/E397VtG.png) ![Dasboard Preview](https://i.imgur.com/SoIhcqS.png)

**Argument Separators**

If you have multiple arguments, you will be prompted with the option to edit the character that will separate an argument from another. By default, the argument separator is `,`.

For example, if you have two arguments, text before the separator will be part of `{argument.1}` and text after the separator will be part of `{argument.2}`.

![Argument Separators Usage](https://i.imgur.com/vJvQlmG.png)

{% hint style="info" %}
You can only have up to **5** arguments per command.
{% endhint %}

{% hint style="success" %}
Make sure to always **save** changes using the pop-up shown whenever a change is done.
{% endhint %}
