Skip to content

Subcommands

Table of Contents


Sub commands

Sub-commands are apart of slash commands and are used to add as the name already suggest sub commands to the regular slash command. Which does not only “bypass” the slash command limit but also allows you to properly structure your application commands.

Creating Application Commands

1
$createApplicationCommand[guildID/global;name;description;defaultPermission(true/false);type(slash/user/message);options?]
FieldTypeDescriptionRequired
guildID/globalstring, numberThe type of application command, either for every guild (global) or for one specific guild (specific guildID).true
namestring, numberThe actual slash command name that will be visible to the user.true
descriptionstring, numberThe slash command description that will be visible to the user.true
defaultPermissionstringIf the application command should synchronize to the default permissions.true
typestringThe application command type (explained below)true
options?objectSlash commands options.true

Examples of creating Application Commands with sub commands

1
client.command({
2
name: "createApplicationCommand",
3
code: `
4
$createApplicationCommand[guildID/global;moderation;Moderation Commands!;true;true;slash;[
5
{
6
"name": "kick",
7
"description": "Kick someone of your guild!",
8
"type": 1
9
},
10
{
11
"name": "ban",
12
"description": "Ban someone of your guild!",
13
"type": 1
14
}
15
]]`
16
});

Creating Sub Commands with options

Creating sub commands with options or choices work basically the same as any other.

1
client.command({
2
name: "createApplicationCommand",
3
code: `
4
$createApplicationCommand[$guildID;moderation;Moderation Commands!;true;true;slash;[
5
{
6
"name": "kick",
7
"description": "Kick someone out of your guild!",
8
"type": 1,
9
"options": [
10
{
11
"name": "user",
12
"description": "Mention the user you want to kick",
13
"required": true,
14
"type": 6
15
},
16
{
17
"name": "reason",
18
"description": "Reason",
19
"required": true,
20
"type": 3
21
}
22
]
23
},
24
{
25
"name": "ban",
26
"description": "Ban someone of your guild!",
27
"type": 1,
28
"options": [
29
{
30
"name": "user",
31
"description": "Mention the user you want to kick",
32
"required": true,
33
"type": 6
34
},
35
{
36
"name": "reason",
37
"description": "Reason",
38
"required": true,
39
"type": 3
40
}
41
]
42
}]
43
]`
44
});

That would for example add two options called “user” and “reason”, where reason is type 3, string and user type 6, mention (user).

Replying to Sub commands

1
<client>.interactionCommand({
2
name: "moderation",
3
sub_command: "ban"
4
prototype: "slash"
5
code: ...
6
})

This would only make the bot reply to the “ban” sub-command, you can return the sub-command with $interactionData[options._subcommand].