Option
Represents a selectable option for a slash command.Parameters
The type of input that is expected for this option. Can be:
- Basic types:
str,int,float,bool - Discord types:
User,Member,Role,GuildChannel,Thread,Attachment,Mentionable SlashCommandOptionTypeenumConverteror converter classenum.Enum- If the enum has ≤25 values, choices are auto-filled. If >25 values, autocomplete is used.
The description of this option. Must be 100 characters or fewer. If
input_type is an Enum and description is not specified, the Enum’s docstring will be used.The name of this option visible in the UI. Inherits from the variable name if not provided as a parameter.
The list of available choices for this option. Can be a list of values or OptionChoice objects. If provided, the input from the user must match one of the choices.
Whether this option is required. Automatically set to
False if default is provided.The default value for this option. If provided,
required will be considered False.The minimum value that can be entered. Only applies to Options with an
input_type of int or float.The maximum value that can be entered. Only applies to Options with an
input_type of int or float.The minimum length of the string that can be entered. Must be between 0 and 6000 (inclusive). Only applies to Options with an
input_type of str.The maximum length of the string that can be entered. Must be between 1 and 6000 (inclusive). Only applies to Options with an
input_type of str.A list of channel types that can be selected in this option. Only applies to Options with an
input_type of SlashCommandOptionType.channel. If this argument is used, input_type will be ignored.The autocomplete handler for the option. Accepts a callable (sync or async) that takes an
AutocompleteContext or Cog and AutocompleteContext. Must return an iterable of str, int, float, or OptionChoice.The name localizations for this option. The values of this should be
"locale": "name". See Discord’s locales documentation for valid locales.The description localizations for this option. The values should be
"locale": "description".Attributes
The resolved input type for this option.
The name of the option.
The description of the option.
Whether this option is required.
The list of available choices for this option.
The autocomplete handler for the option. Does not validate the input value against the autocomplete results.
OptionChoice
Represents a name:value pairing for a selected Option.Parameters
The name of the choice. Shown in the UI when selecting an option.
The value of the choice. If not provided, will use the value of
name.The name localizations for this choice. The values should be
"locale": "name".Attributes
The display name of the choice.
The actual value that gets passed to the command.
option()
A decorator that can be used instead of typehinting Option.The name of the option in the Discord UI.
The type of input expected. Defaults to the parameter’s type annotation.
The name of the target function parameter this option is mapped to. This allows you to have a separate UI name and parameter name.
Additional keyword arguments to pass to the Option constructor.
ThreadOption
Represents a class that can be passed as theinput_type for an Option class to specify thread types.
Parameters
The thread type to expect for this option’s input.
