Discord Slash Command Builder
Design a slash command with options, choices and subcommands in a form that knows Discord's limits. See it in the command picker, then copy the JSON, a curl request, or discord.js and discord.py code.
The command
Lowercase, 1-32 characters, no spaces.
Every server with your app, and DMs if the contexts allow.
Options and subcommands
- Choices 3/25
- Choices 0/25
Required options must come before optional ones. A command with subcommands cannot take options of its own; each subcommand has its own.
Who can use it, and where
Only members with all of them see the command. Server admins can change this in Server Settings, Integrations.
Leave all off to use Discord's default.
Must already be enabled for your app in the Developer Portal. Leave both off to use the app's settings.
Work out which permissions a role actually has with the Discord permissions calculator.
Copy it
{
"name": "ticket",
"type": 1,
"description": "Open a support ticket",
"options": [
{
"type": 3,
"name": "topic",
"description": "What do you need help with?",
"required": true,
"choices": [
{
"name": "Billing",
"value": "billing"
},
{
"name": "Bug report",
"value": "bug"
},
{
"name": "Something else",
"value": "other"
}
]
},
{
"type": 3,
"name": "details",
"description": "Describe the problem",
"max_length": 1000
},
{
"type": 5,
"name": "private",
"description": "Only staff can see the ticket"
}
],
"integration_types": [
0
],
"contexts": [
0
]
}Posting a command with a name that already exists replaces it, so you can re-run the same request after each change.
Runs in your browser. Nothing is sent anywhere: you register the command yourself with the copied request or code, and your token never touches this page.
The limits Discord checks
Discord validates a command when you register it and rejects the whole request if one rule fails. The builder applies the same rules as you type:
- Names: 1-32 characters, lowercase where a lowercase form exists, letters, numbers,
-and_. This applies to the command, every option and every subcommand. - Descriptions: 1-100 characters, required on the command and on every option.
- Counts: up to 25 options at each level and 25 choices per option.
- Order: required options before optional ones. This is the most common rejection when adding an option to an existing command.
- Text length:
min_length0-6000,max_length1-6000. - Total size: 8,000 characters of names, descriptions and choice values across the whole command.
Choosing option types
The option type decides what the user is offered while typing, and what your code receives. Picking the right one removes a lot of validation from your handler.
- User, Role, Channel and User or role open Discord's own pickers, so people choose a real member, role or channel instead of typing a name. Your bot receives the ID and the resolved object.
- Whole number and Decimal number only accept numbers, and a minimum and maximum make Discord refuse anything outside the range before your bot sees it.
- Text with choices becomes a fixed menu; with a minimum and maximum length it stops one-letter answers and essays.
- True / false suits switches such as “private” or “notify”. Leave it optional, and treat a missing value as false.
- File lets the user attach an image or document to the command itself.
Subcommands and groups
Subcommands turn one command into a family: /ticket open, /ticket close, /ticket admin assign. Discord allows exactly one level of grouping. A command holds subcommands or groups; a group holds subcommands; a subcommand holds ordinary options. Once a command has subcommands, the bare /ticket can no longer be run on its own, which is why the builder will not let you mix the two at one level.
In the picker each subcommand is listed as its own entry, so its description carries the explanation. Group related actions that share permissions; a moderation group that only moderators see is a common pattern.
Registered but not showing up
A successful registration returns the command with an id. If it still does not appear, the reason is usually one of these: it was registered for a different server or a different application; default_member_permissions, or the server's Integrations settings, hide it from your account; or the client has not refreshed, which reloading Discord fixes. The full checklist is in Discord slash commands not showing.
Register guild commands while you develop, because they change at once in that one server. Switch to global registration when the command is ready. Discord also limits how many commands you can create per day, so avoid re-creating every command on each restart; the Discord API limits page lists the numbers, and Discord error codes explain rejected requests.
After registration: answering the interaction
Registering only adds the command to the picker. When someone runs it, Discord sends your app an interaction, and your code must reply within three seconds or defer. The discord.js and discord.py tabs include a stub handler for that. If you would rather not host that code, a Discord bot built in Conferbot answers members from a visual flow. New to the concept? Start with what slash commands are.
Frequently asked questions
How do I create a slash command in Discord?
You register it with Discord's API: send the command's JSON to the application commands endpoint with your bot token, for one server or globally. Libraries such as discord.js and discord.py wrap that call. This builder produces the JSON, both curl commands and the library code, and checks every documented limit first so the request is not rejected.
What is the difference between global and guild commands?
A guild command is registered for one server and updates there at once, which makes it right for testing. A global command is registered once and is available in every server that has your app, and in DMs if its contexts allow. Global commands are also the only ones that can use contexts and installation types.
Why must slash command names be lowercase?
Discord's naming rule says that if a letter has a lowercase form, the lowercase form must be used. Names are also 1 to 32 characters from letters, numbers, hyphens and underscores, with no spaces. Letters from other scripts are allowed, so a command can be named in Hindi or Thai. Option names follow the same rule.
How many options can a slash command have?
Up to 25 options per command, 25 per subcommand, and up to 25 choices per option. The whole command, including subcommands, options and choices, is also limited to 8,000 characters of names, descriptions and values together. The counter in the builder tracks that total as you type.
How do I make a slash command only for admins or moderators?
Set default_member_permissions. Pick the permissions a member must have, such as Manage Messages, and only members with them see the command; set it to 0 and only administrators see it. Server admins can still change who can use it in Server Settings, Integrations, so treat it as a default, and check permissions in your handler too.
Should I use choices or autocomplete?
Use choices when the list is short and fixed, up to 25 items: Discord shows them as a menu and only accepts those values. Use autocomplete when the list is long or changes, such as product names or open tickets: your bot receives what the user is typing and returns suggestions. An option cannot have both.
Related
Skip the handler code
Build a Discord bot that answers members, runs a support desk and hands over to your team, from a visual flow. No code, free plan, no card.