Allow passing Emoji in components

This commit is contained in:
Rapptz
2021-06-02 05:28:07 -04:00
parent be5f4ae4ab
commit 47f2d04940
5 changed files with 43 additions and 21 deletions

View File

@ -30,6 +30,7 @@ import os
from .item import Item, ItemCallbackType
from ..enums import ComponentType
from ..partial_emoji import PartialEmoji
from ..emoji import Emoji
from ..interactions import Interaction
from ..utils import MISSING
from ..components import (
@ -176,7 +177,7 @@ class Select(Item[V]):
label: str,
value: str = MISSING,
description: Optional[str] = None,
emoji: Optional[Union[str, PartialEmoji]] = None,
emoji: Optional[Union[str, Emoji, PartialEmoji]] = None,
default: bool = False,
):
"""Adds an option to the select menu.
@ -195,9 +196,9 @@ class Select(Item[V]):
description: Optional[:class:`str`]
An additional description of the option, if any.
Can only be up to 50 characters.
emoji: Optional[Union[:class:`str`, :class:`PartialEmoji`]]
emoji: Optional[Union[:class:`str`, :class:`Emoji`, :class:`PartialEmoji`]]
The emoji of the option, if available. This can either be a string representing
the custom or unicode emoji or an instance of :class:`PartialEmoji`.
the custom or unicode emoji or an instance of :class:`PartialEmoji` or :class:`Emoji`.
default: :class:`bool`
Whether this option is selected by default.
@ -207,9 +208,6 @@ class Select(Item[V]):
The number of options exceeds 25.
"""
if isinstance(emoji, str):
emoji = PartialEmoji.from_str(emoji)
option = SelectOption(
label=label,
value=value,