discord-interactions.py

create_select_menu

Function

Text select menu (25 options max). Options accept dicts, tuples or strings.

from discord_interactions import create_select_menu

Signature

def create_select_menu(    custom_id: str,    placeholder: str | None = 'Select an option',    options: Sequence[Any] | None = None,    min_values: int | None = 1,    max_values: int | None = 1,    disabled: bool = False,    required: bool | None = None,    component_id: int | None = None,) -> Dict[str, Any]

Parameters

NameTypeDefaultDescription
custom_idstrrequiredIdentifier sent back with the selected values.
placeholderstr | None'Select an option'Text shown while nothing is selected.
optionsSequence[Any] | NoneNoneOptions: select_option(...), dicts, tuples (label, value, description, emoji, default) or strings.
min_valuesint | None1Minimum number of choices (0 to 25).
max_valuesint | None1Maximum number of choices (1 to 25).
disabledboolFalseGreyed out menu (messages only).
requiredbool | NoneNoneChoice required (modals only).
component_idint | NoneNone

Returns

Dict[str, Any]

Example

from discord_interactions import create_action_row, create_select_menu, select_option menu = create_select_menu(    "langage",    placeholder="Ton langage",    options=[        select_option("Python", "py", emoji="🐍"),        select_option("Rust", "rs", emoji="🦀"),        "JavaScript",    ],)await ctx.respond(components=[create_action_row(menu)])

Type a name: create_button, ModalBuilder, cooldown.