# Custom

In addition to built-in commands, you can create your own custom commands. These are commands that trigger a Minecraft command to be run on the server.

The following command configuration entries are found under the `custom` field and all share the same options as a [base command](https://axieum.gitbook.io/chatter-for-minecraft/discord/commands/..#command).

{% code title="config/chatter/discord/commands.json5" %}

```javascript
{
	// Custom Discord commands
	"custom": {
		// ...
	}
	// ...
}
```

{% endcode %}

## Configuration

A custom command has two fields in addition to the [shared command options](https://axieum.gitbook.io/chatter-for-minecraft/discord/commands/..#command).

### Command

The Minecraft command to execute on the server, e.g. `/teleport {0} {1}`

```javascript
/**
 * A Minecraft command to execute
 * Use {n} for the nth argument, and {} for all
 */
"command": "/whitelist {}",
```

| Config             | Discord               | Executed              |
| ------------------ | --------------------- | --------------------- |
| /whitelist         | !whitelist list       | /whitelist            |
| /whitelist {0}     | !whitelist list       | /whitelist list       |
| /whitelist {0}     | !whitelist add Axieum | /whitelist add        |
| /whitelist {1}     | !whitelist add Axieum | /whitelist Axieum     |
| /whitelist add {0} | !whitelist Axieum     | /whitelist add Axieum |
| /whitelist {}      | !whitelist a b c d    | /whitelist a b c d    |
| /whitelist {0} {}  | !whitelist a b c d    | /whitelist a a b c d  |

### Quiet

Controls whether command feedback is printed to the user.

```javascript
// True if the execution should not provide any feedback
"quiet": false,
```

## Examples

### !whitelist

![Example of a restricted whitelist command](https://2905471890-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWJ0CGscN1zQsA_eF9d%2F-MXF4SBrsy_JnqzIXDvd%2F-MXFPo6Jxt_c3wLSVBYa%2Fchatter_discord_custom_wl_command.gif?alt=media\&token=c3e82a34-bfa0-4b7b-9c71-598973a62d32)

{% code title="config/chatter/discord/commands.json5" %}

```javascript
{
	// Custom Discord commands
	"custom": [
		{
			// True if the execution should not provide any feedback
			"quiet": false,
			/**
			 * A Minecraft command to execute
			 * Use {n} for the nth argument, and {} for all
			 */
			"command": "/whitelist {}",
			// True if the command should be available for use
			"enabled": true,
			// Trigger name for the command
			"name": "whitelist",
			// Any alternative trigger names for the command
			"aliases": [
				"wl"
			],
			// A brief description of what the command does
			"help": "Manages the whitelist for the server",
			// Details the correct usage of the command, e.g. <username> [count]
			"usage": "<list/add/remove> [username]",
			// True if the command should be hidden from help messages
			"hidden": false,
			// If defined, restricts access to Discord users with the given role identifier or name
			"role": "Admin",
			// The number of seconds a user must wait before using the command again
			"cooldown": 0,
			// To whom the cooldown applies (see https://git.io/JtpsJ)
			"cooldownScope": "USER"
		},
		// ...
	]
	// ...
}
```

{% endcode %}

### !stop

![Example of a hidden, quiet stop command](https://2905471890-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MWJ0CGscN1zQsA_eF9d%2F-MXFZLImuPu268PEdZRH%2F-MXF_robVNc-0m2Le3WD%2Fchatter_discord_custom_stop_command.gif?alt=media\&token=871c313f-e0d8-4bf2-8698-4a22b0ae6eba)

{% code title="config/chatter/discord/commands.json5" %}

```javascript
{
	// Custom Discord commands
	"custom": [
		{
			// True if the execution should not provide any feedback
			"quiet": true,
			/* A Minecraft command to execute
			   Use {n} for the nth argument, and {} for all
			*/
			"command": "/stop",
			// True if the command should be available for use
			"enabled": true,
			// Trigger name for the command
			"name": "stop",
			// Any alternative trigger names for the command
			"aliases": [],
			// A brief description of what the command does
			"help": "Stops the server",
			// Details the correct usage of the command, e.g. <username> [count]
			"usage": null,
			// True if the command should be hidden from help messages
			"hidden": true,
			// If defined, restricts access to Discord users with the given role identifier or name
			"role": "Admin",
			// The number of seconds a user must wait before using the command again
			"cooldown": 60,
			// To whom the cooldown applies (see https://git.io/JtpsJ)
			"cooldownScope": "GLOBAL"
		},
		// ...
	]
	// ...
}
```

{% endcode %}
