Create Command
Creates a Discord slash command (application command) that users can invoke with / in Discord.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Client Id - The Discord bot client identifier from the Connect node (optional if Bot Token provided).
- Application Id - The Discord application ID (found in Developer Portal).
- Commands - JSON configuration defining the command structure.
Options
- Bot Token - Discord bot token credential (optional if using Client ID from Connect node).
- Server Id - (Optional) Server (guild) ID to create a server-specific command. If empty, creates a global command.
How It Works
The Create Command node registers a slash command with Discord. When executed, the node:
- Authenticates using either Client ID or direct bot token
- Validates the application ID
- Parses the command JSON configuration
- Processes any mustache template variables in the JSON
- Sends the command registration request to Discord API
- Creates the command (globally or for a specific server)
Requirements
- Active Discord bot session (Client ID) or bot token credentials
- Valid application ID (from Discord Developer Portal)
- applications.commands scope enabled for the bot
- Properly formatted command JSON
Error Handling
The node will return specific errors in the following cases:
- ErrInvalidArg - Client ID or bot token missing/invalid
- ErrInvalidArg - Application ID is empty
- ErrUnmarshal - Invalid JSON format in Commands field
- ErrCommandCreate - Error creating the command (invalid structure, duplicate name, etc.)
Command JSON Structure
Basic command:
{
"name": "hello",
"description": "Says hello to the user",
"type": 1
}
Command with options:
{
"name": "greet",
"description": "Greet a user",
"type": 1,
"options": [
{
"name": "user",
"description": "The user to greet",
"type": 6,
"required": true
},
{
"name": "message",
"description": "Custom greeting message",
"type": 3,
"required": false
}
]
}
Command with choices:
{
"name": "status",
"description": "Set your status",
"type": 1,
"options": [
{
"name": "mood",
"description": "Your current mood",
"type": 3,
"required": true,
"choices": [
{"name": "Happy", "value": "happy"},
{"name": "Sad", "value": "sad"},
{"name": "Excited", "value": "excited"}
]
}
]
}
Command Properties
Top level:
- name - Command name (lowercase, 1-32 characters, no spaces)
- description - Command description (1-100 characters)
- type - Command type (1=Slash command, 2=User command, 3=Message command)
- options - Array of command options/arguments
Option types:
- 1 - Sub-command
- 2 - Sub-command group
- 3 - String
- 4 - Integer
- 5 - Boolean
- 6 - User
- 7 - Channel
- 8 - Role
- 9 - Mentionable (user or role)
- 10 - Number (decimal)
Global vs Server Commands
Global Commands:
- Available in all servers where the bot is installed
- Take up to 1 hour to propagate
- Limited to 100 global commands per application
Server Commands:
- Only available in the specified server
- Update instantly
- Limited to 100 commands per server
- Better for testing
Example: Simple Command
Inputs:
- Application Id: "123456789012345678"
- Commands:
{
"name": "ping",
"description": "Check bot latency",
"type": 1
}
Result: Creates a /ping command users can invoke.
Example: Command with User Input
Inputs:
- Application Id: "123456789012345678"
- Server Id: "987654321098765432" (for testing)
- Commands:
{
"name": "announce",
"description": "Send an announcement",
"type": 1,
"options": [
{
"name": "message",
"description": "The announcement message",
"type": 3,
"required": true
},
{
"name": "channel",
"description": "Channel to send to",
"type": 7,
"required": true
}
]
}
Example: Command with Subcommands
Commands:
{
"name": "admin",
"description": "Admin commands",
"type": 1,
"options": [
{
"name": "ban",
"description": "Ban a user",
"type": 1,
"options": [
{
"name": "user",
"description": "User to ban",
"type": 6,
"required": true
}
]
},
{
"name": "kick",
"description": "Kick a user",
"type": 1,
"options": [
{
"name": "user",
"description": "User to kick",
"type": 6,
"required": true
}
]
}
]
}
Result: Creates /admin ban and /admin kick commands.
Handling Command Interactions
After creating commands, use Interaction In node to listen for when users invoke them:
1. Create Command (setup phase)
2. Interaction In (runtime - listening for /command usage)
3. Interaction Out (send response)
Use Cases
- Bot features - Expose bot functionality as slash commands
- Server management - Admin and moderation commands
- Utilities - Helper commands for users
- Games - Game-related commands
- Information - Commands to display server or user info
- Configuration - Commands to configure bot behavior
Command Naming Rules
- 1-32 characters
- Lowercase only
- No spaces (use hyphens if needed)
- Letters, numbers, and hyphens only
- Cannot start or end with hyphen
Good names: ping, user-info, ban-user
Bad names: Ping, user info, -ban
Getting Your Application ID
- Go to Discord Developer Portal
- Select your application
- Go to "General Information"
- Copy the "Application ID"
Tips and Best Practices
- Test with server commands - Use Server Id for instant testing
- Descriptive names - Make command names clear and obvious
- Help text - Write clear, helpful descriptions
- Required vs optional - Mark parameters appropriately
- Choices - Use choices for predefined options
- Validation - Validate option values in your interaction handler
- Update strategy - Delete and recreate rather than editing for major changes
- Global rollout - Test server commands before making global