Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1599e3b
handle emoji_lib
Lumabots May 2, 2025
a5527d9
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 2, 2025
2b52aae
Update CHANGELOG.md
Lumabots May 2, 2025
c707590
usage of dismoji
Lumabots May 3, 2025
8b78d9a
Update _.txt
Lumabots May 3, 2025
31d6b39
removal of dismoji
Lumabots May 4, 2025
6124ddf
Update _.txt
Lumabots May 4, 2025
7e7942f
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2025
203c92b
NEED HELP
Lumabots May 4, 2025
5b10a1e
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2025
7fca53d
Update partial_emoji.py
Lumabots May 5, 2025
cda00b4
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 5, 2025
8e6f01c
Add files via upload
Lumabots May 5, 2025
7ce87f8
style(pre-commit): auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 5, 2025
92bad38
Update partial_emoji.py
Lumabots May 5, 2025
879f9d2
Update discord/partial_emoji.py
Lumabots May 9, 2025
49494cb
feature(partial_emoji): support :name: and name
Lumabots May 9, 2025
45d37cd
fix(partial_emoji): remove unnecessary data variable after processing…
Lumabots May 9, 2025
5aeebb6
Merge branch 'master' into emoji
Lumabots May 9, 2025
f2a1deb
Update partial_emoji.py
Lumabots May 19, 2025
f84cfc4
Merge branch 'master' into emoji
Lumabots May 19, 2025
e212726
Merge branch 'master' into emoji
Lumabots May 20, 2025
6b6a0df
reduce emoji.json weight
Lumabots May 25, 2025
6d76476
Update emojis.json
Lumabots May 28, 2025
d8c9f0c
Merge branch 'master' into emoji
Lulalaby Jun 19, 2025
f6e5ed8
refactor: replace Path with importlib.resources for loading emojis.json
Lumabots Jun 19, 2025
ef4f0bf
Update emojis.json
Lumabots Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2761](https://github.com/Pycord-Development/pycord/pull/2761))
- Updated `valid_locales` to support `in` and `es-419`.
([#2767](https://github.com/Pycord-Development/pycord/pull/2767))
- Fixed support emoji aliases like `:smile:` in PartialEmoji.from_str.
([#2774](https://github.com/Pycord-Development/pycord/pull/2774))
- Fixed `Webhook.edit` not working with `attachments=[]`.
([#2779](https://github.com/Pycord-Development/pycord/pull/2779))
- Fixed GIF-based `Sticker` returning the wrong `url`.
Expand Down
1 change: 1 addition & 0 deletions discord/emojis.json

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion discord/partial_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@

from __future__ import annotations

import json
import re
from pathlib import Path
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar

from . import utils
from .asset import Asset, AssetMixin
from .errors import InvalidArgument

EMOJIS_MAP_PATH = Path(__file__).parent / "emojis.json"

with EMOJIS_MAP_PATH.open("r", encoding="utf-8") as f:
EMOJIS_MAP = json.load(f)

__all__ = ("PartialEmoji",)

if TYPE_CHECKING:
Expand Down Expand Up @@ -127,7 +134,7 @@ def from_str(cls: type[PE], value: str) -> PE:
- ``name:id``
- ``<:name:id>``

If the format does not match then it is assumed to be a unicode emoji.
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:``).

.. versionadded:: 2.0

Expand All @@ -141,6 +148,12 @@ def from_str(cls: type[PE], value: str) -> PE:
:class:`PartialEmoji`
The partial emoji from this string.
"""
if value.startswith(":") and value.endswith(":"):
name = value[1:-1]
unicode_emoji = EMOJIS_MAP.get(name)
if unicode_emoji:
return cls(name=unicode_emoji, id=None, animated=False)

match = cls._CUSTOM_EMOJI_RE.match(value)
if match is not None:
groups = match.groupdict()
Expand Down