Command Utilities API Reference

toolbox.commands.as_command_choices(choices: Sequence[Union[str, int, float]]) Sequence[hikari.commands.CommandChoice][source]
toolbox.commands.as_command_choices(choices: Sequence[Sequence[Union[str, int, float]]]) Sequence[hikari.commands.CommandChoice]
toolbox.commands.as_command_choices(choices: Dict[str, Union[str, int, float]]) Sequence[hikari.commands.CommandChoice]
toolbox.commands.as_command_choices(*args: Union[str, int, float]) Sequence[hikari.commands.CommandChoice]
toolbox.commands.as_command_choices(*args: Sequence[Union[str, int, float]]) Sequence[hikari.commands.CommandChoice]
toolbox.commands.as_command_choices(**kwargs: Union[str, int, float]) Sequence[hikari.commands.CommandChoice]

Convert the arguments to typing.Sequence[hikari.CommandChoice].

Parameters
  • choices (Sequence[Union[str, int, float]] or Sequence[Sequence[Union[str, int, float]]] or dict[str, Union[str, int, float]]) –

    A sequence or dict to use to generate the typing.Sequence[hikari.CommandChoice].

    # Returns `(CommandChoice(name='a', value='a'), CommandChoice(name='b', value='b'), CommandChoice(name='c', value='c'))`
    toolbox.as_command_choices(["a", "b", "c"])
    
    # Returns `(CommandChoice(name='a', value='e'), CommandChoice(name='b', value='f'), CommandChoice(name='c', value='g'))`
    toolbox.as_command_choices({"a": "e", "b": "f", "c": "g"})
    toolbox.as_command_choices([["a", "d"], ["b", "e"], ["c", "f"]])
    

  • *args (Union[str, int, float] or Sequence[Union[str, int, float]], optional) –

    The parameters to make the typing.Sequence[CommandChoice] with with.

    *args can be provided in any of the following ways:

    # Returns `(CommandChoice(name='a', value='a'), CommandChoice(name='b', value='b'), CommandChoice(name='c', value='c'))`
    toolbox.as_command_choices("a", "b", "c")
    
    # Returns `(CommandChoice(name='a', value='e'), CommandChoice(name='b', value='f'), CommandChoice(name='c', value='g'))`
    toolbox.as_command_choices(["a", "e"], ["b", "f"], ["c", "g"])
    

  • **kwargs (str, optional) –

    If provided, use kwargs as the (name, value) for each hikari.Commandchoice.

    # Returns `(CommandChoice(name='a', value='e'), CommandChoice(name='b', value='f'), CommandChoice(name='c', value='g'))`
    toolbox.as_command_choices(a="e", b="f", c="g")
    

Returns

The generated hikari.CommandChoice objects.

Return type

Sequence[hikari.CommandChoice]