lightbulb.commands.options¶
- class lightbulb.commands.options.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 (
OptionData
[D
]) – The dataclass describing this instance.default_when_not_bound (
T
) – The value to return from the descriptor if accessed through the class instead of through an instance
- class lightbulb.commands.options.OptionData(type: hikari.OptionType, name: str, description: str, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[t.Sequence[hikari.CommandChoice]] = UNDEFINED, channel_types: hikari.UndefinedOr[t.Sequence[hikari.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[AutocompleteProviderT] = 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.
- channel_types: hikari.UndefinedOr[t.Sequence[hikari.ChannelType]]¶
The channel types for the option.
- choices: hikari.UndefinedOr[t.Sequence[hikari.CommandChoice]]¶
The choices 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: hikari.OptionType¶
The type of the option.
- lightbulb.commands.options.attachment(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Attachment | D [source]¶
An attachment option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- lightbulb.commands.options.boolean(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) bool | D [source]¶
A boolean option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- lightbulb.commands.options.channel(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED, channel_types: Sequence[ChannelType] | UndefinedType = UNDEFINED) PartialChannel | D [source]¶
A channel option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.channel_types (
UndefinedOr
[Sequence
[ChannelType
]]) – The channel types permitted for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- lightbulb.commands.options.integer(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[t.Sequence[hikari.CommandChoice] | t.Mapping[str, int] | t.Sequence[t.Tuple[str, int]] | t.Sequence[int]] = UNDEFINED, min_value: hikari.UndefinedOr[int] = UNDEFINED, max_value: hikari.UndefinedOr[int] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProviderT] = UNDEFINED) int | D [source]¶
An integer option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.choices (
UndefinedOr
[ChoicesT
]) – The choices for the option. Any of the following can be interpreted as a choice: a sequence ofCommandChoice
, a mapping of choice name to choice value, a sequence of 2-tuples where the first element is the name and the second element is the value, or a sequence ofint
where the choice name and value will be the same.min_value (
UndefinedOr
[int
]) – The minimum value for the option.max_value (
UndefinedOr
[int
]) – 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.
- lightbulb.commands.options.mentionable(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Snowflake | D [source]¶
A mentionable (snowflake) option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- lightbulb.commands.options.number(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[t.Sequence[hikari.CommandChoice] | t.Mapping[str, float] | t.Sequence[tuple[str, float]] | t.Sequence[float]] = UNDEFINED, min_value: hikari.UndefinedOr[float] = UNDEFINED, max_value: hikari.UndefinedOr[float] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProviderT] = UNDEFINED) float | D [source]¶
A numeric (float) option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.choices (
UndefinedOr
[ChoicesT
]) – The choices for the option. Any of the following can be interpreted as a choice: a sequence ofCommandChoice
, a mapping of choice name to choice value, a sequence of 2-tuples where the first element is the name and the second element is the value, or a sequence offloat
where the choice name and value will be the same.min_value (
UndefinedOr
[float
]) – The minimum value for the option.max_value (
UndefinedOr
[float
]) – 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.
- lightbulb.commands.options.role(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) Role | D [source]¶
A role option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.
- lightbulb.commands.options.string(name: str, description: str, /, *, localize: bool = False, default: hikari.UndefinedOr[D] = UNDEFINED, choices: hikari.UndefinedOr[t.Sequence[hikari.CommandChoice] | t.Mapping[str, str] | t.Sequence[tuple[str, str]] | t.Sequence[str]] = UNDEFINED, min_length: hikari.UndefinedOr[int] = UNDEFINED, max_length: hikari.UndefinedOr[int] = UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProviderT] = UNDEFINED) str | D [source]¶
A string option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.choices (
UndefinedOr
[ChoicesT
]) – The choices for the option. Any of the following can be interpreted as a choice: a sequence ofCommandChoice
, a mapping of choice name to choice value, a sequence of 2-tuples where the first element is the name and the second element is the value, or a sequence ofstr
where the choice name and value will be the same.min_length (
UndefinedOr
[int
]) – The minimum length for the option.max_length (
UndefinedOr
[int
]) – 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.
- lightbulb.commands.options.user(name: str, description: str, /, *, localize: bool = False, default: D | UndefinedType = UNDEFINED) User | D [source]¶
A user option.
- Parameters:
name (
str
) – The name of the option.description (
str
) – The description of the option.localize (
bool
) – Whether to localize this option’s name and description. Iftrue
, then thename
anddescription
arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults toFalse
.default (
UndefinedOr
[D
]) – The default value for the option.
- Returns:
Descriptor allowing access to the option value from within a command invocation.