Default SelectOption.value to the label if not given
This commit is contained in:
parent
b84c199c70
commit
f321efd4de
@ -26,7 +26,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union
|
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Union
|
||||||
from .enums import try_enum, ComponentType, ButtonStyle
|
from .enums import try_enum, ComponentType, ButtonStyle
|
||||||
from .utils import get_slots
|
from .utils import get_slots, MISSING
|
||||||
from .partial_emoji import PartialEmoji
|
from .partial_emoji import PartialEmoji
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -264,7 +264,8 @@ class SelectOption:
|
|||||||
Can only be up to 25 characters.
|
Can only be up to 25 characters.
|
||||||
value: :class:`str`
|
value: :class:`str`
|
||||||
The value of the option. This is not displayed to users.
|
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`]
|
description: Optional[:class:`str`]
|
||||||
An additional description of the option, if any.
|
An additional description of the option, if any.
|
||||||
Can only be up to 50 characters.
|
Can only be up to 50 characters.
|
||||||
@ -286,13 +287,13 @@ class SelectOption:
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
label: str,
|
label: str,
|
||||||
value: str,
|
value: str = MISSING,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
emoji: Optional[Union[str, PartialEmoji]] = None,
|
emoji: Optional[Union[str, PartialEmoji]] = None,
|
||||||
default: bool = False,
|
default: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.label = label
|
self.label = label
|
||||||
self.value = value
|
self.value = label if value is MISSING else value
|
||||||
self.description = description
|
self.description = description
|
||||||
|
|
||||||
if isinstance(emoji, str):
|
if isinstance(emoji, str):
|
||||||
|
@ -158,7 +158,7 @@ class Select(Item[V]):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
label: str,
|
label: str,
|
||||||
value: str,
|
value: str = MISSING,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
emoji: Optional[Union[str, PartialEmoji]] = None,
|
emoji: Optional[Union[str, PartialEmoji]] = None,
|
||||||
default: bool = False,
|
default: bool = False,
|
||||||
@ -175,7 +175,7 @@ class Select(Item[V]):
|
|||||||
Can only be up to 25 characters.
|
Can only be up to 25 characters.
|
||||||
value: :class:`str`
|
value: :class:`str`
|
||||||
The value of the option. This is not displayed to users.
|
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`]
|
description: Optional[:class:`str`]
|
||||||
An additional description of the option, if any.
|
An additional description of the option, if any.
|
||||||
Can only be up to 50 characters.
|
Can only be up to 50 characters.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user