
    cjhT                       d Z ddlmZ ddlmZmZmZ ddl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 ddlmZmZmZ er8ddlmZ ddlmZ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$ ddl%m&Z' ddl%m(Z) dZ* edd      Z+ G d d      Z, G d de,      Z- G d de-      Z. G d de-ej0                  j^                        Z(y)ae  
The MIT License (MIT)

Copyright (c) 2015-2021 Rapptz
Copyright (c) 2021-present Pycord Development

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AnyTypeVarN   )Asset)Colour)PublicUserFlags)EntitlementIterator)Entitlement)MISSING_bytes_to_base64_datasnowflake_time)datetime)	SnowflakeSnowflakeTime)	DMChannel)Guild)Message)ConnectionState)PartialUser)User)r   
ClientUserBUBaseUser)boundc                      e Zd ZU dZded<   y)_UserTag intidN)__name__
__module____qualname__	__slots____annotations__r       ?/var/www/html/venv/lib/python3.12/site-packages/discord/user.pyr   r   <   s    IGr'   r   c                     e Zd ZU dZer<ded<   ded<   ded<   ded<   d	ed
<   d	ed<   ded<   ded<   ded<   ded<   ded<   ded<   	 	 	 	 	 	 d.dZd/dZd/dZd0dZ	d1dZ
d2dZed3d       Zd4dZed/d       Zed5d       Zed6d       Zed7d        Zed7d!       Zed6d"       Zed6d#       Zed8d$       Zed8d%       Zed9d&       Zed9d'       Zed/d(       Zed:d)       Zed/d*       Zd;d+Zed<d,       Zy-)=r   )namer!   discriminatorglobal_name_avatar_banner_accent_colourbotsystem_public_flags_avatar_decoration_statestrr*   r    r!   r+   
str | Noner,   boolr0   r1   r   r4   r-   r.   
int | Noner/   zdict | Noner3   r2   c               4    || _         | j                  |       y N)r4   _update)selfstatedatas      r(   __init__zBaseUser.__init___   s     Tr'   c                   | j                   r| j                  Dd| j                   d| j                  d| j                  d| j                   d| j
                   dS d| j                   d| j                  d| j                   d| j
                   d	S d| j                   d| j                  d| j                  d| j                   d| j
                   dS )	Nz<BaseUser id=
 username= global_name= bot=z system=> name= discriminator=)is_migratedr,   r!   r*   r0   r1   r+   r<   s    r(   __repr__zBaseUser.__repr__e   s    +77):dii]-HXHXG[DHH:Xdkk]!=wwiz$))z$++a977)6$))od>P>P=SDHH:Xdkk]!5	
r'   c                    | j                   s| j                   d| j                   S | j                  | j                   d| j                   dS | j                  S )N#z ())rG   r*   r+   r,   rH   s    r(   __str__zBaseUser.__str__x   sk     ## yyk4--./	

 ##/ 99+R 0 013		
 YY	
