At present applications must pre-define all possible options when accepting input from users. We want to enable applications to dynamically populate options in slash commands, which would allow for more use-cases (like building a simple search or supporting many choices).

We also want to think about this API in an extensible way, to cover possible new uses for an API like this (for example a giphy-like command, which lists results of images).

Note that one of the use cases explicitly not being solved for here is option discovery, i.e. allowing a user to browse lots of options to choose one. This is something we plan to address in the future.

A video of this feature being used for dictionary lookup!

A video of this feature being used for dictionary lookup!

Application Command Changes

Application command options are updated to have an autocomplete boolean field.

{
	name: "airhorn",
  options: [
    {
      type: 3,
      name: "variant",
      autocomplete: true, // `choices` cannot be present when this is true
    },
  ],
  ...otherApplicationCommandFields
}

Note that an autocomplete option is still a free-form input, and neither the client or the server enforces that the autocomplete suggestions you provide are what you will get back.

Autocomplete Interaction

To keep things simple, we use almost the same schema as a normal application command interaction, with a new interaction type (type 4, APPLICATION_COMMAND_AUTOCOMPLETE). The two differences are that the option currently being autocompleted has a focused boolean set to true, and that otherwise required options may not be passed (if the user hasn't filled them out yet).

Here's an example:

{
  type: 4,
  data: {
    id: "816437322781949972" // command id
    name: "airhorn" // command name
    type: 1 // command type
    version: "847194950382780532" // command version
    options: [
      // we will also pass all wip options, since maybe the bot wants to
      // render different filters based on prior choices
      // (maybe you select a category first, which filters results in autocomplete)
      {
        type: 3, // command option type
        name: "variant", // command option name
        // optional command option value,
        // (if any, since maybe a bot wants dynamic defaults on load)
        value: "data a user is typ"
        focused: true // this indicates which field a user has focused
      }
    ]
  },
  ...allOtherStandardInteractionFields
}

Interaction Callback

We also need a callback from bots which defines the results to display to the user, which we can add another callback type for (type 8, APPLICATION_COMMAND_AUTOCOMPLETE_RESULT):

{
  type: 8,
  data: {
    choices: [
      {
        name: 'A user visible choice display name',
        value: 'a_user_invisible_choice_value'
      }
    ]
  },
}

Note that currently each response is still limited to a maximum of 25 items.

That's it!