
    i%                        d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ dZer$dd	lmZ ddlmZ dd
lmZ ddlmZ ddlmZ ddlmZ  G d d          ZdS )a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotations)TYPE_CHECKINGAsyncIteratorUnionOptional   )User)Object)ReactionType)Reaction)Member)Message)PartialEmoji)Emoji)	Snowflakec                  v    e Zd ZdZdZddd&dZd'dZd(dZd(dZd)dZ	d*dZ
d*dZd+dZd,dZddddd-d%ZdS ).r   a  Represents a reaction to a message.

    Depending on the way this object was created, some of the attributes can
    have a value of ``None``.

    .. container:: operations

        .. describe:: x == y

            Checks if two reactions are equal. This works by checking if the emoji
            is the same. So two messages with the same reaction will be considered
            "equal".

        .. describe:: x != y

            Checks if two reactions are not equal.

        .. describe:: hash(x)

            Returns the reaction's hash.

        .. describe:: str(x)

            Returns the string form of the reaction's emoji.

    Attributes
    -----------
    emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`]
        The reaction emoji. May be a custom emoji, or a unicode emoji.
    count: :class:`int`
        Number of times this reaction was made. This is a sum of :attr:`normal_count` and :attr:`burst_count`.
    me: :class:`bool`
        If the user sent this reaction.
    message: :class:`Message`
        Message this reaction is for.
    me_burst: :class:`bool`
        If the user sent this super reaction.

        .. versionadded:: 2.4
    normal_count: :class:`int`
        The number of times this reaction was made using normal reactions.
        This is not available in the gateway events such as :func:`on_reaction_add`
        or :func:`on_reaction_remove`.

        .. versionadded:: 2.4
    burst_count: :class:`int`
        The number of times this reaction was made using super reactions.
        This is not available in the gateway events such as :func:`on_reaction_add`
        or :func:`on_reaction_remove`.

        .. versionadded:: 2.4
    )messagecountemojimeme_burstnormal_countburst_countN)r   r   r   dataReactionPayloadr   )Optional[Union[PartialEmoji, Emoji, str]]c                  || _         |p|j                            |d                   | _        |                    dd          | _        |d         | _        |                    di           }|                    dd          | _        |                    dd          | _        |                    d	d
          | _	        d S )Nr   r   r   r   count_detailsnormalr   burstr   F)
r   _stateget_emoji_from_partial_payloadr   getr   r   r   r   r   )selfr   r   r   detailss        W/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/reaction.py__init__zReaction.__init__g   s     '6;6{w~?l?lmqrymz?{?{
((7A..
T
((?B//!(Xq!9!9 'GQ 7 7"hhz599    returnboolc                8    t          | j        t                     S )z):class:`bool`: If this is a custom emoji.)
isinstancer   strr$   s    r&   is_custom_emojizReaction.is_custom_emojiq   s    dj#....r(   otherobjectc                L    t          || j                  o|j        | j        k    S Nr,   	__class__r   r$   r0   s     r&   __eq__zReaction.__eq__u   s"    %00NU[DJ5NNr(   c                P    t          || j                  r|j        | j        k    S dS )NTr4   r6   s     r&   __ne__zReaction.__ne__x   s*    eT^,, 	-;$*,,tr(   intc                *    t          | j                  S r3   )hashr   r.   s    r&   __hash__zReaction.__hash__}   s    DJr(   r-   c                *    t          | j                  S r3   )r-   r   r.   s    r&   __str__zReaction.__str__   s    4:r(   c                8    d| j         d| j         d| j         dS )Nz<Reaction emoji=z me=z count=>)r   r   r   r.   s    r&   __repr__zReaction.__repr__   s)    Q$*QQDGQQDJQQQQr(   userr   Nonec                V   K   | j                             | j        |           d{V  dS )a  |coro|

        Remove the reaction by the provided :class:`User` from the message.

        If the reaction is not your own (i.e. ``user`` parameter is not you) then
        :attr:`~Permissions.manage_messages` is needed.

        The ``user`` parameter must represent a user or member and meet
        the :class:`abc.Snowflake` abc.

        Parameters
        -----------
        user: :class:`abc.Snowflake`
             The user or member from which to remove the reaction.

        Raises
        -------
        HTTPException
            Removing the reaction failed.
        Forbidden
            You do not have the proper permissions to remove the reaction.
        NotFound
            The user you specified, or the reaction's message was not found.
        N)r   remove_reactionr   )r$   rC   s     r&   removezReaction.remove   s:      4 l**4:t<<<<<<<<<<<r(   c                T   K   | j                             | j                   d{V  dS )am  |coro|

        Clears this reaction from the message.

        You must have :attr:`~Permissions.manage_messages` to do this.

        .. versionadded:: 1.3

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        Raises
        --------
        HTTPException
            Clearing the reaction failed.
        Forbidden
            You do not have the proper permissions to clear the reaction.
        NotFound
            The emoji you specified was not found.
        TypeError
            The emoji parameter is invalid.
        N)r   clear_reactionr   r.   s    r&   clearzReaction.clear   s8      0 l))$*55555555555r(   )limitaftertyperK   Optional[int]rL   Optional[Snowflake]rM   Optional[ReactionType]"AsyncIterator[Union[Member, User]]c              2  K   t          | j        t                    s| j        j         d| j        j         }n| j        }|| j        }|dk    rGt          |d          }| j        }|j        }|j	        }|r|j        nd}	|j
                            |j        j        |j        |||	||j        nd           d{V }
|
r<|t          |
          z  }t          t!          |
d         d                             }nd}|t          |t                    r't#          |
          D ]}t%          ||	          W V  t#          |
          D ]B}t!          |d                   }|                    |          }|pt%          ||	          W V  C|dk    EdS dS )
a  Returns an :term:`asynchronous iterator` representing the users that have reacted to the message.

        The ``after`` parameter must represent a member
        and meet the :class:`abc.Snowflake` abc.

        .. versionchanged:: 2.0

            ``limit`` and ``after`` parameters are now keyword-only.

        Examples
        ---------

        Usage ::

            # I do not actually recommend doing this.
            async for user in reaction.users():
                await channel.send(f'{user} has reacted with {reaction.emoji}!')

        Flattening into a list: ::

            users = [user async for user in reaction.users()]
            # users is now a list of User...
            winner = random.choice(users)
            await channel.send(f'{winner} has won the raffle.')

        Parameters
        ------------
        limit: Optional[:class:`int`]
            The maximum number of results to return.
            If not provided, returns all the users who
            reacted to the message.
        after: Optional[:class:`abc.Snowflake`]
            For pagination, reactions are sorted by member.
        type: Optional[:class:`ReactionType`]
            The type of reaction to return users from.
            If not provided, Discord only returns users of reactions with type ``normal``.

            .. versionadded:: 2.4

        Raises
        --------
        HTTPException
            Getting the users for the reaction failed.

        Yields
        --------
        Union[:class:`User`, :class:`Member`]
            The member (if retrievable) or the user that has reacted
            to this message. The case where it can be a :class:`Member` is
            in a guild message context. Sometimes it can be a :class:`User`
            if the member has left the guild.
        :Nr   d   )rL   rM   id)rV   )stater   )r,   r   r-   namerV   r   minr   guildr!   httpget_reaction_userschannelvaluelenr
   r:   reversedr	   
get_member)r$   rK   rL   rM   r   retriever   rZ   rW   after_idr   raw_user	member_idmembers                 r&   userszReaction.users   s     p $*c** 	z8888EEJE=JEaii5#HlGMENE#(2uxxdH66"
#'#3TZZ 7        D  T"#d2htn"5"5666 }
5& 9 9} ( ; ;HU::::::::$TNN A A//	)))44@5x @ @ @@@@@@E aiiiiiir(   )r   r   r   r   r   r   )r)   r*   )r0   r1   r)   r*   )r)   r:   )r)   r-   )rC   r   r)   rD   )r)   rD   )rK   rN   rL   rO   rM   rP   r)   rQ   )__name__
__module____qualname____doc__	__slots__r'   r/   r7   r9   r=   r?   rB   rG   rJ   rg    r(   r&   r   r   /   s(       3 3j _Ivz : : : : : :/ / / /O O O O   
          R R R R= = = =86 6 6 66 )-4ptbA bA bA bA bA bA bA bAr(   r   N)rk   
__future__r   typingr   r   r   r   rC   r	   r1   r
   enumsr   __all__rf   r   types.messager   r   r   r   partial_emojir   r   r   abcr   rm   r(   r&   <module>ru      s@   0 # " " " " " @ @ @ @ @ @ @ @ @ @ @ @                  
  ::::::      ++++++oA oA oA oA oA oA oA oA oA oAr(   