Slash commands are the primary way users interact with your Discord bot. They appear in Discord’s command menu and can accept various types of options.Documentation Index
Fetch the complete documentation index at: https://djs-core.cleboost.com/llms.txt
Use this file to discover all available pages before exploring further.
Commands are automatically registered when placed in
src/interactions/commands/. The command name is derived from the file path, so src/interactions/commands/ping.ts becomes /ping.Creating a Command
Commands in djs-core are created using theCommand class. Each command file in src/interactions/commands/ automatically becomes a slash command.
Basic Command
Here’s a simple ping command:| File Path | Command Name |
|---|---|
src/interactions/commands/ping.ts | /ping |
src/interactions/commands/admin/kick.ts | /admin kick |
src/interactions/commands/shop/buy.ts | /shop buy |
src/interactions/commands/admin/moderation/ban.ts | /admin moderation ban |
Command Options
Commands can accept various types of options to collect user input. Each option type serves a specific purpose:- String: Text input - for names, descriptions, messages, etc.
- Integer/Number: Numeric input - for quantities, IDs, timestamps, etc.
- Boolean: True/false checkbox - for toggles and flags
- User: Discord user selection - for mentions and user-specific actions
- Channel: Discord channel selection - for channel configuration
- Role: Discord role selection - for role assignment
- Mentionable: User or role selection - flexible mention option
- Attachment: File upload - for images, documents, etc.
String Option
Autocomplete
Commands can provide autocomplete suggestions for string, integer, and number options. This improves user experience by showing relevant options as they type.Permissions
You can restrict commands to users with specific permissions. This is essential for administrative or sensitive commands.[src/interactions/commands/admin/restart.ts]