Application commands
Application commands are what a member sees when they type / in a server your bot is in, or right-click a member or a message. You register them with your bot token; Moymo sends an interaction to your endpoint when somebody uses one. The shapes, numbers and limits are Discord's. For the guide, read Application commands.
Application command object
| Field | Type | Description |
|---|---|---|
id | UUID | The command's id |
application_id | UUID | The application it belongs to |
server_id | ?UUID | The server it was made for. Left out for a global command (in every server the bot is in) |
type | integer | The type |
name | string | 1 to 32 characters. A slash command's name is lowercase letters, digits, - and _ (any alphabet), with no spaces. A context-menu command's name may have spaces and capitals |
description | string | 1 to 100 characters for a slash command. Empty for the other kinds |
options | array | Up to 25 options, for slash commands |
name_localizations | ?object | Locale to name ({"cs": "hod"}), with the same rules as name |
description_localizations | ?object | Locale to description |
default_member_permissions | ?string | A permission set as a decimal string: members need all of it in the channel to see and use the command. "0" is nobody but administrators. Left out is everybody |
version | integer | Goes up every time the command changes |
Example commandJSON
json
{
"id": "3b9d5e21-8c47-4a06-b1f2-6e0a7d4c9f38",
"application_id": "0f6c1a52-3b9e-4c1c-9d1b-6e7d2a8f4b10",
"type": 1,
"name": "roll",
"description": "Roll some dice",
"options": [
{
"type": 4,
"name": "sides",
"description": "How many sides",
"required": true,
"min_value": 2,
"max_value": 100
}
],
"version": 1
}Command types
| Name | Value | |
|---|---|---|
CHAT_INPUT | 1 | A slash command, typed as /roll 2d6 |
USER | 2 | A command on a member (right-click a member, choose it under Apps). No options |
MESSAGE | 3 | A command on a message. No options |
Command option object
| Field | Type | Description |
|---|---|---|
type | integer | The option type |
name | string | 1 to 32 characters, lowercase letters, digits, - and _. Unique in its list |
description | string | 1 to 100 characters |
required | boolean | Default false. Required options come before the optional ones. Not for sub-commands |
choices | array | Up to 25 { name, value } (name 1 to 100 characters). For string, integer and number options. When present these are the only valid values |
autocomplete | boolean | Your application suggests values while the member types. Cannot be combined with choices |
min_value, max_value | number | Bounds, for integer and number options |
min_length, max_length | integer | Bounds on the text (0 to 6000), for string options |
channel_types | array | Kinds of channel to offer: TEXT, VOICE, FORUM, TODO, DOC, CALENDAR, PARTY, GALLERY, CATEGORY |
options | array | For sub-commands and groups: up to 25 |
name_localizations, description_localizations | object | As on the command |
Option types
| Name | Value | Notes |
|---|---|---|
SUB_COMMAND | 1 | /server info. A command has either sub-commands or values, never both |
SUB_COMMAND_GROUP | 2 | /server roles list: groups hold sub-commands, one level deep |
STRING | 3 | |
INTEGER | 4 | Whole numbers between −2⁵³ and 2⁵³ |
BOOLEAN | 5 | |
USER | 6 | A member of the server, given as an id |
CHANNEL | 7 | |
ROLE | 8 | |
MENTIONABLE | 9 | A member or a role |
NUMBER | 10 | Any number |
ATTACHMENT | 11 | Not supported yet |
Limits
| Slash commands per application, per scope | 100 |
| Each kind of context-menu command per application, per scope | 15 |
| Everything in one command (name, description, options, choices) | 8000 characters |
| Options in a list | 25 |
A scope is "global" or "one server". A name is used once per application, per kind and per scope; registering a name that exists changes that command.
Create global command
POST
/applications/@me/commands Registers a command that works in every server your bot is in, or changes the one with the same name and kind. Returns 201 with the command when it is new and 200 when an existing one was changed.
RequestPOST
/applications/@me/commands bash
curl -X POST https://moymo.net/api/app/v1/applications/@me/commands \
-H "Authorization: Bot $MOYMO_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "roll",
"description": "Roll some dice",
"options": [{
"type": 4,
"name": "sides",
"description": "How many sides",
"required": true,
"min_value": 2,
"max_value": 100
}]
}'js
const response = await fetch('https://moymo.net/api/app/v1/applications/@me/commands', {
method: 'POST',
headers: {
Authorization: `Bot ${process.env.MOYMO_BOT_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'roll',
description: 'Roll some dice',
options: [{
type: 4,
name: 'sides',
description: 'How many sides',
required: true,
min_value: 2,
max_value: 100
}]
})
})
const command = await response.json()python
import os
import requests
response = requests.post(
"https://moymo.net/api/app/v1/applications/@me/commands",
headers={"Authorization": f"Bot {os.environ['MOYMO_BOT_TOKEN']}"},
json={
"name": "roll",
"description": "Roll some dice",
"options": [{
"type": 4,
"name": "sides",
"description": "How many sides",
"required": True,
"min_value": 2,
"max_value": 100,
}],
},
)
command = response.json()Response201CreatedJSON
json
{
"id": "3b9d5e21-8c47-4a06-b1f2-6e0a7d4c9f38",
"application_id": "0f6c1a52-3b9e-4c1c-9d1b-6e7d2a8f4b10",
"type": 1,
"name": "roll",
"description": "Roll some dice",
"options": [{
"type": 4,
"name": "sides",
"description": "How many sides",
"required": true,
"min_value": 2,
"max_value": 100
}],
"version": 1
}Get global commands
GET
/applications/@me/commands The application's global commands.
Get global command
GET
/applications/@me/commands/{command.id} Edit global command
PATCH
/applications/@me/commands/{command.id} Changes the fields you give; the others stay. The type cannot be changed.
Delete global command
DELETE
/applications/@me/commands/{command.id} Returns 204.
Bulk overwrite global commands
PUT
/applications/@me/commands Takes a list of commands and makes the application's global commands exactly that list: new ones are added, ones whose name and kind exist are changed, the others are removed. This is the call to make when your program starts. Returns the list as it is now.
RequestPUT
/applications/@me/commands Shellbash
curl -X PUT https://moymo.net/api/app/v1/applications/@me/commands \
-H "Authorization: Bot $MOYMO_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{ "name": "hello", "description": "Say hello" },
{ "name": "roll", "description": "Roll some dice" },
{ "type": 3, "name": "Quote this" }
]'An empty list removes everything
PUT with [] removes all the application's global commands. Build the list from your code, not from what is already registered.
Server commands
The same operations for commands that exist only in one server. The bot has to be in the server, or the answer is 403.
GET
/applications/@me/servers/{server.id}/commands POST
/applications/@me/servers/{server.id}/commands PUT
/applications/@me/servers/{server.id}/commands GET
/applications/@me/servers/{server.id}/commands/{command.id} PATCH
/applications/@me/servers/{server.id}/commands/{command.id} DELETE
/applications/@me/servers/{server.id}/commands/{command.id} What a member sees
A command shows in the slash menu only when the application has a verified interactions endpoint, the bot is in the server, and the member has the permissions in default_member_permissions in that channel. You can look at everything an application has registered, and remove a command, on the Commands tab of the portal.