What Are Slash Commands?
Slash commands are the modern Discord bot interaction model. When users type / in a channel, Discord shows a list of available commands with descriptions and parameter hints. They replaced the old prefix system as the recommended way to interact with bots.
Advantages Over Prefix Commands
- Auto-complete shows users available commands
- Parameter descriptions guide users on what to enter
- No conflicts between bots using the same prefix
- Required and optional parameters are clearly defined
Global vs Guild Commands
Global commands appear in all servers and take up to 1 hour to register. Guild commands are instant and only appear in specific servers — useful for testing.
Command Types
- Chat input commands — the standard / commands
- User commands — right-click on a user to trigger
- Message commands — right-click on a message to trigger
Handling Responses
Slash commands must be acknowledged within 3 seconds or Discord shows a failure message. Use interaction.deferReply() for operations that take longer, then follow up with interaction.editReply().
Example Implementation
The official discord.js guide at discordjs.guide is the best resource for slash command implementation with full code examples.