> For the complete documentation index, see [llms.txt](https://axieum.gitbook.io/chatter-for-minecraft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://axieum.gitbook.io/chatter-for-minecraft/discord/commands.md).

# Commands

## Overview

Ever wanted to run a command against your server, but don't have the game loaded up? Well, now you can create custom commands that can be run directly from your Discord client!

![A quick showcase of commands](/files/-MXFbFWAfXq1pW_qwMgL)

## Configuration

{% hint style="success" %}
Made changes to the configuration? Type **`/reload`** to apply the changes immediately!
{% endhint %}

### Enable Commands

Controls whether or not the command client should be enabled.

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

```javascript
{
	// True if any commands should be available for use
	"enabled": true,
	// ...
}
```

{% endcode %}

### Command Prefix

A prefix that when included in a Discord message, will treat the request as a command.

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

```javascript
{
	// Message prefix used in Discord to trigger commands
	"prefix": "!",
	// ...
}
```

{% endcode %}

### Help Menu

By defining a help word, a command will be automatically registered that sends a *direct message* containing all available commands and their usage.

![Example help menu](/files/-MXFK1NZ7VUJG1CE7XXJ)

{% tabs %}
{% tab title="Register Help" %}
{% code title="config/chatter/discord/commands.json5" %}

```javascript
{
	// If defined, exposes a command to display help
	"helpWord": "help",
	// ...
}
```

{% endcode %}
{% endtab %}

{% tab title="Turn Off Help" %}
{% code title="config/chatter/discord/commands.json5" %}

```javascript
{
	// If defined, exposes a command to display help
	"helpWord": null,
	// ...
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Admins

A command administrator will skip all permission checks, hence, having access to all commands.

{% hint style="warning" %}
You must configure **at least one** command administrator!
{% endhint %}

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

```javascript
{
	// Identifiers for users within Discord to whom to grant all permissions
	"admins": [
		"252311115122475009",
		// ...
	],
	// ...
}
```

{% endcode %}

![Finding a Discord user identifer](/files/-MXFYGXcntWPprPWAQaa)

### Messages

There are some instances where feedback is provided. In these cases, the following messages may be sent.

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

```javascript
{
	// Feedback provided to the user who triggered a command
	"messages": {
		// The error message used when the server is unavailable
		"unavailable": "The server is not yet ready - please wait. :warning:"
		// ...
	},
	// ...
}
```

{% endcode %}

### Command

There are two types of commands, [built-in](/chatter-for-minecraft/discord/commands/built-in.md) and [custom](/chatter-for-minecraft/discord/commands/custom.md). Both share a common set of base command options, as defined below.

{% content-ref url="/pages/-MXFLZqWtx1Cj8B6l8Sg" %}
[Built-In](/chatter-for-minecraft/discord/commands/built-in.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MXFOTwrn8e0fbQbqCnZ" %}
[Custom](/chatter-for-minecraft/discord/commands/custom.md)
{% endcontent-ref %}

#### Enabled

Controls whether or not the command should be registered.

```javascript
// True if the command should be available for use
"enabled": true,
```

#### Name

A trigger keyword that comes directly after the [message prefix](/chatter-for-minecraft/discord/commands.md#command-prefix), to use the command.

```javascript
// Trigger name for the command
"name": "teleport",
```

#### Aliases

Alternative trigger keywords in addition to the above [name](/chatter-for-minecraft/discord/commands.md#name).

```javascript
// Any alternative trigger names for the command
"aliases": [
	"tp",
	// ...
],
```

#### Help

A description of what the command does - this is used in the [help menu](/chatter-for-minecraft/discord/commands.md#help-menu).

```javascript
// A brief description of what the command does
"help": "Teleports a player",
```

#### Usage

Details the correct usage of the command - this is used in the [help menu](/chatter-for-minecraft/discord/commands.md#help-menu).

{% tabs %}
{% tab title="Example" %}

```javascript
// Details the correct usage of the command, e.g. <username> [count]
"usage": "<username> [x] [y] [z]",
```

{% endtab %}

{% tab title="Blank" %}

```javascript
// Details the correct usage of the command, e.g. <username> [count]
"usage": null,
```

{% endtab %}
{% endtabs %}

#### Hidden

Controls whether this command should be visible in the [help menu](/chatter-for-minecraft/discord/commands.md#help-menu).

```javascript
// True if the command should be hidden from help messages
"hidden": false,
```

#### Role

If defined, restricts access to Discord users who have the specified role.

{% tabs %}
{% tab title="Role Name" %}

```javascript
// If defined, restricts access to Discord users with the given role identifier or name
"role": "Admin",
```

{% endtab %}

{% tab title="Role Identifier" %}

```javascript
// If defined, restricts access to Discord users with the given role identifier or name
"role": "815892510135025675",
```

{% endtab %}

{% tab title="Anyone" %}

```javascript
// If defined, restricts access to Discord users with the given role identifier or name
"role": null,
```

{% endtab %}
{% endtabs %}

#### Cooldown

Specifies how often the command may be used, in seconds. A cooldown can be scoped accordingly.

| Scope          | Meaning                                                                                  |
| -------------- | ---------------------------------------------------------------------------------------- |
| `USER`         | Per-user, across all&#xD; locations, e.g. text/private channels, guild, etc.             |
| `CHANNEL`      | Per-channel that the command was called in                                               |
| `USER_CHANNEL` | Per-user, per-channel that the command was called in                                     |
| `GUILD`        | All users, per-guild, e.g. an entire Discord server                                      |
| `USER_GUILD`   | Per-guild, per-user, e.g. John Doe in server A and John Doe in server B                  |
| `GLOBAL`       | Global, every server, channel and user, e.g. if stopping the server, only ever call once |

```javascript
// 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",
```
