|
@ -75,6 +75,12 @@ class Select(Item[V]): |
|
|
Defaults to 1 and must be between 1 and 25. |
|
|
Defaults to 1 and must be between 1 and 25. |
|
|
options: List[:class:`discord.SelectOption`] |
|
|
options: List[:class:`discord.SelectOption`] |
|
|
A list of options that can be selected in this menu. |
|
|
A list of options that can be selected in this menu. |
|
|
|
|
|
row: Optional[:class:`int`] |
|
|
|
|
|
The relative row this select menu belongs to. A Discord component can only have 5 |
|
|
|
|
|
rows. By default, items are arranged automatically into those 5 rows. If you'd |
|
|
|
|
|
like to control the relative positioning of the row then passing an index is advised. |
|
|
|
|
|
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic |
|
|
|
|
|
ordering. The row number cannot be negative or greater than 5. |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
__item_repr_attributes__: Tuple[str, ...] = ( |
|
|
__item_repr_attributes__: Tuple[str, ...] = ( |
|
@ -92,7 +98,7 @@ class Select(Item[V]): |
|
|
min_values: int = 1, |
|
|
min_values: int = 1, |
|
|
max_values: int = 1, |
|
|
max_values: int = 1, |
|
|
options: List[SelectOption] = MISSING, |
|
|
options: List[SelectOption] = MISSING, |
|
|
group: Optional[int] = None, |
|
|
row: Optional[int] = None, |
|
|
) -> None: |
|
|
) -> None: |
|
|
self._selected_values: List[str] = [] |
|
|
self._selected_values: List[str] = [] |
|
|
custom_id = os.urandom(16).hex() if custom_id is MISSING else custom_id |
|
|
custom_id = os.urandom(16).hex() if custom_id is MISSING else custom_id |
|
@ -105,7 +111,7 @@ class Select(Item[V]): |
|
|
max_values=max_values, |
|
|
max_values=max_values, |
|
|
options=options, |
|
|
options=options, |
|
|
) |
|
|
) |
|
|
self.group_id = group |
|
|
self.row = row |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def custom_id(self) -> str: |
|
|
def custom_id(self) -> str: |
|
@ -229,6 +235,10 @@ class Select(Item[V]): |
|
|
"""List[:class:`str`]: A list of values that have been selected by the user.""" |
|
|
"""List[:class:`str`]: A list of values that have been selected by the user.""" |
|
|
return self._selected_values |
|
|
return self._selected_values |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
def width(self) -> int: |
|
|
|
|
|
return 5 |
|
|
|
|
|
|
|
|
def to_component_dict(self) -> SelectMenuPayload: |
|
|
def to_component_dict(self) -> SelectMenuPayload: |
|
|
return self._underlying.to_dict() |
|
|
return self._underlying.to_dict() |
|
|
|
|
|
|
|
@ -247,7 +257,7 @@ class Select(Item[V]): |
|
|
min_values=component.min_values, |
|
|
min_values=component.min_values, |
|
|
max_values=component.max_values, |
|
|
max_values=component.max_values, |
|
|
options=component.options, |
|
|
options=component.options, |
|
|
group=None, |
|
|
row=None, |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
@ -265,7 +275,7 @@ def select( |
|
|
min_values: int = 1, |
|
|
min_values: int = 1, |
|
|
max_values: int = 1, |
|
|
max_values: int = 1, |
|
|
options: List[SelectOption] = MISSING, |
|
|
options: List[SelectOption] = MISSING, |
|
|
group: Optional[int] = None, |
|
|
row: Optional[int] = None, |
|
|
) -> Callable[[ItemCallbackType], ItemCallbackType]: |
|
|
) -> Callable[[ItemCallbackType], ItemCallbackType]: |
|
|
"""A decorator that attaches a select menu to a component. |
|
|
"""A decorator that attaches a select menu to a component. |
|
|
|
|
|
|
|
@ -281,12 +291,12 @@ def select( |
|
|
custom_id: :class:`str` |
|
|
custom_id: :class:`str` |
|
|
The ID of the select menu that gets received during an interaction. |
|
|
The ID of the select menu that gets received during an interaction. |
|
|
It is recommended not to set this parameter to prevent conflicts. |
|
|
It is recommended not to set this parameter to prevent conflicts. |
|
|
group: Optional[:class:`int`] |
|
|
row: Optional[:class:`int`] |
|
|
The relative group this select menu belongs to. A Discord component can only have 5 |
|
|
The relative row this select menu belongs to. A Discord component can only have 5 |
|
|
groups. By default, items are arranged automatically into those 5 groups. If you'd |
|
|
rows. By default, items are arranged automatically into those 5 rows. If you'd |
|
|
like to control the relative positioning of the group then passing an index is advised. |
|
|
like to control the relative positioning of the row then passing an index is advised. |
|
|
For example, group=1 will show up before group=2. Defaults to ``None``, which is automatic |
|
|
For example, row=1 will show up before row=2. Defaults to ``None``, which is automatic |
|
|
ordering. |
|
|
ordering. The row number cannot be negative or greater than 5. |
|
|
min_values: :class:`int` |
|
|
min_values: :class:`int` |
|
|
The minimum number of items that must be chosen for this select menu. |
|
|
The minimum number of items that must be chosen for this select menu. |
|
|
Defaults to 1 and must be between 1 and 25. |
|
|
Defaults to 1 and must be between 1 and 25. |
|
@ -305,7 +315,7 @@ def select( |
|
|
func.__discord_ui_model_kwargs__ = { |
|
|
func.__discord_ui_model_kwargs__ = { |
|
|
'placeholder': placeholder, |
|
|
'placeholder': placeholder, |
|
|
'custom_id': custom_id, |
|
|
'custom_id': custom_id, |
|
|
'group': group, |
|
|
'row': row, |
|
|
'min_values': min_values, |
|
|
'min_values': min_values, |
|
|
'max_values': max_values, |
|
|
'max_values': max_values, |
|
|
'options': options, |
|
|
'options': options, |
|
|