-
-
Notifications
You must be signed in to change notification settings - Fork 477
feat: Added support for emoji aliases like :smile:
in PartialEmoji.from_str (redo)
#2815
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
base: master
Are you sure you want to change the base?
Conversation
…moji.fro…" This reverts commit 8619b69.
Also this is not a fix but probably more a feat |
:smile:
in PartialEmoji.from_str (redo):smile:
in PartialEmoji.from_str (redo)
Co-authored-by: Paillat <[email protected]> Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
Signed-off-by: Lala Sabathil <[email protected]>
:smile:
in PartialEmoji.from_str (redo):smile:
in PartialEmoji.from_str (redo)
@Lulalaby pls add |
should i make a new pr or could we add to this pr the support unicode emoji in partial emoji converter ? from discord.partial_emoji import EMOJIS_MAP
class PartialEmojiConverter(Converter[discord.PartialEmoji]):
"""Converts to a :class:`~discord.PartialEmoji`.
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`
"""
async def convert(self, ctx: Context, argument: str) -> discord.PartialEmoji:
match = re.match(r"<(a?):(\w{1,32}):([0-9]{15,20})>$", argument)
if match:
emoji_animated = bool(match.group(1))
emoji_name = match.group(2)
emoji_id = int(match.group(3))
return discord.PartialEmoji.with_state(
ctx.bot._connection,
animated=emoji_animated,
name=emoji_name,
id=emoji_id,
)
if argument in EMOJIS_MAP.values():
return discord.PartialEmoji.with_state(
ctx.bot._connection,
animated=False,
name=argument,
id=None,
)
raise PartialEmojiConversionFailure(argument) for the moment, only custom emoji are supported. |
pr it to the branch |
Signed-off-by: Lala Sabathil <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested please someone else test it too
so its rely on this pr (for the emoji custom map, so to be able to pr it i will first need this to be merged. |
oups that's mb, i'm usually not able to pr directly on branch, but it might be different since you are a maintainer |
* Update converter.py * fix: enhance PartialEmojiConverter to support direct emoji names * update doc
Pr changes 😂 I'm too dead |
im gonna sleep its 2am rn, but i'll check that tomorrow morning, if you have a more efficient way to check for the value feel free to share it |
* Add Unicode emoji support to PartialEmojiConverter PartialEmojiConverter now recognizes standard Unicode emojis using a new UNICODE_EMOJIS set loaded from emojis.json. The emoji mapping and set are moved to discord.utils for reuse, and references in partial_emoji.py are updated accordingly. * style(pre-commit): auto fixes from pre-commit.com hooks * Update converter.py Signed-off-by: Lumouille <[email protected]> * Update converter.py * fix(utils): update UNICODE_EMOJIS to use values from EMOJIS_MAP --------- Signed-off-by: Lumouille <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add Unicode emoji support to PartialEmojiConverter PartialEmojiConverter now recognizes standard Unicode emojis using a new UNICODE_EMOJIS set loaded from emojis.json. The emoji mapping and set are moved to discord.utils for reuse, and references in partial_emoji.py are updated accordingly. * style(pre-commit): auto fixes from pre-commit.com hooks * Update converter.py Signed-off-by: Lumouille <[email protected]> * Update converter.py * fix(utils): update UNICODE_EMOJIS to use values from EMOJIS_MAP * fix(partial_emoji): simplify emoji name extraction by using removeprefix and removesuffix * style(pre-commit): auto fixes from pre-commit.com hooks --------- Signed-off-by: Lumouille <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Lala Sabathil <[email protected]>
@@ -127,7 +127,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:``). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:``). | |
If the format does not match then it is assumed to be a Unicode emoji block, either as Unicode characters or as a Discord alias (``:smile:``). |
@@ -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)) | |||
- Added support for emoji aliases like `:smile:` in PartialEmoji.from_str. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to mention it was also added to PartialEmojiConverter
or add a second line or smth.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll do that soon
@@ -97,10 +98,21 @@ | |||
"generate_snowflake", | |||
"basic_autocomplete", | |||
"filter_params", | |||
"EMOJIS_MAP", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we consider documenting these as public utils ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont see why it would not be a good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we would then have to maintain that and also would not be able to remove them without it being breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we would then have to maintain that and also would not be able to remove them without it being breaking.
Then let's not put it public ;)
@Lumabots Can you take a look at the comments ? |
Reverts #2814
Re-applies #2774