Select
Represents a UI select menu.Constructor
The type of select to create. Must be one of:
string_select, user_select, role_select, mentionable_select, or channel_select.The ID of the select menu. Auto-generated if not provided.
The placeholder text shown if nothing is selected. Maximum of 150 characters.
The minimum number of items that must be chosen. Must be between 0 and 25.
The maximum number of items that can be chosen. Must be between 1 and 25.
A list of options that can be selected. Only valid for
string_select.A list of channel types that can be selected. Only valid for
channel_select.Whether the select is disabled or not.
The relative row this select menu belongs to (0-4).
The select menu’s ID.
Whether the select is required or not. Only applicable in modals.
The default values of this select. Only applicable for non-string selects.
Attributes
The ID of the select menu.
The placeholder text that is shown if nothing is selected.
The minimum number of items that must be chosen.
The maximum number of items that can be chosen.
Whether the select is disabled or not.
Whether the select is required or not.
A list of options that can be selected. Only for string selects.
A list of channel types that can be selected. Only for channel selects.
A list of the select’s default values.
A list of values that have been selected by the user.
None if not yet interacted with.The width of the select menu in the UI layout. Always 5.
The row position of this select menu (0-4).
Methods
add_option
add_option
Adds an option to the select menu (string selects only).Parameters:
label(str): The label of the option (max 100 chars).value(str): The value of the option (max 100 chars). Defaults to label.description(str | None): An additional description (max 100 chars).emoji(str | PartialEmoji | None): The emoji of the option.default(bool): Whether this option is selected by default.
ValueError: The number of options exceeds 25.
append_option
append_option
Appends a pre-existing SelectOption to the select menu.Parameters:
option(SelectOption): The option to append.
ValueError: The number of options exceeds 25.
add_default_value
add_default_value
Adds a default value to the select menu.Parameters:
id(int): The ID of the entity to add as a default.type(SelectDefaultValueType): The default value type. Required for mentionable selects.
TypeError: Invalid type or select type is string_select.ValueError: Number of default values exceeds 25.
append_default_value
append_default_value
Appends a default value to this select menu.Parameters:
value(SelectDefaultValue | Snowflake): The default value to append.
TypeError: The select type is string_select.ValueError: Number of default values exceeds 25.
callback
callback
The callback associated with this select menu. Override in subclasses or use the decorator.Parameters:
interaction(Interaction): The interaction that triggered this select.
Select Type Aliases
Convenience aliases for creating specific types of selects:- StringSelect
- UserSelect
- RoleSelect
- ChannelSelect
- MentionableSelect
An alias for
Select with select_type=ComponentType.string_select.Select Decorators
Decorators for attaching select menus to views:@select
Convenience Decorators
@string_select()- String select@user_select()- User select@role_select()- Role select@channel_select()- Channel select@mentionable_select()- Mentionable select
