Slash Commands

Slash Commands are the new, exciting way to build and interact with bots on Discord. With Slash Commands, all you have to do is type / and you're ready to use your favorite bot. Users can learn everything your bot does and easily find new features as you add them. Validation, error states, and helpful UI walks them through your commands, meaning they can get it right the first time, especially on mobile. You now have one more ally in the fight against your phone's autocorrect. Slash Commands set your users up for success instead of confusion and frustration. They separate how users think and how your code works, meaning no matter how complex your codebase and commands may get, people who love your bot will find it approachable and easy to use.

Prerequisites

Scopes

Your bot must be invited with the bot and applications.commands scopes.

onInteraction Event

Don't forget to add the onInteraction event to your main file. For example:

Limitations

  • Each bot can have 100 global slash commands, as well as, 100 slash commands per guild.

  • Slash commands can not share the same name.

  • Slash command names can not contain special characters and must be shorter than 32 characters.

Application Command Data

Create slash command data in your main file.

Template:

With Options

Without Options

Example:

Creating Slash Commands

Finalizing your slash commands.

Global slash commands can take up to an hour to fully register. Guild slash commands should be registered instantly.

Template: Guild Slash Command_

Global Slash Command

Examples: Guild Slash Command

Global Slash Command

Responding to Slash Commands

Template:

Example:

Last updated

Was this helpful?