Why Discord Bot Slash Command Choices Limited to 25 in Dropdown
🔍 WiseChecker

Why Discord Bot Slash Command Choices Limited to 25 in Dropdown

When building a Discord bot with slash commands, you may notice that dropdown menus for command options only display up to 25 choices. This limit applies to the choices parameter in slash command option definitions. The restriction exists because Discord enforces a maximum of 25 choices per command option to keep the user interface clean and responsive. This article explains why the limit exists, how it affects bot development, and what you can do to work around it.

Key Takeaways: Discord Slash Command Choice Limit

  • 25 choices per option: Discord restricts the choices array to 25 items for each slash command option.
  • Autocomplete as alternative: Use autocomplete interaction to handle more than 25 choices dynamically.
  • Option type matters: The 25 limit applies to STRING, INTEGER, and NUMBER option types with predefined choices.

ADVERTISEMENT

Why Discord Limits Slash Command Choices to 25

Discord limits the number of choices in a slash command option to 25 for performance and usability reasons. Each choice is part of the command definition sent to every client that can use the command. If a bot had hundreds of choices, the command definition payload would become large, increasing latency when loading commands and consuming more memory on client devices.

The 25-choice limit also prevents cluttered dropdown menus. A dropdown with more than 25 items becomes hard to scroll through on mobile devices and small windows. Discord designed slash commands to be fast and clean, so the limit keeps the interface manageable.

The restriction applies to the choices parameter when defining a command option. You can still use autocomplete to provide more than 25 options. Autocomplete sends a request to your bot when the user types, allowing you to return up to 25 suggestions per request, but you can respond with different sets based on the user’s input.

How the 25-Choice Limit Affects Bot Commands

If your bot needs to let users select from a large list, such as a server roster, game titles, or time zones, the 25-choice limit forces you to redesign the command. You have two main options: limit the command to 25 choices or switch to autocomplete. The autocomplete approach gives you flexibility but requires additional code to handle the interaction.

Steps to Work Around the 25-Choice Limit

Follow these steps to replace predefined choices with autocomplete in your Discord bot.

  1. Identify the command option with more than 25 choices
    Look at your slash command definitions. Find options where the choices array has more than 25 items. These options must use autocomplete instead.
  2. Remove the choices array from the option definition
    In your bot code, delete the choices parameter from the option. Add autocomplete: true to the option object. For example, in discord.js: options: [{ name: 'game', type: ApplicationCommandOptionType.String, autocomplete: true, required: true }].
  3. Register the updated command with Discord
    Run your bot’s command registration script. The command must be updated globally or for the guild. Wait up to one hour for global commands to propagate, or use guild commands for instant updates during development.
  4. Create an autocomplete interaction handler
    In your bot code, listen for the interactionCreate event. Check if the interaction is an autocomplete interaction. If yes, extract the user’s current input and query your data source for matching items.
  5. Return up to 25 suggestions per autocomplete request
    Build an array of objects with name and value properties. Send the array using interaction.respond(). You can return a maximum of 25 suggestions per response, but you can filter based on what the user typed.
  6. Handle the final command execution
    When the user selects an autocomplete suggestion and submits the command, your bot receives a normal command interaction. Use the selected value as you would with predefined choices.

Example Code Snippet for Autocomplete in discord.js

The following example shows a simple autocomplete handler that returns game titles matching the user’s input.

client.on('interactionCreate', async interaction => {
  if (!interaction.isAutocomplete()) return;
  
  const focusedValue = interaction.options.getFocused();
  const allGames = ['Fortnite', 'Minecraft', 'Roblox', 'Valorant', 'League of Legends', 'Apex Legends', 'Overwatch 2', 'Call of Duty: Warzone', 'Grand Theft Auto V', 'Rocket League', 'Counter-Strike 2', 'Dota 2', 'World of Warcraft', 'Elder Scrolls Online', 'Destiny 2', 'Rainbow Six Siege', 'Team Fortress 2', 'Fall Guys', 'Among Us', 'Halo Infinite', 'Battlefield 2042', 'FIFA 23', 'Madden NFL 24', 'NBA 2K24', 'The Sims 4', 'Stardew Valley', 'Terraria', 'Factorio', 'Cyberpunk 2077', 'Red Dead Redemption 2'];
  
  const filtered = allGames.filter(game =>
    game.toLowerCase().includes(focusedValue.toLowerCase())
  ).slice(0, 25);
  
  await interaction.respond(
    filtered.map(game => ({ name: game, value: game }))
  );
});

ADVERTISEMENT

Common Issues When Using Autocomplete Instead of Choices

Autocomplete Suggestions Do Not Appear

If autocomplete suggestions do not show up, check that you set autocomplete: true in the option definition and registered the command correctly. Also verify your bot has the application.commands scope and is present in the server. The autocomplete interaction fires only when the user types in that option field.

Bot Returns More Than 25 Suggestions

Discord will ignore any response with more than 25 suggestions. Always apply .slice(0, 25) to your filtered array before responding. If you need to show more options, encourage the user to type more specific text to narrow results.

Autocomplete Response Times Are Too Slow

Discord expects a response within 3 seconds for autocomplete interactions. If your data source is slow, consider caching the list in memory or using a local database. If you cannot respond in time, Discord shows no suggestions, and the user sees an error.

Discord Slash Command Choice Options: Predefined vs Autocomplete

Feature Predefined Choices Autocomplete
Maximum options 25 total 25 per response, unlimited total
User experience Dropdown appears immediately Suggestions appear as user types
Implementation complexity Simple, static array Requires interaction handler and data query
Dynamic filtering Not supported Filter results based on user input
Response time requirement None Must respond within 3 seconds
Best use case Small static lists Large or dynamic lists

Now you know why Discord limits slash command choices to 25 and how to work around it using autocomplete. Start by identifying which command options need more choices, then implement the autocomplete handler. For large datasets, consider caching the list to meet the 3-second response window. If you only need a few options, predefined choices remain the simplest approach.

ADVERTISEMENT