We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
PartialEmoji.from_str incorrectly assumes emojis starting with `a` but not including `:` are animated
### Summary

PartialEmoji.from_str incorrectly assumes emojis starting with `a` but not including `:` are animated

### Reproduction Steps

- Create an emoji that starts with `a` such as `anemoji`
- Save the emoji information as `emoji_name:emoji_id`, a listed valid representation for `PartialEmoji.from_str`.
- Call `PartialEmoji.from_str("anemoji:12345678910111213")`
- The returned PartialEmoji assumes that the emoji is animated when it isn't.

### Minimal Reproducible Code

```python
>>> my_emoji = PartialEmoji.from_str("anemoji:12345678910111213")
>>> print(repr(my_emoji))
>>> <PartialEmoji animated=True name='nemoji' id=12345678910111213>
```


### Expected Results

I expected following a valid format for `PartialEmoji.from_str` to return a valid representation of the emoji.

### Actual Results

Emojis with names starting with `a` are incorrectly assumed to be animated despite missing the animated separator.

### Intents

all

### System Information

- Python v3.11.4-final
- discord.py v2.3.0-final
- aiohttp v3.8.4
- system info: Linux 5.15.90.2-microsoft-standard-WSL2 SMP Fri Jun 2 00:45:15 UTC 2023

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `discord/partial_emoji.py`
Content:
```
1 """
2 The MIT License (MIT)
3 
4 Copyright (c) 2015-present Rapptz
5 
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 """
24 
25 from __future__ import annotations
26 
27 from typing import Any, Dict, Optional, TYPE_CHECKING, Union
28 import re
29 
30 from .asset import Asset, AssetMixin
31 from . import utils
32 
33 # fmt: off
34 __all__ = (
35     'PartialEmoji',
36 )
37 # fmt: on
38 
39 if TYPE_CHECKING:
40     from typing_extensions import Self
41 
42     from .state import ConnectionState
43     from datetime import datetime
44     from .types.emoji import Emoji as EmojiPayload, PartialEmoji as PartialEmojiPayload
45     from .types.activity import ActivityEmoji
46 
47 
48 class _EmojiTag:
49     __slots__ = ()
50 
51     id: int
52 
53     def _to_partial(self) -> PartialEmoji:
54         raise NotImplementedError
55 
56 
57 class PartialEmoji(_EmojiTag, AssetMixin):
58     """Represents a "partial" emoji.
59 
60     This model will be given in two scenarios:
61 
62     - "Raw" data events such as :func:`on_raw_reaction_add`
63     - Custom emoji that the bot cannot see from e.g. :attr:`Message.reactions`
64 
65     .. container:: operations
66 
67         .. describe:: x == y
68 
69             Checks if two emoji are the same.
70 
71         .. describe:: x != y
72 
73             Checks if two emoji are not the same.
74 
75         .. describe:: hash(x)
76 
77             Return the emoji's hash.
78 
79         .. describe:: str(x)
80 
81             Returns the emoji rendered for discord.
82 
83     Attributes
84     -----------
85     name: Optional[:class:`str`]
86         The custom emoji name, if applicable, or the unicode codepoint
87         of the non-custom emoji. This can be ``None`` if the emoji
88         got deleted (e.g. removing a reaction with a deleted emoji).
89     animated: :class:`bool`
90         Whether the emoji is animated or not.
91     id: Optional[:class:`int`]
92         The ID of the custom emoji, if applicable.
93     """
94 
95     __slots__ = ('animated', 'name', 'id', '_state')
96 
97     _CUSTOM_EMOJI_RE = re.compile(r'<?(?P<animated>a)?:?(?P<name>[A-Za-z0-9\_]+):(?P<id>[0-9]{13,20})>?')
98 
99     if TYPE_CHECKING:
100         id: Optional[int]
101 
102     def __init__(self, *, name: str, animated: bool = False, id: Optional[int] = None):
103         self.animated: bool = animated
104         self.name: str = name
105         self.id: Optional[int] = id
106         self._state: Optional[ConnectionState] = None
107 
108     @classmethod
109     def from_dict(cls, data: Union[PartialEmojiPayload, ActivityEmoji, Dict[str, Any]]) -> Self:
110         return cls(
111             animated=data.get('animated', False),
112             id=utils._get_as_snowflake(data, 'id'),
113             name=data.get('name') or '',
114         )
115 
116     @classmethod
117     def from_str(cls, value: str) -> Self:
118         """Converts a Discord string representation of an emoji to a :class:`PartialEmoji`.
119 
120         The formats accepted are:
121 
122         - ``a:name:id``
123         - ``<a:name:id>``
124         - ``name:id``
125         - ``<:name:id>``
126 
127         If the format does not match then it is assumed to be a unicode emoji.
128 
129         .. versionadded:: 2.0
130 
131         Parameters
132         ------------
133         value: :class:`str`
134             The string representation of an emoji.
135 
136         Returns
137         --------
138         :class:`PartialEmoji`
139             The partial emoji from this string.
140         """
141         match = cls._CUSTOM_EMOJI_RE.match(value)
142         if match is not None:
143             groups = match.groupdict()
144             animated = bool(groups['animated'])
145             emoji_id = int(groups['id'])
146             name = groups['name']
147             return cls(name=name, animated=animated, id=emoji_id)
148 
149         return cls(name=value, id=None, animated=False)
150 
151     def to_dict(self) -> EmojiPayload:
152         payload: EmojiPayload = {
153             'id': self.id,
154             'name': self.name,
155         }
156 
157         if self.animated:
158             payload['animated'] = self.animated
159 
160         return payload
161 
162     def _to_partial(self) -> PartialEmoji:
163         return self
164 
165     def _to_forum_tag_payload(self) -> Dict[str, Any]:
166         if self.id is not None:
167             return {'emoji_id': self.id, 'emoji_name': None}
168         return {'emoji_id': None, 'emoji_name': self.name}
169 
170     @classmethod
171     def with_state(
172         cls,
173         state: ConnectionState,
174         *,
175         name: str,
176         animated: bool = False,
177         id: Optional[int] = None,
178     ) -> Self:
179         self = cls(name=name, animated=animated, id=id)
180         self._state = state
181         return self
182 
183     def __str__(self) -> str:
184         # Coerce empty names to _ so it renders in the client regardless of having no name
185         name = self.name or '_'
186         if self.id is None:
187             return name
188         if self.animated:
189             return f'<a:{name}:{self.id}>'
190         return f'<:{name}:{self.id}>'
191 
192     def __repr__(self) -> str:
193         return f'<{self.__class__.__name__} animated={self.animated} name={self.name!r} id={self.id}>'
194 
195     def __eq__(self, other: object) -> bool:
196         if self.is_unicode_emoji():
197             return isinstance(other, PartialEmoji) and self.name == other.name
198 
199         if isinstance(other, _EmojiTag):
200             return self.id == other.id
201         return False
202 
203     def __ne__(self, other: object) -> bool:
204         return not self.__eq__(other)
205 
206     def __hash__(self) -> int:
207         return hash((self.id, self.name))
208 
209     def is_custom_emoji(self) -> bool:
210         """:class:`bool`: Checks if this is a custom non-Unicode emoji."""
211         return self.id is not None
212 
213     def is_unicode_emoji(self) -> bool:
214         """:class:`bool`: Checks if this is a Unicode emoji."""
215         return self.id is None
216 
217     def _as_reaction(self) -> str:
218         if self.id is None:
219             return self.name
220         return f'{self.name}:{self.id}'
221 
222     @property
223     def created_at(self) -> Optional[datetime]:
224         """Optional[:class:`datetime.datetime`]: Returns the emoji's creation time in UTC, or None if Unicode emoji.
225 
226         .. versionadded:: 1.6
227         """
228         if self.id is None:
229             return None
230 
231         return utils.snowflake_time(self.id)
232 
233     @property
234     def url(self) -> str:
235         """:class:`str`: Returns the URL of the emoji, if it is custom.
236 
237         If this isn't a custom emoji then an empty string is returned
238         """
239         if self.is_unicode_emoji():
240             return ''
241 
242         fmt = 'gif' if self.animated else 'png'
243         return f'{Asset.BASE}/emojis/{self.id}.{fmt}'
244 
245     async def read(self) -> bytes:
246         """|coro|
247 
248         Retrieves the content of this asset as a :class:`bytes` object.
249 
250         Raises
251         ------
252         DiscordException
253             There was no internal connection state.
254         HTTPException
255             Downloading the asset failed.
256         NotFound
257             The asset was deleted.
258         ValueError
259             The PartialEmoji is not a custom emoji.
260 
261         Returns
262         -------
263         :class:`bytes`
264             The content of the asset.
265         """
266         if self.is_unicode_emoji():
267             raise ValueError('PartialEmoji is not a custom emoji')
268 
269         return await super().read()
270
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/discord/partial_emoji.py b/discord/partial_emoji.py
--- a/discord/partial_emoji.py
+++ b/discord/partial_emoji.py
@@ -94,7 +94,7 @@
 
     __slots__ = ('animated', 'name', 'id', '_state')
 
-    _CUSTOM_EMOJI_RE = re.compile(r'<?(?P<animated>a)?:?(?P<name>[A-Za-z0-9\_]+):(?P<id>[0-9]{13,20})>?')
+    _CUSTOM_EMOJI_RE = re.compile(r'<?(?:(?P<animated>a)?:)?(?P<name>[A-Za-z0-9\_]+):(?P<id>[0-9]{13,20})>?')
 
     if TYPE_CHECKING:
         id: Optional[int]

{"golden_diff": "diff --git a/discord/partial_emoji.py b/discord/partial_emoji.py\n--- a/discord/partial_emoji.py\n+++ b/discord/partial_emoji.py\n@@ -94,7 +94,7 @@\n \n     __slots__ = ('animated', 'name', 'id', '_state')\n \n-    _CUSTOM_EMOJI_RE = re.compile(r'<?(?P<animated>a)?:?(?P<name>[A-Za-z0-9\\_]+):(?P<id>[0-9]{13,20})>?')\n+    _CUSTOM_EMOJI_RE = re.compile(r'<?(?:(?P<animated>a)?:)?(?P<name>[A-Za-z0-9\\_]+):(?P<id>[0-9]{13,20})>?')\n \n     if TYPE_CHECKING:\n         id: Optional[int]\n", "issue": "PartialEmoji.from_str incorrectly assumes emojis starting with `a` but not including `:` are animated\n### Summary\r\n\r\nPartialEmoji.from_str incorrectly assumes emojis starting with `a` but not including `:` are animated\r\n\r\n### Reproduction Steps\r\n\r\n- Create an emoji that starts with `a` such as `anemoji`\r\n- Save the emoji information as `emoji_name:emoji_id`, a listed valid representation for `PartialEmoji.from_str`.\r\n- Call `PartialEmoji.from_str(\"anemoji:12345678910111213\")`\r\n- The returned PartialEmoji assumes that the emoji is animated when it isn't.\r\n\r\n### Minimal Reproducible Code\r\n\r\n```python\r\n>>> my_emoji = PartialEmoji.from_str(\"anemoji:12345678910111213\")\r\n>>> print(repr(my_emoji))\r\n>>> <PartialEmoji animated=True name='nemoji' id=12345678910111213>\r\n```\r\n\r\n\r\n### Expected Results\r\n\r\nI expected following a valid format for `PartialEmoji.from_str` to return a valid representation of the emoji.\r\n\r\n### Actual Results\r\n\r\nEmojis with names starting with `a` are incorrectly assumed to be animated despite missing the animated separator.\r\n\r\n### Intents\r\n\r\nall\r\n\r\n### System Information\r\n\r\n- Python v3.11.4-final\r\n- discord.py v2.3.0-final\r\n- aiohttp v3.8.4\r\n- system info: Linux 5.15.90.2-microsoft-standard-WSL2 SMP Fri Jun 2 00:45:15 UTC 2023\r\n\r\n### Checklist\r\n\r\n- [X] I have searched the open issues for duplicates.\r\n- [X] I have shown the entire traceback, if possible.\r\n- [X] I have removed my token from display, if visible.\r\n\r\n### Additional Context\r\n\r\n_No response_\n", "before_files": [{"content": "\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing import Any, Dict, Optional, TYPE_CHECKING, Union\nimport re\n\nfrom .asset import Asset, AssetMixin\nfrom . import utils\n\n# fmt: off\n__all__ = (\n    'PartialEmoji',\n)\n# fmt: on\n\nif TYPE_CHECKING:\n    from typing_extensions import Self\n\n    from .state import ConnectionState\n    from datetime import datetime\n    from .types.emoji import Emoji as EmojiPayload, PartialEmoji as PartialEmojiPayload\n    from .types.activity import ActivityEmoji\n\n\nclass _EmojiTag:\n    __slots__ = ()\n\n    id: int\n\n    def _to_partial(self) -> PartialEmoji:\n        raise NotImplementedError\n\n\nclass PartialEmoji(_EmojiTag, AssetMixin):\n    \"\"\"Represents a \"partial\" emoji.\n\n    This model will be given in two scenarios:\n\n    - \"Raw\" data events such as :func:`on_raw_reaction_add`\n    - Custom emoji that the bot cannot see from e.g. :attr:`Message.reactions`\n\n    .. container:: operations\n\n        .. describe:: x == y\n\n            Checks if two emoji are the same.\n\n        .. describe:: x != y\n\n            Checks if two emoji are not the same.\n\n        .. describe:: hash(x)\n\n            Return the emoji's hash.\n\n        .. describe:: str(x)\n\n            Returns the emoji rendered for discord.\n\n    Attributes\n    -----------\n    name: Optional[:class:`str`]\n        The custom emoji name, if applicable, or the unicode codepoint\n        of the non-custom emoji. This can be ``None`` if the emoji\n        got deleted (e.g. removing a reaction with a deleted emoji).\n    animated: :class:`bool`\n        Whether the emoji is animated or not.\n    id: Optional[:class:`int`]\n        The ID of the custom emoji, if applicable.\n    \"\"\"\n\n    __slots__ = ('animated', 'name', 'id', '_state')\n\n    _CUSTOM_EMOJI_RE = re.compile(r'<?(?P<animated>a)?:?(?P<name>[A-Za-z0-9\\_]+):(?P<id>[0-9]{13,20})>?')\n\n    if TYPE_CHECKING:\n        id: Optional[int]\n\n    def __init__(self, *, name: str, animated: bool = False, id: Optional[int] = None):\n        self.animated: bool = animated\n        self.name: str = name\n        self.id: Optional[int] = id\n        self._state: Optional[ConnectionState] = None\n\n    @classmethod\n    def from_dict(cls, data: Union[PartialEmojiPayload, ActivityEmoji, Dict[str, Any]]) -> Self:\n        return cls(\n            animated=data.get('animated', False),\n            id=utils._get_as_snowflake(data, 'id'),\n            name=data.get('name') or '',\n        )\n\n    @classmethod\n    def from_str(cls, value: str) -> Self:\n        \"\"\"Converts a Discord string representation of an emoji to a :class:`PartialEmoji`.\n\n        The formats accepted are:\n\n        - ``a:name:id``\n        - ``<a:name:id>``\n        - ``name:id``\n        - ``<:name:id>``\n\n        If the format does not match then it is assumed to be a unicode emoji.\n\n        .. versionadded:: 2.0\n\n        Parameters\n        ------------\n        value: :class:`str`\n            The string representation of an emoji.\n\n        Returns\n        --------\n        :class:`PartialEmoji`\n            The partial emoji from this string.\n        \"\"\"\n        match = cls._CUSTOM_EMOJI_RE.match(value)\n        if match is not None:\n            groups = match.groupdict()\n            animated = bool(groups['animated'])\n            emoji_id = int(groups['id'])\n            name = groups['name']\n            return cls(name=name, animated=animated, id=emoji_id)\n\n        return cls(name=value, id=None, animated=False)\n\n    def to_dict(self) -> EmojiPayload:\n        payload: EmojiPayload = {\n            'id': self.id,\n            'name': self.name,\n        }\n\n        if self.animated:\n            payload['animated'] = self.animated\n\n        return payload\n\n    def _to_partial(self) -> PartialEmoji:\n        return self\n\n    def _to_forum_tag_payload(self) -> Dict[str, Any]:\n        if self.id is not None:\n            return {'emoji_id': self.id, 'emoji_name': None}\n        return {'emoji_id': None, 'emoji_name': self.name}\n\n    @classmethod\n    def with_state(\n        cls,\n        state: ConnectionState,\n        *,\n        name: str,\n        animated: bool = False,\n        id: Optional[int] = None,\n    ) -> Self:\n        self = cls(name=name, animated=animated, id=id)\n        self._state = state\n        return self\n\n    def __str__(self) -> str:\n        # Coerce empty names to _ so it renders in the client regardless of having no name\n        name = self.name or '_'\n        if self.id is None:\n            return name\n        if self.animated:\n            return f'<a:{name}:{self.id}>'\n        return f'<:{name}:{self.id}>'\n\n    def __repr__(self) -> str:\n        return f'<{self.__class__.__name__} animated={self.animated} name={self.name!r} id={self.id}>'\n\n    def __eq__(self, other: object) -> bool:\n        if self.is_unicode_emoji():\n            return isinstance(other, PartialEmoji) and self.name == other.name\n\n        if isinstance(other, _EmojiTag):\n            return self.id == other.id\n        return False\n\n    def __ne__(self, other: object) -> bool:\n        return not self.__eq__(other)\n\n    def __hash__(self) -> int:\n        return hash((self.id, self.name))\n\n    def is_custom_emoji(self) -> bool:\n        \"\"\":class:`bool`: Checks if this is a custom non-Unicode emoji.\"\"\"\n        return self.id is not None\n\n    def is_unicode_emoji(self) -> bool:\n        \"\"\":class:`bool`: Checks if this is a Unicode emoji.\"\"\"\n        return self.id is None\n\n    def _as_reaction(self) -> str:\n        if self.id is None:\n            return self.name\n        return f'{self.name}:{self.id}'\n\n    @property\n    def created_at(self) -> Optional[datetime]:\n        \"\"\"Optional[:class:`datetime.datetime`]: Returns the emoji's creation time in UTC, or None if Unicode emoji.\n\n        .. versionadded:: 1.6\n        \"\"\"\n        if self.id is None:\n            return None\n\n        return utils.snowflake_time(self.id)\n\n    @property\n    def url(self) -> str:\n        \"\"\":class:`str`: Returns the URL of the emoji, if it is custom.\n\n        If this isn't a custom emoji then an empty string is returned\n        \"\"\"\n        if self.is_unicode_emoji():\n            return ''\n\n        fmt = 'gif' if self.animated else 'png'\n        return f'{Asset.BASE}/emojis/{self.id}.{fmt}'\n\n    async def read(self) -> bytes:\n        \"\"\"|coro|\n\n        Retrieves the content of this asset as a :class:`bytes` object.\n\n        Raises\n        ------\n        DiscordException\n            There was no internal connection state.\n        HTTPException\n            Downloading the asset failed.\n        NotFound\n            The asset was deleted.\n        ValueError\n            The PartialEmoji is not a custom emoji.\n\n        Returns\n        -------\n        :class:`bytes`\n            The content of the asset.\n        \"\"\"\n        if self.is_unicode_emoji():\n            raise ValueError('PartialEmoji is not a custom emoji')\n\n        return await super().read()\n", "path": "discord/partial_emoji.py"}], "after_files": [{"content": "\"\"\"\nThe MIT License (MIT)\n\nCopyright (c) 2015-present Rapptz\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing import Any, Dict, Optional, TYPE_CHECKING, Union\nimport re\n\nfrom .asset import Asset, AssetMixin\nfrom . import utils\n\n# fmt: off\n__all__ = (\n    'PartialEmoji',\n)\n# fmt: on\n\nif TYPE_CHECKING:\n    from typing_extensions import Self\n\n    from .state import ConnectionState\n    from datetime import datetime\n    from .types.emoji import Emoji as EmojiPayload, PartialEmoji as PartialEmojiPayload\n    from .types.activity import ActivityEmoji\n\n\nclass _EmojiTag:\n    __slots__ = ()\n\n    id: int\n\n    def _to_partial(self) -> PartialEmoji:\n        raise NotImplementedError\n\n\nclass PartialEmoji(_EmojiTag, AssetMixin):\n    \"\"\"Represents a \"partial\" emoji.\n\n    This model will be given in two scenarios:\n\n    - \"Raw\" data events such as :func:`on_raw_reaction_add`\n    - Custom emoji that the bot cannot see from e.g. :attr:`Message.reactions`\n\n    .. container:: operations\n\n        .. describe:: x == y\n\n            Checks if two emoji are the same.\n\n        .. describe:: x != y\n\n            Checks if two emoji are not the same.\n\n        .. describe:: hash(x)\n\n            Return the emoji's hash.\n\n        .. describe:: str(x)\n\n            Returns the emoji rendered for discord.\n\n    Attributes\n    -----------\n    name: Optional[:class:`str`]\n        The custom emoji name, if applicable, or the unicode codepoint\n        of the non-custom emoji. This can be ``None`` if the emoji\n        got deleted (e.g. removing a reaction with a deleted emoji).\n    animated: :class:`bool`\n        Whether the emoji is animated or not.\n    id: Optional[:class:`int`]\n        The ID of the custom emoji, if applicable.\n    \"\"\"\n\n    __slots__ = ('animated', 'name', 'id', '_state')\n\n    _CUSTOM_EMOJI_RE = re.compile(r'<?(?:(?P<animated>a)?:)?(?P<name>[A-Za-z0-9\\_]+):(?P<id>[0-9]{13,20})>?')\n\n    if TYPE_CHECKING:\n        id: Optional[int]\n\n    def __init__(self, *, name: str, animated: bool = False, id: Optional[int] = None):\n        self.animated: bool = animated\n        self.name: str = name\n        self.id: Optional[int] = id\n        self._state: Optional[ConnectionState] = None\n\n    @classmethod\n    def from_dict(cls, data: Union[PartialEmojiPayload, ActivityEmoji, Dict[str, Any]]) -> Self:\n        return cls(\n            animated=data.get('animated', False),\n            id=utils._get_as_snowflake(data, 'id'),\n            name=data.get('name') or '',\n        )\n\n    @classmethod\n    def from_str(cls, value: str) -> Self:\n        \"\"\"Converts a Discord string representation of an emoji to a :class:`PartialEmoji`.\n\n        The formats accepted are:\n\n        - ``a:name:id``\n        - ``<a:name:id>``\n        - ``name:id``\n        - ``<:name:id>``\n\n        If the format does not match then it is assumed to be a unicode emoji.\n\n        .. versionadded:: 2.0\n\n        Parameters\n        ------------\n        value: :class:`str`\n            The string representation of an emoji.\n\n        Returns\n        --------\n        :class:`PartialEmoji`\n            The partial emoji from this string.\n        \"\"\"\n        match = cls._CUSTOM_EMOJI_RE.match(value)\n        if match is not None:\n            groups = match.groupdict()\n            animated = bool(groups['animated'])\n            emoji_id = int(groups['id'])\n            name = groups['name']\n            return cls(name=name, animated=animated, id=emoji_id)\n\n        return cls(name=value, id=None, animated=False)\n\n    def to_dict(self) -> EmojiPayload:\n        payload: EmojiPayload = {\n            'id': self.id,\n            'name': self.name,\n        }\n\n        if self.animated:\n            payload['animated'] = self.animated\n\n        return payload\n\n    def _to_partial(self) -> PartialEmoji:\n        return self\n\n    def _to_forum_tag_payload(self) -> Dict[str, Any]:\n        if self.id is not None:\n            return {'emoji_id': self.id, 'emoji_name': None}\n        return {'emoji_id': None, 'emoji_name': self.name}\n\n    @classmethod\n    def with_state(\n        cls,\n        state: ConnectionState,\n        *,\n        name: str,\n        animated: bool = False,\n        id: Optional[int] = None,\n    ) -> Self:\n        self = cls(name=name, animated=animated, id=id)\n        self._state = state\n        return self\n\n    def __str__(self) -> str:\n        # Coerce empty names to _ so it renders in the client regardless of having no name\n        name = self.name or '_'\n        if self.id is None:\n            return name\n        if self.animated:\n            return f'<a:{name}:{self.id}>'\n        return f'<:{name}:{self.id}>'\n\n    def __repr__(self) -> str:\n        return f'<{self.__class__.__name__} animated={self.animated} name={self.name!r} id={self.id}>'\n\n    def __eq__(self, other: object) -> bool:\n        if self.is_unicode_emoji():\n            return isinstance(other, PartialEmoji) and self.name == other.name\n\n        if isinstance(other, _EmojiTag):\n            return self.id == other.id\n        return False\n\n    def __ne__(self, other: object) -> bool:\n        return not self.__eq__(other)\n\n    def __hash__(self) -> int:\n        return hash((self.id, self.name))\n\n    def is_custom_emoji(self) -> bool:\n        \"\"\":class:`bool`: Checks if this is a custom non-Unicode emoji.\"\"\"\n        return self.id is not None\n\n    def is_unicode_emoji(self) -> bool:\n        \"\"\":class:`bool`: Checks if this is a Unicode emoji.\"\"\"\n        return self.id is None\n\n    def _as_reaction(self) -> str:\n        if self.id is None:\n            return self.name\n        return f'{self.name}:{self.id}'\n\n    @property\n    def created_at(self) -> Optional[datetime]:\n        \"\"\"Optional[:class:`datetime.datetime`]: Returns the emoji's creation time in UTC, or None if Unicode emoji.\n\n        .. versionadded:: 1.6\n        \"\"\"\n        if self.id is None:\n            return None\n\n        return utils.snowflake_time(self.id)\n\n    @property\n    def url(self) -> str:\n        \"\"\":class:`str`: Returns the URL of the emoji, if it is custom.\n\n        If this isn't a custom emoji then an empty string is returned\n        \"\"\"\n        if self.is_unicode_emoji():\n            return ''\n\n        fmt = 'gif' if self.animated else 'png'\n        return f'{Asset.BASE}/emojis/{self.id}.{fmt}'\n\n    async def read(self) -> bytes:\n        \"\"\"|coro|\n\n        Retrieves the content of this asset as a :class:`bytes` object.\n\n        Raises\n        ------\n        DiscordException\n            There was no internal connection state.\n        HTTPException\n            Downloading the asset failed.\n        NotFound\n            The asset was deleted.\n        ValueError\n            The PartialEmoji is not a custom emoji.\n\n        Returns\n        -------\n        :class:`bytes`\n            The content of the asset.\n        \"\"\"\n        if self.is_unicode_emoji():\n            raise ValueError('PartialEmoji is not a custom emoji')\n\n        return await super().read()\n", "path": "discord/partial_emoji.py"}]}