Auto Complete for Slash Command Options

Auto complete allows your bot to read user input as they type it and give user suggestions based on that.
example-autocomplete
Check example to get started quickly.

General Information

  • You can only create up to 25 suggestions per option
  • You need to enable autocomplete for the option
  • You can’t use option choices with autocomplete

$onAutoComplete[Name] callback

This callback receives information about current user input. It’s used for adding suggestions.
Name is the name of a slash command.

Avaliable functions

$appendOptionSuggestion[Label;Value]

Used for adding new suggestions.

  • Label - text which will be displayed in the suggestion list (for example: arg-ad from the previous example)
  • Value - data that can be accessed in a slash command by using $message[] function. label is only a display name but value holds the actual value for a suggestion.

Note: value must have the same type as the currently typed option! Meaning, if the option’s type is Integer, value can’t be set to Hello but it can be set to 123

$autoCompleteOptionName

Returns the name of currently being typed option. For example arg from the previous example

$autoCompleteOptionValue

Returns the current user input. For example ad from the previous example

Example

New slash command with a new option:

slash auto complete

Slash option:

slash option

Slash command code:

$message[arg]

$onAutoComplete[] callback:

autocompletetrigger

Callback code

$nomention
$appendOptionSuggestion[$autoCompleteOptionName-$autoCompleteOptionValue;$autoCompleteOptionValue]
Explanation
  • $appendOptionSuggestion[] - adds new suggestion
  • $autoCompleteOptionName-$autoCompleteOptionValue - suggestion’s label. It’s set to the option name and user input (<option name>-<user input>)
  • $autoCompleteOptionValue - suggestion’s value. It’s set to whatever user typed.

Result:

1.

example-autocomplete

2.

example-autocomplete2