conditional
Function
Picks an autocomplete depending on the context.
from discord_interactions.slash import conditionalSignature
def conditional( condition: Callable[[AutocompleteContext], bool], if_true: Callable[..., Awaitable[List[Tuple[str, Any]]]], if_false: Callable[..., Awaitable[List[Tuple[str, Any]]]],) -> Callable[..., Awaitable[List[Tuple[str, Any]]]]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
condition | Callable[[AutocompleteContext], bool] | required | |
if_true | Callable[..., Awaitable[List[Tuple[str, Any]]]] | required | |
if_false | Callable[..., Awaitable[List[Tuple[str, Any]]]] | required |
Returns
Callable[..., Awaitable[List[Tuple[str, Any]]]]
Details
Example:
@slash.command()@autocomplete("channel", conditional( lambda ctx: ctx.options.get("type") == "voice", voice_channels_handler, text_channels_handler,))async def select_channel(ctx, type: str, channel: str): ...