From b84c199c70be18d0c3dc7877c8496efc09a3ce8c Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 28 May 2021 09:40:49 -0400 Subject: [PATCH] Allow constructing SelectOption.emoji from a string as well --- discord/components.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/discord/components.py b/discord/components.py index 7e89f8ffc..881f2c3f4 100644 --- a/discord/components.py +++ b/discord/components.py @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. 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 .utils import get_slots from .partial_emoji import PartialEmoji @@ -288,12 +288,16 @@ class SelectOption: label: str, value: str, description: Optional[str] = None, - emoji: Optional[PartialEmoji] = None, + emoji: Optional[Union[str, PartialEmoji]] = None, default: bool = False, ) -> None: self.label = label self.value = value self.description = description + + if isinstance(emoji, str): + emoji = PartialEmoji.from_str(emoji) + self.emoji = emoji self.default = default