lightbulb.commands.options

class Choice(name: 'str', value: 'T', localize: 'bool' = False)[source]
localize: bool

Whether the name of the choice should be interpreted as a localization key.

name: str

The name of the choice.

value: T

The value of the choice.

class Option(data: OptionData[DefaultT, ConvertedT], default_when_not_bound: DefaultT)[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[DefaultT] = 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, converter: t.Callable[[Context, t.Any], ConvertedT] | None = None)[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: bool

Whether autocomplete is enabled for the option.

autocomplete_provider: hikari.UndefinedOr[AutocompleteProvider[t.Any]]

The provider to use to resolve autocomplete interactions for this option.

channel_types: hikari.UndefinedOr[Sequence[ChannelType]]

The channel types for the option.

choices: hikari.UndefinedOr[Sequence[Choice[t.Any]]]

The choices for the option.

converter: t.Callable[[Context, t.Any], ConvertedT] | None

The converter to use for this option.

Added in version 3.1.0.

default: hikari.UndefinedOr[DefaultT]

The default value for the option.

description: str

The description of the option.

localize: bool

Whether the name and description of the option should be interpreted as localization keys.

max_length: hikari.UndefinedOr[int]

The maximum length for the option.

max_value: hikari.UndefinedOr[int | float]

The maximum value for the option.

min_length: hikari.UndefinedOr[int]

The minimum length for the option.

min_value: hikari.UndefinedOr[int | float]

The minimum value for the option.

name: str

The name of the option.

type: OptionType

The type of the option.

attachment(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) Attachment | DefaultT[source]
attachment(name: str, description: str, /, *, converter: t.Callable[[Context, Attachment], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) DefaultT | ConvertedT

An attachment option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • default – The default value for the option.

Returns:

Descriptor allowing access to the option value from within a command invocation.

Added in version 3.1.0: The converter argument.

boolean(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) bool | DefaultT[source]
boolean(name: str, description: str, /, *, converter: t.Callable[[Context, bool], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) DefaultT | ConvertedT

A boolean option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • default – The default value for the option.

Returns:

Descriptor allowing access to the option value from within a command invocation.

Added in version 3.1.0: The converter argument.

channel(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, channel_types: hikari.UndefinedOr[Sequence[ChannelType]] = hikari.UNDEFINED) PartialChannel | DefaultT[source]
channel(name: str, description: str, /, *, converter: t.Callable[[Context, PartialChannel], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, channel_types: hikari.UndefinedOr[Sequence[ChannelType]] = hikari.UNDEFINED) DefaultT | ConvertedT

A channel option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • 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.

Added in version 3.1.0: The converter argument.

integer(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[int]]] = hikari.UNDEFINED, min_value: int | UndefinedType = hikari.UNDEFINED, max_value: int | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[int]] = hikari.UNDEFINED) int | DefaultT[source]
integer(name: str, description: str, /, *, converter: t.Callable[[Context, int], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[int]]] = hikari.UNDEFINED, min_value: int | UndefinedType = hikari.UNDEFINED, max_value: int | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[int]] = hikari.UNDEFINED) DefaultT | ConvertedT

An integer option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • 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.

Added in version 3.1.0: The converter argument.

mentionable(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) Snowflake | DefaultT[source]
mentionable(name: str, description: str, /, *, converter: t.Callable[[Context, Snowflake], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) DefaultT | ConvertedT

A mentionable (snowflake) option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • default – The default value for the option.

Returns:

Descriptor allowing access to the option value from within a command invocation.

Added in version 3.1.0: The converter argument.

number(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[float]]] = hikari.UNDEFINED, min_value: float | UndefinedType = hikari.UNDEFINED, max_value: float | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[float]] = hikari.UNDEFINED) float | DefaultT[source]
number(name: str, description: str, /, *, converter: t.Callable[[Context, float], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[float]]] = hikari.UNDEFINED, min_value: float | UndefinedType = hikari.UNDEFINED, max_value: float | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[float]] = hikari.UNDEFINED) DefaultT | ConvertedT

A numeric (float) option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • 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.

Added in version 3.1.0: The converter argument.

role(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) Role | DefaultT[source]
role(name: str, description: str, /, *, converter: t.Callable[[Context, Role], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) DefaultT | ConvertedT

A role option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • default – The default value for the option.

Returns:

Descriptor allowing access to the option value from within a command invocation.

Added in version 3.1.0: The converter argument.

string(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[str]]] = hikari.UNDEFINED, min_length: int | UndefinedType = hikari.UNDEFINED, max_length: int | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[str]] = hikari.UNDEFINED) str | DefaultT[source]
string(name: str, description: str, /, *, converter: t.Callable[[Context, str], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED, choices: hikari.UndefinedOr[Sequence[Choice[str]]] = hikari.UNDEFINED, min_length: int | UndefinedType = hikari.UNDEFINED, max_length: int | UndefinedType = hikari.UNDEFINED, autocomplete: hikari.UndefinedOr[AutocompleteProvider[str]] = hikari.UNDEFINED) DefaultT | ConvertedT

A string option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • 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.

Added in version 3.1.0: The converter argument.

user(name: str, description: str, /, *, localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) User | DefaultT[source]
user(name: str, description: str, /, *, converter: t.Callable[[Context, User], types.MaybeAwaitable[ConvertedT]], localize: bool = False, default: DefaultT | UndefinedType = hikari.UNDEFINED) DefaultT | ConvertedT

A user option.

Parameters:
  • name – The name of the option.

  • description – The description of the option.

  • converter – The converter to be used to convert the value to a custom type.

  • localize – Whether to localize this option’s name and description. If True, then the name and description arguments will instead be interpreted as localization keys from which the actual name and description will be retrieved. Defaults to False.

  • default – The default value for the option.

Returns:

Descriptor allowing access to the option value from within a command invocation.

Added in version 3.1.0: The converter argument.