|
|
|
@ -39,6 +39,7 @@ __all__ = ( |
|
|
|
if TYPE_CHECKING: |
|
|
|
from typing_extensions import Self |
|
|
|
|
|
|
|
from .client import Client |
|
|
|
from .state import ConnectionState |
|
|
|
from datetime import datetime |
|
|
|
from .types.emoji import Emoji as EmojiPayload, PartialEmoji as PartialEmojiPayload |
|
|
|
@ -114,7 +115,7 @@ class PartialEmoji(_EmojiTag, AssetMixin): |
|
|
|
) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def from_str(cls, value: str) -> Self: |
|
|
|
def from_str(cls, value: str, *, client: Client = utils.MISSING) -> Self: |
|
|
|
"""Converts a Discord string representation of an emoji to a :class:`PartialEmoji`. |
|
|
|
|
|
|
|
The formats accepted are: |
|
|
|
@ -132,6 +133,11 @@ class PartialEmoji(_EmojiTag, AssetMixin): |
|
|
|
------------ |
|
|
|
value: :class:`str` |
|
|
|
The string representation of an emoji. |
|
|
|
client: :class:`Client` |
|
|
|
The client to initialise this emoji with. This allows it to |
|
|
|
attach the client's internal state. |
|
|
|
|
|
|
|
.. versionadded:: 2.7 |
|
|
|
|
|
|
|
Returns |
|
|
|
-------- |
|
|
|
@ -144,8 +150,12 @@ class PartialEmoji(_EmojiTag, AssetMixin): |
|
|
|
animated = bool(groups['animated']) |
|
|
|
emoji_id = int(groups['id']) |
|
|
|
name = groups['name'] |
|
|
|
if client is not utils.MISSING: |
|
|
|
return cls.with_state(name=name, animated=animated, id=emoji_id, state=client._connection) |
|
|
|
return cls(name=name, animated=animated, id=emoji_id) |
|
|
|
|
|
|
|
if client is not utils.MISSING: |
|
|
|
return cls.with_state(name=value, animated=False, id=None, state=client._connection) |
|
|
|
return cls(name=value, id=None, animated=False) |
|
|
|
|
|
|
|
def to_dict(self) -> EmojiPayload: |
|
|
|
|