Slash commands vs prefix commands: which should your bot use?

Discord bots used to listen for messages like !ban @user. Today most use slash commands, such as /ban. Both still work, but they behave very differently, and the right choice affects permissions, privacy, how easy your bot is to use and how well it scales. Here is how they compare, and how to decide.

How each works

Prefix commands. The bot reads every message and checks whether it starts with a prefix, such as !. If so, it treats the rest as a command. This requires the bot to see the content of messages, which needs the Message Content intent. See Discord gateway intents explained.

Slash commands. The bot registers its commands with Discord ahead of time. When a user types /, Discord shows a list with descriptions and option fields. When they run one, Discord sends the bot an interaction containing just that command and its options. The bot never reads ordinary messages.

Comparison

PointPrefix commandsSlash commands
DiscoverabilityUsers must know or read a help listBuilt-in menu lists commands and options
Message Content intentRequiredNot needed
PermissionsYou must code the checksDiscord can restrict who sees a command
Input checkingYou parse text yourselfOptions have types, such as user, channel or number
ConflictsTwo bots can share a prefixCommands are labelled with the bot's name
PrivacyThe bot reads all messagesThe bot sees only the command
Verification at scaleNeeds approval for message contentEasier

Slash commands win for nearly everything new. They are easier for members, safer and kinder to your bot's growth.

When prefix commands still make sense

  • Reading messages is the point. Moderation bots that scan for spam, bots that log deleted messages, or ones that react to keywords need message content anyway.
  • Very simple private bots on small servers, where a prefix is quicker to write.
  • Legacy bots you do not want to rewrite yet.

Many bots offer both, with slash commands as the main way and a prefix as a fallback.

How slash commands are registered

Commands must be registered with Discord through its API, and your library does this for you.

  • Guild commands apply to one server and update instantly, which makes them ideal while developing.
  • Global commands apply everywhere your bot is, and are what you use for a finished bot. There is a limit on how many a bot can have, at 100 chat input commands.

Register again only when the list changes, not every time the bot starts. Repeated registration wastes your rate limit. See Handling Discord rate limits.

The three second rule

When a user runs a slash command, your bot has three seconds to respond. If it takes longer, Discord shows "The application did not respond", and the interaction fails. For slow work such as a database query or an external request:

  1. Send a deferred response straight away. The user sees "Bot is thinking...".
  2. Do the work.
  3. Send the final answer as a follow-up. You have up to 15 minutes.

Forgetting to defer is the most common cause of intermittent failures, particularly when your bot is on a busy or slow server.

Permissions

Discord lets you set default permissions on a command, such as "only members who can manage messages". Server owners can then change who may use it in their server's settings. Do not rely only on that. Check permissions inside your code for anything dangerous, because the interface rules can be changed.

Planning the move

If you have a prefix bot and want to switch:

  1. List your commands and their options.
  2. Rebuild them as slash commands, one at a time.
  3. Keep the prefix versions for a while, with a message telling people about the new ones.
  4. Remove the old ones, and turn off the Message Content intent if you no longer need it.

Your hosting needs do not change much between the two, though a bot that reads every message uses more processing on a large server. Hosting resource sizing for Discord bots gives guidance. And Deploy a Node.js Discord bot or Deploy a Python bot show how to get yours running.


Still stuck? Open a ticket on Discord - run /ticket in any channel, pick a department, and include your Server ID or Invoice ID so we can jump straight in.