@@ -470,7 +470,6 @@ async def reply(
470470
471471 if not components or components is MISSING :
472472 _components = []
473- # TODO: Break this obfuscation pattern down to a "builder" method.
474473 else :
475474 _components = _build_components (components = components )
476475
@@ -552,6 +551,97 @@ async def create_thread(
552551 )
553552 return Channel (** res , _client = self ._client )
554553
554+ async def create_reaction (
555+ self ,
556+ emoji : Union [str , "Emoji" ],
557+ ) -> None :
558+ """
559+ Adds a reaction to the message.
560+
561+ :param emoji: The Emoji as object or formatted as `name:id`
562+ :type emoji: Union[str, Emoji]
563+ """
564+ if not self ._client :
565+ raise AttributeError ("HTTPClient not found!" )
566+
567+ _emoji = (
568+ emoji if not isinstance (emoji , Emoji ) else f":{ emoji .name .replace (':' , '' )} :{ emoji .id } "
569+ )
570+
571+ return await self ._client .create_reaction (
572+ channel_id = int (self .channel_id ), message_id = int (self .id ), emoji = _emoji
573+ )
574+
575+ async def remove_all_reactions (self ) -> None :
576+ """
577+ Removes all reactions of the message.
578+ """
579+ if not self ._client :
580+ raise AttributeError ("HTTPClient not found!" )
581+
582+ return await self ._client .remove_all_reactions (
583+ channel_id = int (self .channel_id ), message_id = int (self .id )
584+ )
585+
586+ async def remove_all_reactions_of (
587+ self ,
588+ emoji : Union [str , "Emoji" ],
589+ ) -> None :
590+ """
591+ Removes all reactions of one emoji of the message.
592+
593+ :param emoji: The Emoji as object or formatted as `name:id`
594+ :type emoji: Union[str, Emoji]
595+ """
596+ if not self ._client :
597+ raise AttributeError ("HTTPClient not found!" )
598+
599+ _emoji = (
600+ emoji if not isinstance (emoji , Emoji ) else f":{ emoji .name .replace (':' , '' )} :{ emoji .id } "
601+ )
602+ return await self ._client .remove_all_reactions_of_emoji (
603+ channel_id = int (self .channel_id ), message_id = int (self .id ), emoji = _emoji
604+ )
605+
606+ async def remove_own_reaction_of (
607+ self ,
608+ emoji : Union [str , "Emoji" ],
609+ ) -> None :
610+ """
611+ Removes the own reaction of an emoji of the message.
612+
613+ :param emoji: The Emoji as object or formatted as `name:id`
614+ :type emoji: Union[str, Emoji]
615+ """
616+ if not self ._client :
617+ raise AttributeError ("HTTPClient not found!" )
618+
619+ _emoji = (
620+ emoji if not isinstance (emoji , Emoji ) else f"{ emoji .name .replace (':' , '' )} :{ emoji .id } "
621+ )
622+ return await self ._client .remove_self_reaction (
623+ channel_id = int (self .channel_id ), message_id = int (self .id ), emoji = _emoji
624+ )
625+
626+ async def remove_reaction_from (
627+ self , emoji : Union [str , "Emoji" ], user : Union [Member , User , int ]
628+ ) -> None :
629+ """
630+ Removes another reaction of an emoji of the message.
631+
632+ :param emoji: The Emoji as object or formatted as `name:id`
633+ :type emoji: Union[str, Emoji]
634+ :param user: The user or user_id to remove the reaction of
635+ :type user: Union[Member, user, int]
636+ """
637+ _emoji = (
638+ emoji if not isinstance (emoji , Emoji ) else f":{ emoji .name .replace (':' , '' )} :{ emoji .id } "
639+ )
640+ _user_id = user if isinstance (user , int ) else user .id
641+ return await self ._client .remove_user_reaction (
642+ channel_id = int (self .channel_id ), message_id = int (self .id ), user_id = _user_id , emoji = _emoji
643+ )
644+
555645 @classmethod
556646 async def get_from_url (cls , url : str , client : "HTTPClient" ) -> "Message" : # noqa,
557647 """
@@ -590,6 +680,7 @@ class Emoji(DictSerializerMixin):
590680 """
591681
592682 __slots__ = (
683+ "_client" ,
593684 "_json" ,
594685 "id" ,
595686 "name" ,
@@ -605,6 +696,66 @@ def __init__(self, **kwargs):
605696 super ().__init__ (** kwargs )
606697 self .id = Snowflake (self .id ) if self ._json .get ("id" ) else None
607698
699+ @classmethod
700+ async def get (
701+ cls ,
702+ guild_id : int ,
703+ emoji_id : int ,
704+ client : "HTTPClient" , # noqa
705+ ) -> "Emoji" :
706+ """
707+ Gets an emoji.
708+
709+ :param guild_id: The id of the guild of the emoji
710+ :type guild_id: int
711+ :param emoji_id: The id of the emoji
712+ :type emoji_id: int
713+ :param client: The HTTPClient of your bot. Equals to ``bot._http``
714+ :type client: HTTPClient
715+ :return: The Emoji as object
716+ :rtype: Emoji
717+ """
718+ res = await client .get_guild_emoji (guild_id = guild_id , emoji_id = emoji_id )
719+ return cls (** res , _client = client )
720+
721+ @classmethod
722+ async def get_all_of_guild (
723+ cls ,
724+ guild_id : int ,
725+ client : "HTTPClient" , # noqa
726+ ) -> List ["Emoji" ]:
727+ """
728+ Gets all emoji of a guild.
729+
730+ :param guild_id: The id of the guild to get the emojis of
731+ :type guild_id: int
732+ :param client: The HTTPClient of your bot. Equals to ``bot._http``
733+ :type client: HTTPClient
734+ :return: The Emoji as list
735+ :rtype: List[Emoji]
736+ """
737+ res = await client .get_all_emoji (guild_id = guild_id )
738+ return [cls (** emoji , _client = client ) for emoji in res ]
739+
740+ async def delete (
741+ self ,
742+ guild_id : int ,
743+ reason : Optional [str ] = None ,
744+ ) -> None :
745+ """
746+ Deletes the emoji.
747+
748+ :param guild_id: The guild id to delete the emoji from
749+ :type guild_id: int
750+ :param reason?: The reason of the deletion
751+ :type reason?: Optional[str]
752+ """
753+ if not self ._client :
754+ raise AttributeError ("HTTPClient not found!" )
755+ return await self ._client .delete_guild_emoji (
756+ guild_id = guild_id , emoji_id = int (self .id ), reason = reason
757+ )
758+
608759
609760class ReactionObject (DictSerializerMixin ):
610761 """The reaction object.
0 commit comments