Browse Source

Allow constructing SelectOption.emoji from a string as well

pull/6985/head
Rapptz 4 years ago
parent
commit
b84c199c70
  1. 8
      discord/components.py

8
discord/components.py

@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE.
from __future__ import annotations from __future__ import annotations
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar 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
from .partial_emoji import PartialEmoji from .partial_emoji import PartialEmoji
@ -288,12 +288,16 @@ class SelectOption:
label: str, label: str,
value: str, value: str,
description: Optional[str] = None, description: Optional[str] = None,
emoji: Optional[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 = value
self.description = description self.description = description
if isinstance(emoji, str):
emoji = PartialEmoji.from_str(emoji)
self.emoji = emoji self.emoji = emoji
self.default = default self.default = default

Loading…
Cancel
Save