lightbulb.commands.options¶
- class Choice(name: 'str', value: 'T', localize: 'bool' = False)[source]¶
-
- value: T¶
The value of the choice.
- class Option(data: OptionData[D], default_when_not_bound: T)[source]¶
Descriptor class representing a command option.
This class should generally not be instantiated manually and instead be created through the use of one of the helper functions.
- Parameters:
data – The dataclass describing this instance.
default_when_not_bound – The value to return from the descriptor if accessed through the class instead of through an instance
- class OptionData(type: OptionType, name: str, description: str, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[t.Any]]] = UNDEFINED, channel_types: hikari.UndefinedOr[Sequence[ChannelType]] = UNDEFINED, min_value: hikari.UndefinedOr[int | float] = UNDEFINED, max_value: hikari.UndefinedOr[int | float] = UNDEFINED, min_length: hikari.UndefinedOr[int] = UNDEFINED, max_length: hikari.UndefinedOr[int] = UNDEFINED, autocomplete: bool = False, autocomplete_provider: hikari.UndefinedOr[AutocompleteProvider[t.Any]] = UNDEFINED)[source]¶
Dataclass for storing information about an option necessary for command creation.
This should generally not be instantiated manually. An appropriate one will be generated when defining an option within a command class.
- async to_command_option(default_locale: Locale, localization_provider: localization.LocalizationProvider) CommandOption [source]¶
Convert this option data into a hikari
CommandOption
.- Parameters:
default_locale – The default locale to use when resolving localizations.
localization_provider – The localization provider to use when resolving localizations.
- Returns:
The created command option.
- autocomplete_provider: hikari.UndefinedOr[AutocompleteProvider[t.Any]]¶
The provider to use to resolve autocomplete interactions for this command.
- channel_types: hikari.UndefinedOr[Sequence[ChannelType]]¶
The channel types for the option.
- default: hikari.UndefinedOr[D]¶
The default value for the option.
- localize: bool¶
Whether the name and description of the option should be interpreted as localization keys.
- type: OptionType¶
The type of the option.
- attachment(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Attachment | D [source]¶
An attachment option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- boolean(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) bool | D [source]¶
A boolean option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- channel(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, channel_types: hikari.UndefinedOr[Sequence[ChannelType]] = UNDEFINED) PartialChannel | D [source]¶
A channel option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
channel_types – The channel types permitted for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- integer(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[int]]] = UNDEFINED, min_value: hikari.UndefinedOr[int] = UNDEFINED, max_value: hikari.UndefinedOr[int] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[int]] = UNDEFINED) int | D [source]¶
An integer option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
choices – The choices for the option.
min_value – The minimum value for the option.
max_value – The maximum value for the option.
autocomplete – The autocomplete provider function to use for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- mentionable(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Snowflake | D [source]¶
A mentionable (snowflake) option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- number(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[float]]] = UNDEFINED, min_value: hikari.UndefinedOr[float] = UNDEFINED, max_value: hikari.UndefinedOr[float] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[float]] = UNDEFINED) float | D [source]¶
A numeric (float) option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
choices – The choices for the option.
min_value – The minimum value for the option.
max_value – The maximum value for the option.
autocomplete – The autocomplete provider function to use for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- role(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Role | D [source]¶
A role option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- string(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[str]]] = UNDEFINED, min_length: hikari.UndefinedOr[int] = UNDEFINED, max_length: hikari.UndefinedOr[int] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[str]] = UNDEFINED) str | D [source]¶
A string option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
choices – The choices for the option.
min_length – The minimum length for the option.
max_length – The maximum length for the option.
autocomplete – The autocomplete provider function to use for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- user(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) User | D [source]¶
A user option.
- Parameters:
name – The name of the option.
description – The description of the option.
localize – Whether to localize this option’s name and description. If
True
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.