r'   c                X    t        |t              xr |j                  | j                  k(  S r:   )
isinstancer   r!   )r<   others     r(   __eq__zBaseUser.__eq__   s!    %*Buxx477/BBr'   c                     | j                   dz	  S )N   r!   rH   s    r(   __hash__zBaseUser.__hash__   s    ww"}r'   c                   |d   | _         t        |d         | _        |d   | _        |j	                  dd       xs d | _        |d   | _        |j	                  dd       | _        |j	                  dd       | _        |j	                  dd       | _	        |j	                  d	d
      | _
        |j	                  dd      | _        |j	                  dd      | _        y )Nusernamer!   r+   r,   avatarbanneraccent_coloravatar_decoration_datapublic_flagsr   r0   Fr1   )r*   r    r!   r+   getr,   r-   r.   r/   r3   r2   r0   r1   )r<   r>   s     r(   r;   zBaseUser._update   s    $	d4j/!/288M48@DH~xx$/"hh~t<"&((+CT"J!XXna888E5)hhx/r'   c                   | j                  |       }|j                  |_        |j                  |_        |j                  |_        |j                  |_        |j
                  |_        |j                  |_        |j                  |_        |j                  |_        |j                  |_	        |j                  |_
        |j                  |_        |S r:   )__new__r*   r!   r+   r,   r-   r.   r/   r3   r0   r4   r2   )clsuserr<   s      r(   _copyzBaseUser._copy   s    {{3II	''!//++||||"11"&"9"988kk!//r'   c                    | j                   | j                  | j                  | j                  | j                  | j
                  dS )N)rW   r!   rX   r+   r,   r0   )r*   r!   r-   r+   r,   r0   rH   s    r(   _to_minimal_user_jsonzBaseUser._to_minimal_user_json   s:    		''ll!//++88
 	
r'   c                     d| j                    S )zaReturns a URL that allows the client to jump to the user.

        .. versionadded:: 2.0
        zhttps://discord.com/users/rT   rH   s    r(   jump_urlzBaseUser.jump_url   s     ,DGG955r'   c                @    t        j                  | j                        S )z*The publicly available flags the user has.)r
   _from_valuer2   rH   s    r(   r\   zBaseUser.public_flags   s     **4+=+=>>r'   c                    | j                   5t        j                  | j                  | j                  | j                         S y)zReturns an :class:`Asset` for the avatar the user has.

        If the user does not have a traditional avatar, ``None`` is returned.
        If you want the avatar that a user has displayed, consider :attr:`display_avatar`.
        N)r-   r   _from_avatarr4   r!   rH   s    r(   rX   zBaseUser.avatar   s2     <<#%%dkk477DLLIIr'   c                    | j                   r| j                  dz	  nt        | j                        }| j                   rdnd}t	        j
                  | j                  ||z        S )zReturns the default avatar for a given user.
        This is calculated by the user's ID if they're on the new username system, otherwise their discriminator.
        rS         )rG   r!   r    r+   r   _from_default_avatarr4   )r<   eqpercs      r(   default_avatarzBaseUser.default_avatar   sP    
 !% 0 0dggmc$:L:L6M$$q!))$++rDyAAr'   c                6    | j                   xs | j                  S )zReturns the user's display avatar.

        For regular users this is just their default avatar or uploaded avatar.

        .. versionadded:: 2.0
        )rX   rq   rH   s    r(   display_avatarzBaseUser.display_avatar   s     {{1d111r'   c                    | j                   yt        j                  | j                  | j                  | j                         S )zReturns the user's banner asset, if available.

        .. versionadded:: 2.0

        .. note::
            This information is only available via :meth:`Client.fetch_user`.
        N)r.   r   _from_user_bannerr4   r!   rH   s    r(   rY   zBaseUser.banner   s2     <<&&t{{DGGT\\JJr'   c                    | j                   yt        j                  | j                  | j                  | j                   j                  d            S )z[Returns the user's avatar decoration, if available.

        .. versionadded:: 2.5
        Nasset)r3   r   _from_avatar_decorationr4   r!   r]   rH   s    r(   avatar_decorationzBaseUser.avatar_decoration   sF     ""*,,KK$"9"9"="=g"F
 	
r'   c                F    | j                   yt        | j                         S )zReturns the user's accent colour, if applicable.

        There is an alias for this named :attr:`accent_color`.

        .. versionadded:: 2.0

        .. note::

            This information is only available via :meth:`Client.fetch_user`.
        N)r/   r	   rH   s    r(   accent_colourzBaseUser.accent_colour   s$     &d))**r'   c                    | j                   S )zReturns the user's accent color, if applicable.

        There is an alias for this named :attr:`accent_colour`.

        .. versionadded:: 2.0

        .. note::

            This information is only available via :meth:`Client.fetch_user`.
        )r{   rH   s    r(   rZ   zBaseUser.accent_color  s     !!!r'   c                *    t        j                         S )zA property that returns a colour denoting the rendered colour
        for the user. This always returns :meth:`Colour.default`.

        There is an alias for this named :attr:`color`.
        )r	   defaultrH   s    r(   colourzBaseUser.colour  s     ~~r'   c                    | j                   S )zA property that returns a color denoting the rendered color
        for the user. This always returns :meth:`Colour.default`.

        There is an alias for this named :attr:`colour`.
        )r   rH   s    r(   colorzBaseUser.color  s     {{r'   c                "    d| j                    dS )z;Returns a string that allows you to mention the given user.z<@rD   rT   rH   s    r(   mentionzBaseUser.mention&  s     DGG9Ar'   c                ,    t        | j                        S )zoReturns the user's creation time in UTC.

        This is when the user's Discord account was created.
        )r   r!   rH   s    r(   
created_atzBaseUser.created_at+  s     dgg&&r'   c                6    | j                   xs | j                  S )zrReturns the user's display name.
        This will be their global name if set, otherwise their username.
        )r,   r*   rH   s    r(   display_namezBaseUser.display_name3  s    
 ,499,r'   c                Z     |j                   ryt         fd|j                  D              S )a:  Checks if the user is mentioned in the specified message.

        Parameters
        ----------
        message: :class:`Message`
            The message to check if you're mentioned in.

        Returns
        -------
        :class:`bool`
            Indicates if the user is mentioned in the message.
        Tc              3  P   K   | ]  }|j                   j                   k(    y wr:   rT   ).0ra   r<   s     r(   	<genexpr>z(BaseUser.mentioned_in.<locals>.<genexpr>K  s     C$477dgg%Cs   #&)mention_everyoneanymentions)r<   messages   ` r(   mentioned_inzBaseUser.mentioned_in:  s(     ##C'2B2BCCCr'   c                     | j                   dk(  S )z;Checks whether the user is already migrated to global name.0)r+   rH   s    r(   rG   zBaseUser.is_migratedM  s     !!S((r'   N)r=   r   r>   z UserPayload | PartialUserPayloadreturnNoner   r5   )rP   r   r   r7   )r   r    r>   UserPayloadr   r   )r`   ztype[BU]ra   r   r   r   )r   zdict[str, Any])r   r
   )r   zAsset | None)r   r   )r   zColour | None)r   r	   )r   r   )r   r   r   r7   )r   r7   ) r"   r#   r$   r%   r   r&   r?   rI   rM   rQ   rU   r;   classmethodrb   rd   propertyrf   r\   rX   rq   rs   rY   ry   r{   rZ   r   r   r   r   r   r   rG   r   r'   r(   r   r   A   s   I 		""'''/O	
