diff options
| author | Rapptz <[email protected]> | 2021-05-28 09:43:15 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2021-05-28 09:43:15 -0400 |
| commit | f321efd4de26b7bf7eeeadcccba039478cc6672c (patch) | |
| tree | 02c53d866eb4f816ee338ff002218b2a9bea2bd5 | |
| parent | Allow constructing SelectOption.emoji from a string as well (diff) | |
| download | discord.py-f321efd4de26b7bf7eeeadcccba039478cc6672c.tar.xz discord.py-f321efd4de26b7bf7eeeadcccba039478cc6672c.zip | |
Default SelectOption.value to the label if not given
| -rw-r--r-- | discord/components.py | 9 | ||||
| -rw-r--r-- | discord/ui/select.py | 4 |
2 files changed, 7 insertions, 6 deletions
diff --git a/discord/components.py b/discord/components.py index 881f2c3f..b30c3ec3 100644 --- a/discord/components.py +++ b/discord/components.py @@ -26,7 +26,7 @@ from __future__ import annotations from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union from .enums import try_enum, ComponentType, ButtonStyle -from .utils import get_slots +from .utils import get_slots, MISSING from .partial_emoji import PartialEmoji if TYPE_CHECKING: @@ -264,7 +264,8 @@ class SelectOption: Can only be up to 25 characters. value: :class:`str` The value of the option. This is not displayed to users. - Can only be up to 100 characters. + If not provided when constructed then it defaults to the + label. Can only be up to 100 characters. description: Optional[:class:`str`] An additional description of the option, if any. Can only be up to 50 characters. @@ -286,13 +287,13 @@ class SelectOption: self, *, label: str, - value: str, + value: str = MISSING, description: Optional[str] = None, emoji: Optional[Union[str, PartialEmoji]] = None, default: bool = False, ) -> None: self.label = label - self.value = value + self.value = label if value is MISSING else value self.description = description if isinstance(emoji, str): diff --git a/discord/ui/select.py b/discord/ui/select.py index e6276ffb..cbbee3bc 100644 --- a/discord/ui/select.py +++ b/discord/ui/select.py @@ -158,7 +158,7 @@ class Select(Item[V]): self, *, label: str, - value: str, + value: str = MISSING, description: Optional[str] = None, emoji: Optional[Union[str, PartialEmoji]] = None, default: bool = False, @@ -175,7 +175,7 @@ class Select(Item[V]): Can only be up to 25 characters. value: :class:`str` The value of the option. This is not displayed to users. - Can only be up to 100 characters. + If not given, defaults to the label. Can only be up to 100 characters. description: Optional[:class:`str`] An additional description of the option, if any. Can only be up to 50 characters. |