2525
2626from __future__ import annotations
2727
28+ import importlib .resources
29+ import json
2830import re
2931from typing import TYPE_CHECKING , Any , TypedDict , TypeVar
3032
3133from . import utils
3234from .asset import Asset , AssetMixin
3335from .errors import InvalidArgument
3436
37+ with (
38+ importlib .resources .files (__package__ )
39+ .joinpath ("emojis.json" )
40+ .open (encoding = "utf-8" ) as f
41+ ):
42+ EMOJIS_MAP = json .load (f )
43+
3544__all__ = ("PartialEmoji" ,)
3645
3746if TYPE_CHECKING :
@@ -127,7 +136,7 @@ def from_str(cls: type[PE], value: str) -> PE:
127136 - ``name:id``
128137 - ``<:name:id>``
129138
130- If the format does not match then it is assumed to be a unicode emoji.
139+ If the format does not match then it is assumed to be a unicode emoji, either as Unicode characters or as a Discord alias (``:smile:``) .
131140
132141 .. versionadded:: 2.0
133142
@@ -141,6 +150,12 @@ def from_str(cls: type[PE], value: str) -> PE:
141150 :class:`PartialEmoji`
142151 The partial emoji from this string.
143152 """
153+ if value .startswith (":" ) and value .endswith (":" ):
154+ name = value [1 :- 1 ]
155+ unicode_emoji = EMOJIS_MAP .get (name )
156+ if unicode_emoji :
157+ return cls (name = unicode_emoji , id = None , animated = False )
158+
144159 match = cls ._CUSTOM_EMOJI_RE .match (value )
145160 if match is not None :
146161 groups = match .groupdict ()
0 commit comments