&	
C0  "
 6 6 ? ?   B B 2 2 
K 
K 	
 	
 + + " "         ' ' - -D& ) )r'   c                       e Zd ZU dZdZerded<   ded<   ded<   ded	<   d fd
ZddZd fdZ	e
e
e
d	 	 	 	 	 	 	 ddZ xZS )r   a5  Represents your Discord user.

    .. container:: operations

        .. describe:: x == y

            Checks if two users are equal.

        .. describe:: x != y

            Checks if two users are not equal.

        .. describe:: hash(x)

            Return the user's hash.

        .. describe:: str(x)

            Returns the user's name with discriminator or global_name.

    Attributes
    ----------
    name: :class:`str`
        The user's username.
    id: :class:`int`
        The user's unique ID.
    discriminator: :class:`str`
        The user's discriminator. This is given when the username has conflicts.

        .. note::

            If the user has migrated to the new username system, this will always be 0.
    global_name: :class:`str`
        The user's global name.

        .. versionadded:: 2.5
    bot: :class:`bool`
        Specifies if the user is a bot account.
    system: :class:`bool`
        Specifies if the user is a system user (i.e. represents Discord officially).

        .. versionadded:: 1.3
    verified: :class:`bool`
        Specifies if the user's email is verified.
    locale: Optional[:class:`str`]
        The IETF language tag used to identify the language the user is using.
    mfa_enabled: :class:`bool`
        Specifies if the user has MFA turned on and working.
    )locale_flagsverifiedmfa_enabled__weakref__r7   r   r6   r   r   r    r   c               (    t         |   ||       y )Nr=   r>   )superr?   r<   r=   r>   	__class__s      r(   r?   zClientUser.__init__  s    u40r'   c                   | j                   r| j                  Qd| j                   d| j                  d| j                  d| j                   d| j
                   d| j                   dS d| j                   d| j                  d| j                   d| j
                   d| j                   dS d| j                   d| j                  d	| j                  d| j                   d| j
                   d| j                   dS )
