From 2447303043ac665a6742d1e269e6aca364d2912e Mon Sep 17 00:00:00 2001 From: Lumouille <144063653+Lumabots@users.noreply.github.com> Date: Wed, 25 Jun 2025 01:10:23 +0300 Subject: [PATCH 1/3] Update converter.py --- discord/ext/commands/converter.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index e60ac89b34..9529752ecc 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -872,6 +872,9 @@ async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji: id=emoji_id, ) + if argument: + return discord.PartialEmoji(name=argument) + raise PartialEmojiConversionFailure(argument) @@ -1094,7 +1097,11 @@ def get_converter(param: inspect.Parameter) -> Any: def is_generic_type(tp: Any, *, _GenericAlias: type = _GenericAlias) -> bool: - return isinstance(tp, type) and issubclass(tp, Generic) or isinstance(tp, _GenericAlias) # type: ignore + return ( + isinstance(tp, type) + and issubclass(tp, Generic) + or isinstance(tp, _GenericAlias) + ) # type: ignore CONVERTER_MAPPING: dict[type[Any], Any] = { From 718b68facbc1adb408d88207e5c1e7e6998b2330 Mon Sep 17 00:00:00 2001 From: Lumouille <144063653+Lumabots@users.noreply.github.com> Date: Wed, 25 Jun 2025 01:44:28 +0300 Subject: [PATCH 2/3] fix: enhance PartialEmojiConverter to support direct emoji names --- discord/ext/commands/converter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 9529752ecc..e225c472b5 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -41,6 +41,7 @@ ) import discord +from discord.partial_emoji import EMOJIS_MAP from .errors import * @@ -872,8 +873,13 @@ async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji: id=emoji_id, ) - if argument: - return discord.PartialEmoji(name=argument) + if argument in EMOJIS_MAP.values(): + return discord.PartialEmoji.with_state( + ctx.bot._connection, + animated=False, + name=argument, + id=None, + ) raise PartialEmojiConversionFailure(argument) From b5fb13c80265a6232297a48119b93d90f3926889 Mon Sep 17 00:00:00 2001 From: Lumouille <144063653+Lumabots@users.noreply.github.com> Date: Wed, 25 Jun 2025 01:45:46 +0300 Subject: [PATCH 3/3] update doc --- discord/ext/commands/converter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index e225c472b5..5f75aec6b3 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -852,7 +852,8 @@ async def convert(self, ctx: Context, argument: str) -> discord.GuildEmoji: class PartialEmojiConverter(Converter[discord.PartialEmoji]): """Converts to a :class:`~discord.PartialEmoji`. - This is done by extracting the animated flag, name and ID from the emoji. + This is done by extracting the animated flag, name, and ID for custom emojis, + or by using the standard Unicode emojis supported by Discord. .. versionchanged:: 1.5 Raise :exc:`.PartialEmojiConversionFailure` instead of generic :exc:`.BadArgument`