Skip to content

Revert 2814 revert 2774 emoji #2820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions discord/ext/commands/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
)

import discord
from discord.partial_emoji import EMOJIS_MAP
from discord.utils import UNICODE_EMOJIS

from .errors import *

Expand Down Expand Up @@ -874,7 +874,7 @@ async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji:
id=emoji_id,
)

if argument in EMOJIS_MAP.values():
if argument in UNICODE_EMOJIS:
return discord.PartialEmoji.with_state(
ctx.bot._connection,
animated=False,
Expand Down
11 changes: 1 addition & 10 deletions discord/partial_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,13 @@

from __future__ import annotations

import importlib.resources
import json
import re
from typing import TYPE_CHECKING, Any, TypedDict, TypeVar

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

with (
importlib.resources.files(__package__)
.joinpath("emojis.json")
.open(encoding="utf-8") as f
):
EMOJIS_MAP = json.load(f)

__all__ = ("PartialEmoji",)

if TYPE_CHECKING:
Expand Down Expand Up @@ -152,7 +143,7 @@ def from_str(cls: type[PE], value: str) -> PE:
"""
if value.startswith(":") and value.endswith(":") and len(value) > 2:
name = value[1:-1]
if unicode_emoji := EMOJIS_MAP.get(name):
if unicode_emoji := utils.EMOJIS_MAP.get(name):
return cls(name=unicode_emoji, id=None, animated=False)
match = cls._CUSTOM_EMOJI_RE.match(value)
if match is not None:
Expand Down
12 changes: 12 additions & 0 deletions discord/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import collections.abc
import datetime
import functools
import importlib.resources
import itertools
import json
import re
Expand Down Expand Up @@ -97,10 +98,21 @@
"generate_snowflake",
"basic_autocomplete",
"filter_params",
"EMOJIS_MAP",
"UNICODE_EMOJIS",
)

DISCORD_EPOCH = 1420070400000

with (
importlib.resources.files(__package__)
.joinpath("emojis.json")
.open(encoding="utf-8") as f
):
EMOJIS_MAP = json.load(f)

UNICODE_EMOJIS = set(EMOJIS_MAP.values())


class _MissingSentinel:
def __eq__(self, other) -> bool:
Expand Down
Loading