Nz<ClientUser id=rA   rB   rC   z
 verified=z mfa_enabled=rD   rE   rF   )rG   r,   r!   r*   r0   r   r   r+   rH   s    r(   rI   zClientUser.__repr__  s	   +77):dii]-HXHXG[DHH:ZmDL\L\K]]^`wwiz$))zDMM?-HXHXGYYZ\77)6$))od>P>P=SDHH:ZmDDTDTCUUVX	
r'   c                    t         |   |       |j                  dd      | _        |j                  d      | _        |j                  dd      | _        |j                  dd      | _        y )Nr   Fr   flagsr   r   )r   r;   r]   r   r   r   r   )r<   r>   r   s     r(   r;   zClientUser._update  sV    U3hhx(hhw*88M59r'   )rW   rX   rY   c               ,  K   i }|t         ur||d<   |d|d<   n|t         urt        |      |d<   |d|d<   n|t         urt        |      |d<   | j                  j                  j	                  |       d{   }t        | j                  |      S 7 w)a  |coro|

        Edits the current profile of the client.

        .. note::

            To upload an avatar or banner, a :term:`py:bytes-like object` must be passed in that
            represents the image being uploaded. If this is done through a file
            then the file must be opened via ``open('some_filename', 'rb')`` and
            the :term:`py:bytes-like object` is given through the use of ``fp.read()``.

            The only image formats supported for uploading are JPEG, PNG, and GIF.

        .. versionchanged:: 2.0
            The edit is no longer in-place, instead the newly edited client user is returned.

        .. versionchanged:: 2.6
            The ``banner`` keyword-only parameter was added.

        Parameters
        ----------
        username: :class:`str`
            The new username you wish to change to.
        avatar: :class:`bytes`
            A :term:`py:bytes-like object` representing the image to upload.
            Could be ``None`` to denote no avatar.
        banner: :class:`bytes`
            A :term:`py:bytes-like object` representing the image to upload.
            Could be ``None`` to denote no banner.

        Returns
        -------
        :class:`ClientUser`
            The newly edited client user.

        Raises
        ------
        HTTPException
            Editing your profile failed.
        InvalidArgument
            Wrong image format passed for ``avatar`` or ``banner``.
        rW   NrX   rY   r   )r   r   r4   httpedit_profiler   )r<   rW   rX   rY   payloadr>   s         r(   editzClientUser.edit  s     b #%7""*GJ> $GH7" 5f =GH> $GH7" 5f =GH"&++"2"2"?"?"HH$77 Is   A4B6B7Br=   r   r>   r   r   r   r   r   )rW   r5   rX   bytesrY   r   r   r   )r"   r#   r$   __doc__r%   r   r&   r?   rI   r;   r   r   __classcell__r   s   @r(   r   r   S  sv    0d OI1
&:  @8 @8 	@8
 @8 
@8r'   r   c                       e Zd ZdZdZd fdZddZddZed fd       Z	ddZ
edd       Zedd	       Zdd
ZddZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZ xZS )r   a  Represents a Discord user.

    .. container:: operations

        .. describe:: x == y

            Checks if two users are equal.

        .. describe:: x != y

            Checks if two users are not equal.

        .. describe:: hash(x)

            Return the user's hash.

        .. describe:: str(x)

            Returns the user's name with discriminator or global_name.

    Attributes
    ----------
    name: :class:`str`
        The user's username.
    id: :class:`int`
        The user's unique ID.
    discriminator: :class:`str`
        The user's discriminator. This is given when the username has conflicts.

        .. note::

            If the user has migrated to the new username system, this will always be "0".
    global_name: :class:`str`
        The user's global name.

        .. versionadded:: 2.5
    bot: :class:`bool`
        Specifies if the user is a bot account.
    system: :class:`bool`
        Specifies if the user is a system user (i.e. represents Discord officially).
    )_storedc               6    t         |   ||       d| _        y )Nr   F)r   r?   r   r   s      r(   r?   zUser.__init__  s    u40"r'   c           	     b   | j                   rm| j                  7d| j                   d| j                  d| j                  d| j                   d	S d| j                   d| j                  d| j                   dS d| j                   d| j                  d| j
                  d| j                   d	S )Nz	<User id=rA   rB   rC   rD   rE   rF   )rG   r,   r!   r*   r0   r+   rH   s    r(   rI   zUser.__repr__!  s    +77):dii]-HXHXG[[`aeaiai`jjkm "$''*TYYMtxxjPQRR77)6$))od>P>P=SSXY]YaYaXbbce	
r'   c                    	 | j                   r&| j                  j                  | j                         y y # t        $ r Y y w xY wr:   )r   r4   
deref_userr!   	ExceptionrH   s    r(   __del__zUser.__del__.  s;    	||&&tww/  		s   15 	A Ac                4    t         |   |      }d|_        |S )NF)r   rb   r   )r`   ra   r<   r   s      r(   rb   z
User._copy5  s    w}T"r'   c                B   K   | j                          d {   }|S 7 wr:   )	create_dm)r<   chs     r(   _get_channelzUser._get_channel;  s     >>##	 $s   c                L    | j                   j                  | j                        S )zReturns the channel associated with this user if it exists.

        If this returns ``None``, you can create a DM channel by calling the
        :meth:`create_dm` coroutine function.
        )r4   _get_private_channel_by_userr!   rH   s    r(   
dm_channelzUser.dm_channel?  s     {{77@@r'   c                    | j                   j                  j                         D cg c]   }|j                  | j                        s|" c}S c c}w )zThe guilds that the user shares with the client.

        .. note::

            This will only return mutual guilds within the client's internal cache.

        .. versionadded:: 1.7
        )r4   _guildsvalues
get_memberr!   )r<   guilds     r(   mutual_guildszUser.mutual_guildsH  sH      ${{2299;
u?O?OPTPWPW?XE
 	
 
s    AAc                   K   | j                   }||S | j                  }|j                  j                  | j                         d{   }|j                  |      S 7 w)a
  |coro|

        Creates a :class:`DMChannel` with this user.

        This should be rarely called, as this is done transparently for most
        people.

        Returns
        -------
        :class:`.DMChannel`
            The channel that was created.
        N)r   r4   r   start_private_messager!   add_dm_channel)r<   foundr=   r>   s       r(   r   zUser.create_dmV  sW      L',zz'G'G'P!P##D)) "Qs   AAAAc                   K   |j                   | j                   dd}| j                  j                  j                  | j                   |       d{   }t	        || j                        S 7 w)a!  |coro|

        Creates a test entitlement for the user.

        Parameters
        ----------
        sku: :class:`Snowflake`
            The SKU to create a test entitlement for.

        Returns
        -------
        :class:`Entitlement`
            The created entitlement.
           )sku_idowner_id
owner_typeN)r>   r=   )r!   r4   r   create_test_entitlementr   )r<   skur   r>   s       r(   r   zUser.create_test_entitlementk  s\       ff

 [[%%==dggwOODKK88 Ps   AA.A,A.c           	         t        | j                  |r|D cg c]  }|j                   c}nd|||| j                  |      S c c}w )a  Returns an :class:`.AsyncIterator` that enables fetching the user's entitlements.

        This is identical to :meth:`Client.entitlements` with the ``user`` parameter.

        .. versionadded:: 2.6

        Parameters
        ----------
        skus: list[:class:`.abc.Snowflake`] | None
            Limit the fetched entitlements to entitlements that are for these SKUs.
        before: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None
            Retrieves guilds before this date or object.
            If a datetime is provided, it is recommended to use a UTC-aware datetime.
            If the datetime is naive, it is assumed to be local time.
        after: :class:`.abc.Snowflake` | :class:`datetime.datetime` | None
            Retrieve guilds after this date or object.
            If a datetime is provided, it is recommended to use a UTC-aware datetime.
            If the datetime is naive, it is assumed to be local time.
        limit: Optional[:class:`int`]
            The number of entitlements to retrieve.
            If ``None``, retrieves every entitlement, which may be slow.
            Defaults to ``100``.
        exclude_ended: :class:`bool`
            Whether to limit the fetched entitlements to those that have not ended.
            Defaults to ``False``.

        Yields
        ------
        :class:`.Entitlement`
            The application's entitlements.

        Raises
        ------
        :exc:`HTTPException`
            Retrieving the entitlements failed.
        N)sku_idsbeforeafterlimituser_idexclude_ended)r   r4   r!   )r<   skusr   r   r   r   r   s          r(   entitlementszUser.entitlements  sE    X #KK04t,SVV,$GG'
 	
,s   A
r   r   )r   r   )ra   r   )r   r   )r   zDMChannel | None)r   zlist[Guild])r   zdiscord.abc.Snowflaker   r   )NNNd   F)r   zlist[Snowflake] | Noner   SnowflakeTime | Noner   r   r   r8   r   r7   r   r   )r"   r#   r$   r   r%   r?   rI   r   r   rb   r   r   r   r   r   r   r   r   r   s   @r(   r   r     s    (T I#
  
 A A 
 
**92 (,'+&*#4
$4
 %4
 $	4

 4
 4
 
4
r'   r   )0r   
__future__r   typingr   r   r   discord.abcdiscordrw   r   r   r	   r   r
   	iteratorsr   monetizationr   utilsr   r   r   r   abcr   r   channelr   r   r   r   r   r=   r   types.channelDMChannelPayload
types.userr   PartialUserPayloadr   r   __all__r   r   r   r   Messageabler   r'   r(   <module>r      s   2 # . .    " * % A A!-" &<=/
 T$ 
O)x O)dZ8 Z8zF
8W[[,, F
r'   