
    i                    x   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	m
Z
mZmZmZmZmZmZ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mZ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e/          Z0ervddl1m2Z2 ddl3m4Z4m5Z5m6Z6 ddl*m7Z7 ddl8m9Z9 ddl:m;Z; ddl,m<Z< ddl=m>Z?m@ZAmBZC ddlDmEZE ddlFmZGmHZH ddlImJZJ ddlKmLZL dd lMmNZN dd!lOmPZP dd"lQmRZSmTZU dd#lVmWZW dd$lXmYZY ee5e6f         ZZ G d% d&          ZTd,d)Z[e[ G d* d+ejI        j\        e                      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.
    )annotationsN)
attrgetter)Any	AwaitableCallable
CollectionDictListOptionalTYPE_CHECKINGTupleTypeVarUnion   )utils)Asset)MISSING)BaseUser
ClientUserUser_UserTag)Permissions)Status)ClientException)Colour)Object)MemberFlags)ClientStatus)
VoiceStateMemberT)bound)Self)	DMChannelVoiceChannelStageChannel)PublicUserFlags)Guild)ActivityTypes)RawPresenceUpdateEvent)MemberWithUserr    UserWithMember)GuildMemberUpdateEvent)r   AvatarDecorationData)	Snowflake)ConnectionState)Message)Role)GuildVoiceStater   )PrimaryGuild)Collectiblec                  4    e Zd ZdZdZdddd	Zdd
ZddZdS )r   a  Represents a Discord user's voice state.

    Attributes
    ------------
    deaf: :class:`bool`
        Indicates if the user is currently deafened by the guild.
    mute: :class:`bool`
        Indicates if the user is currently muted by the guild.
    self_mute: :class:`bool`
        Indicates if the user is currently muted by their own accord.
    self_deaf: :class:`bool`
        Indicates if the user is currently deafened by their own accord.
    self_stream: :class:`bool`
        Indicates if the user is currently streaming via 'Go Live' feature.

        .. versionadded:: 1.3

    self_video: :class:`bool`
        Indicates if the user is currently broadcasting video.
    suppress: :class:`bool`
        Indicates if the user is suppressed from speaking.

        Only applies to stage channels.

        .. versionadded:: 1.7

    requested_to_speak_at: Optional[:class:`datetime.datetime`]
        An aware datetime object that specifies the date and time in UTC that the member
        requested to speak. It will be ``None`` if they are not requesting to speak
        anymore or have been accepted to speak.

        Only applicable to stage channels.

        .. versionadded:: 1.7

    afk: :class:`bool`
        Indicates if the user is currently in the AFK channel in the guild.
    channel: Optional[Union[:class:`VoiceChannel`, :class:`StageChannel`]]
        The voice channel that the user is currently connected to. ``None`` if the user
        is not currently in a voice channel.
    )
session_iddeafmute	self_muteself_stream
self_video	self_deafafkchannelrequested_to_speak_atsuppressN)r?   data0Union[VoiceStatePayload, GuildVoiceStatePayload]r?   Optional[VocalGuildChannel]c               f    |                     d          | _        |                     ||           d S )Nr7   )getr7   _updateselfrB   r?   s      U/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/member.py__init__zVoiceState.__init__   s1     *.,)?)?T7#####    c                   |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        |                     dd          | _        t          j
        |                     d	                    | _        || _        d S )
Nr:   Fr=   r;   r<   rA   r9   r8   request_to_speak_timestamp)rF   r:   r=   r;   r<   r>   r9   r8   rA   r   
parse_timer@   r?   rH   s      rJ   rG   zVoiceState._update   s    #xxU;;#xxU;;!%-!?!? $u = =*e44((6511	((6511	"hhz599BGBRSWS[S[\xSySyBzBz"4;rL   returnstrc                    d| j         fd| j        fd| j        fd| j        fd| j        fd| j        fg}d                    d |D                       }d	| j        j         d| d
S )Nr:   r=   r;   rA   r@   r?    c              3      K   | ]	}d |z  V  
dS )z%s=%rN ).0ts     rJ   	<genexpr>z&VoiceState.__repr__.<locals>.<genexpr>   s&      441444444rL   <>)	r:   r=   r;   rA   r@   r?   join	__class____name__)rI   attrsinners      rJ   __repr__zVoiceState.__repr__   s    $.)$.)D,-'$d&@A%
 44e4444454>*55U5555rL   )rB   rC   r?   rD   rP   rQ   )r]   
__module____qualname____doc__	__slots__rK   rG   r`   rU   rL   rJ   r   r   S   ss        ( (TI qu$ $ $ $ $ $
< 
< 
< 
<
6 
6 
6 
6 
6 
6rL   r   clsrP   c                   t          j        t          j                                        t
          j                                                  D ]\  }|                    d          r|| j        v r%t          d          s7t          d|z             }t          | |t          |d| d                     lfd} ||          } t          j                  |          }t          | ||           | S )N___annotations__z_user.zEquivalent to :attr:`User.`)docc                V     t          j                  r fd}n fd} |_        |S )Nc                J   K    t          | j                  |i | d {V S Ngetattr_userrI   argskwargsxs      rJ   generalz8flatten_user.<locals>.generate_function.<locals>.general   s:      %;WTZ%;%;T%LV%L%LLLLLLLLrL   c                :     t          | j                  |i |S rn   ro   rr   s      rJ   rv   z8flatten_user.<locals>.generate_function.<locals>.general   s$    5wtz155tFvFFFrL   )inspectiscoroutinefunctionr]   )ru   rv   values   ` rJ   generate_functionz'flatten_user.<locals>.generate_function   si    .u55 GM M M M M M
G G G G G $% rL   )	itertoolschainr   __dict__itemsr   
startswithhasattrr   setattrpropertyr   copy_doc)rf   attrgetterr{   funcrz   s        @rJ   flatten_userr      s    x'8'>'>'@'@$-BUBUBWBWXX $% $%e??3 	 3< u/00 	%400FCx4XQU4X4X4XYYYZZZZ     %$T**D(5>%((..DCt$$$$JrL   c                  t   e Zd ZU dZdZerdd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ed<   ded<   ded<   ded<   ded<   d ed!<   d"ed#<   d$ed%<   dd,Zdd.Zdd/Z	dd2Z
dd3Zdd4Zedd9            Zedd<            Zdd>ZeddA            ZeddC            ZddEZddGZddLZddMZeddO            ZeddP            Zej        ddR            ZeddS            ZeddT            ZeddU            ZddVZeddX            ZeddY            Z edd[            Z!edd]            Z"edd^            Z#edd_            Z$edd`            Z%edda            Z&eddb            Z'eddc            Z(edde            Z)ddfZ*eddh            Z+eddj            Z,eddl            Z-eddn            Z.eddp            Z/e0e0dqdrddvZ1dqdwddxZ2dqdwddyZ3e0e0e0e0e0e0e0e0e0e0e0dqdzddZ4ddZ5dqdwddZ6dqdwddZ7dqddddZ8dqddddZ9ddZ:ddZ;ddZ<dqS )r    a4	  Represents a Discord member to a :class:`Guild`.

    This implements a lot of the functionality of :class:`User`.

    .. container:: operations

        .. describe:: x == y

            Checks if two members are equal.
            Note that this works with :class:`User` instances too.

        .. describe:: x != y

            Checks if two members are not equal.
            Note that this works with :class:`User` instances too.

        .. describe:: hash(x)

            Returns the member's hash.

        .. describe:: str(x)

            Returns the member's handle (e.g. ``name`` or ``name#discriminator``).

    Attributes
    ----------
    joined_at: Optional[:class:`datetime.datetime`]
        An aware datetime object that specifies the date and time in UTC that the member joined the guild.
        If the member left and rejoined the guild, this will be the latest date.
        This can be ``None``, such as when the member is a guest.
    activities: Tuple[Union[:class:`BaseActivity`, :class:`Spotify`]]
        The activities that the user is currently doing.

        .. note::

            Due to a Discord API limitation, a user's Spotify activity may not appear
            if they are listening to a song with a title longer
            than 128 characters. See :issue:`1738` for more information.

    guild: :class:`Guild`
        The guild that the member belongs to.
    nick: Optional[:class:`str`]
        The guild specific nickname of the user. Takes precedence over the global name.
    pending: :class:`bool`
        Whether the member is pending member verification.

        .. versionadded:: 1.6
    premium_since: Optional[:class:`datetime.datetime`]
        An aware datetime object that specifies the date and time in UTC when the member used their
        "Nitro boost" on the guild, if available. This could be ``None``.
    timed_out_until: Optional[:class:`datetime.datetime`]
        An aware datetime object that specifies the date and time in UTC that the member's time out will expire.
        This will be set to ``None`` or a time in the past if the user is not timed out.

        .. versionadded:: 2.0
    client_status: :class:`ClientStatus`
        Model which holds information about the status of the member on various clients/platforms via presence updates.

        .. versionadded:: 2.5
    )_roles	joined_atpremium_since
activitiesguildpendingnicktimed_out_until_permissionsclient_statusrq   _state_avatar_banner_flags_avatar_decoration_datarQ   nameintiddiscriminatorOptional[str]global_nameboolbotsystemzdatetime.datetime
created_atr   default_avatarOptional[Asset]avatarzOptional[DMChannel]
dm_channelz"Callable[[], Awaitable[DMChannel]]	create_dmzList[Guild]mutual_guildsr'   public_flagsbannerzOptional[Colour]accent_coloraccent_colouravatar_decorationzOptional[int]avatar_decoration_sku_idr4   primary_guildzList[Collectible]collectiblesrB   MemberWithUserPayloadr   r(   stater0   c                  || _         |                    |d                   | _        || _        t	          j        |                    d                    | _        t	          j        |                    d                    | _        t	          j	        t          t          |d                             | _        t                      | _        d| _        |                    dd           | _        |                    dd          | _        |                    d	          | _        |                    d
          | _        |  |d         | _        |                    d          | _        	 t          |d                   | _        n# t.          $ r
 d | _        Y nw xY wt	          j        |                    d                    | _        d S )Nuserr   r   rolesrU   r   r   Fr   r   flagsavatar_decoration_datapermissionscommunication_disabled_until)r   
store_userrq   r   r   rO   rF   r   r   SnowflakeListmapr   r   r   r   r   r   r   r   r   r   r   r   KeyErrorr   )rI   rB   r   r   s       rJ   rK   zMember.__init__=  s   ', ++DL99
!
6;6FtxxP[G\G\6]6]:?:J488TcKdKd:e:e+0+>s3W?V?V+W+W+7>>57#'88FD#9#9	!XXi77&*hhx&8&8&*hhx&8&8(=GKxxPhGiGi$	% #D$7 8 8D 	% 	% 	% $D	% =B<LTXXVtMuMu<v<vs   'F FFrP   c                *    t          | j                  S rn   )rQ   rq   rI   s    rJ   __str__zMember.__str__T  s    4:rL   c                    d| j         j         d| j         j        d| j         j        d| j         j         d| j        d| j        dS )Nz<Member id=z name=z global_name=z bot=z nick=z guild=rZ   )rq   r   r   r   r   r   r   r   s    rJ   r`   zMember.__repr__W  s    N$*- N Ntz N NtzOe N NJNN N*.)N N>BjN N N	
rL   otherobjectc                L    t          |t                    o|j        | j        k    S rn   )
isinstancer   r   rI   r   s     rJ   __eq__zMember.__eq__]  s     %**Bux47/BBrL   c                .    |                      |           S rn   )r   r   s     rJ   __ne__zMember.__ne__`  s    ;;u%%%%rL   c                *    t          | j                  S rn   )hashrq   r   s    rJ   __hash__zMember.__hash__c  s    DJrL   messager1   MemberPayloadr#   c               n    |j         }|                                |d<    | ||j        |j                  S )Nr   rB   r   r   )author_to_minimal_user_jsonr   r   )rf   r   rB   r   s       rJ   _from_messagezMember._from_messagef  s9    3355VsGMHHHHrL   r   r   c               N    g |                                 dd} | |||          S )Nr   )r   r   r   r   )r   )rf   r   r   r   rB   s        rJ   _from_client_userzMember._from_client_userl  s>     ..00
 

 sE7777rL   Nonec                   t          j        |                    d                    | _        t          j        |                    d                    | _        t          j        t          t          |d                             | _        |                    dd           | _	        |                    dd          | _
        t          j        |                    d                    | _        |                    dd	          | _        d S )
Nr   r   r   r   r   Fr   r   r   )r   rO   rF   r   r   r   r   r   r   r   r   r   r   rI   rB   s     rJ   _update_from_messagezMember._update_from_messageu  s    )$((;*?*?@@"-dhh.G.GHH)#c4=*A*ABBHHVT**	xx	511$/9W0X0XYYhhw**rL   UserWithMemberPayloadUnion[User, Self]c                   	 |                     d          }||d<    | |||          S # t          $ r |                    |          cY S w xY w)Nmemberr   r   )popr   create_user)rf   rB   r   r   member_datas        rJ   _try_upgradezMember._try_upgrade~  ss    	C((8,,K #'K3KuEBBBB	  	+ 	+ 	+$$T*****	+s   * AAr   c                   |                      |           }t          j        |j        d          |_        |j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |j	        |_	        |j
        |_
        |j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |j        |_        |S )NT)	is_sorted)__new__r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   )rf   r   rI   s      rJ   _copyzMember._copy  s    {{3)&-4HHH)#1#1\
K	~ +%5m"/m~~'-'E$ \
rL   r$   c                >   K   |                                   d {V }|S rn   )r   )rI   chs     rJ   _get_channelzMember._get_channel  s,      >>########	rL   r-   c                h   	 |d         | _         n# t          $ r Y nw xY w	 |d         | _        n# t          $ r Y nw xY wt          j        |                    d                    | _        t          j        |                    d                    | _        t          j        t          t          |d                             | _        |                    d          | _        |                    d          | _        |                    dd	          | _        |                    d
          | _        d S )Nr   r   r   r   r   r   r   r   r   r   )r   r   r   r   rO   rF   r   r   r   r   r   r   r   r   r   r   r   s     rJ   rG   zMember._update  s   	VDII 	 	 	D			?DLL 	 	 	D	 #-dhh.G.GHH$/9W0X0XYY)#c4=*A*ABBxx))xx))hhw**'+xx0H'I'I$$$s    
/ 
<<rawr*   UserPayloadOptional[Tuple[User, User]]c                    |j         | _         |j        | _        t          |          dk    r|                     |          S d S )Nr   )r   r   len_update_inner_user)rI   r   r   s      rJ   _presence_updatezMember._presence_update  s@    . .t99q==**4000 =rL   c                   | j         }|j        |j        |j        |j        |j        |j        |j        d         nd |j        f}|                    d          }|                    dd           }|d         |d         |d         |                    d          |                    dd	          ||d         nd |f}||k    rt          j
        | j                   }|d         |d         |d         |                    d          |                    dd	          ||f\  |_        |_        |_        |_        |_        |_        |_        ||fS d S )
Nsku_idr   r   usernamer   r   r   r   r   )rq   r   r   r   r   _public_flagsr   _primary_guildrF   r   r   )rI   r   uoriginaldecoration_payloadprimary_guild_payloadmodified	to_returns           rJ   r   zMember._update_inner_user  sh   JFOIMO343L3XA%h//^b
 "XX&>?? $$ ? ? !NHH]##HH^Q'',>,Jx((PT!
 x
4:..I Z _%X''++"%	)  a<)  rL   r   c                    | j         j        S )zn:class:`Status`: The member's overall status. If the value is unknown, then it will be a :class:`str` instead.)r   statusr   s    rJ   r   zMember.status  s     !((rL   c                    | j         j        S )zd:class:`str`: The member's overall status as a string value.

        .. versionadded:: 1.5
        )r   _statusr   s    rJ   
raw_statuszMember.raw_status  s     !))rL   rz   c                8    t          |          | j        _        d S rn   )rQ   r   r   )rI   rz   s     rJ   r   zMember.status  s     &)ZZ"""rL   c                    | j         j        S )zG:class:`Status`: The member's status on a mobile device, if applicable.)r   mobile_statusr   s    rJ   r  zMember.mobile_status  s     !//rL   c                    | j         j        S )zJ:class:`Status`: The member's status on the desktop client, if applicable.)r   desktop_statusr   s    rJ   r  zMember.desktop_status  s     !00rL   c                    | j         j        S )zF:class:`Status`: The member's status on the web client, if applicable.)r   
web_statusr   s    rJ   r  zMember.web_status  s     !,,rL   c                4    | j                                         S )zA helper function that determines if a member is active on a mobile device.

        Returns
        -------
        :class:`bool`
        )r   is_on_mobiler   s    rJ   r	  zMember.is_on_mobile  s     !..000rL   r   c                    | j         dd         }t          |          D ]}|j        j        r	|j        c S t	          j                    S )a  :class:`Colour`: A property that returns a colour denoting the rendered colour
        for the member. If the default colour is the one rendered then an instance
        of :meth:`Colour.default` is returned.

        There is an alias for this named :attr:`color`.
        r   N)r   reversedcolourrz   r   default)rI   r   roles      rJ   r  zMember.colour  sX     
122
 UOO 	# 	#D{  #{"""#~rL   c                    | j         S )a  :class:`Colour`: A property that returns a color denoting the rendered color for
        the member. If the default color is the one rendered then an instance of :meth:`Colour.default`
        is returned.

        There is an alias for this named :attr:`colour`.
        )r  r   s    rJ   colorzMember.color-  s     {rL   
List[Role]c                    g }| j         }| j        D ].}|                    |          }|r|                    |           /|j        }|r|                    |           |                                 |S )a  List[:class:`Role`]: A :class:`list` of :class:`Role` that the member belongs to. Note
        that the first element of this list is always the default '@everyone'
        role.

        These roles are sorted by their position in the role hierarchy.
        )r   r   get_roleappenddefault_rolesort)rI   resultgrole_idr  r  s         rJ   r   zMember.roles7  s     J{ 	$ 	$G::g&&D $d###~ 	(MM,'''rL   Optional[Union[str, Asset]]c                b    | j         dd         }t          |          D ]}|j        }|r|c S dS )zOptional[Union[:class:`str`, :class:`Asset`]]: A property that returns the role icon that is rendered for
        this member. If no icon is shown then ``None`` is returned.

        .. versionadded:: 2.0
        r   N)r   r  display_icon)rI   r   r  icons       rJ   r  zMember.display_iconK  sM     
122UOO 	 	D$D  trL   c                "    d| j         j         dS )zE:class:`str`: Returns a string that allows you to mention the member.z<@rZ   )rq   r   r   s    rJ   mentionzMember.mention[  s     %DJM$$$$rL   c                ,    | j         p| j        p| j        S )z:class:`str`: Returns the user's display name.

        For regular users this is just their global name or their username,
        but if they have a guild specific nickname then that
        is returned instead.
        )r   r   r   r   s    rJ   display_namezMember.display_name`  s     y9D,9	9rL   c                @    | j         p| j        j        p| j        j        S )z:class:`Asset`: Returns the member's display avatar.

        For regular members this is just their avatar, but
        if they have a guild specific avatar then that
        is returned instead.

        .. versionadded:: 2.0
        )guild_avatarrq   r   r   r   s    rJ   display_avatarzMember.display_avatarj  s!      RDJ$5R9RRrL   c                t    | j         dS t          j        | j        | j        j        | j        | j                   S )zOptional[:class:`Asset`]: Returns an :class:`Asset` for the guild avatar
        the member has. If unavailable, ``None`` is returned.

        .. versionadded:: 2.0
        N)r   r   _from_guild_avatarr   r   r   r   s    rJ   r#  zMember.guild_avatarv  2     <4'TZ]DGT\ZZZrL   c                (    | j         p| j        j        S )a  Optional[:class:`Asset`]: Returns the member's displayed banner, if any.

        This is the member's guild banner if available, otherwise it's their
        global banner. If the member has no banner set then ``None`` is returned.

        .. versionadded:: 2.5
        )guild_bannerrq   r   r   s    rJ   display_bannerzMember.display_banner  s      5DJ$55rL   c                t    | j         dS t          j        | j        | j        j        | j        | j                   S )zOptional[:class:`Asset`]: Returns an :class:`Asset` for the guild banner
        the member has. If unavailable, ``None`` is returned.

        .. versionadded:: 2.5
        N)r   r   _from_guild_bannerr   r   r   r   s    rJ   r)  zMember.guild_banner  r'  rL   Optional[ActivityTypes]c                .    | j         r| j         d         S dS )a  Optional[Union[:class:`BaseActivity`, :class:`Spotify`]]: Returns the primary
        activity the user is currently doing. Could be ``None`` if no activity is being done.

        .. note::

            Due to a Discord API limitation, this may be ``None`` if
            the user is listening to a song on Spotify with a title longer
            than 128 characters. See :issue:`1738` for more information.

        .. note::

            A user may have multiple activities, these can be accessed under :attr:`activities`.
        r   N)r   r   s    rJ   activityzMember.activity  s%     ? 	&?1%%	& 	&rL   c                     |j         |j         j         j         j        k    rdS  j                            |          rdS t	           fd|j        D                       S )a?  Checks if the member 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 member is mentioned in the message.
        NFTc              3  V   K   | ]#}j                             |j                  V  $d S rn   )r   hasr   )rV   r  rI   s     rJ   rX   z&Member.mentioned_in.<locals>.<genexpr>  s3      NN4;??47++NNNNNNrL   )r   r   rq   mentioned_inanyrole_mentions)rI   r   s   ` rJ   r3  zMember.mentioned_in  sh     = GM$4
$E$E5:""7++ 	4NNNN8MNNNNNNrL   r2   c                    | j         t          | j                  dk    rj        S t	          fd| j        D                       S )z:class:`Role`: Returns the member's highest role.

        This is useful for figuring where a member stands in the role
        hierarchy chain.
        r   c              3  P   K   | ] }                     |          pj        V  !d S rn   )r  r  )rV   ridr   s     rJ   rX   z"Member.top_role.<locals>.<genexpr>  s7      TT5>>#&&<%*<TTTTTTrL   )r   r   r   r  max)rI   r   s    @rJ   top_rolezMember.top_role  sO     
t{q  %%TTTTTTTTTTrL   r   c                b   | j         j        | j        k    rt          j                    S t          j                    }| j        D ]}|xj        |j        j        z  c_        |j	        rt          j                    S | 
                                r!|xj        t          j                    z  c_        |S )a7  :class:`Permissions`: Returns the member's guild permissions.

        This only takes into consideration the guild permissions
        and not most of the implied permissions or any of the
        channel permission overwrites. For 100% accurate permission
        calculation, please use :meth:`abc.GuildChannel.permissions_for`.

        This does take into consideration guild ownership, the
        administrator implication, and whether the member is timed out.

        .. versionchanged:: 2.0
            Member timeouts are taken into consideration.
        )r   owner_idr   r   allnoner   rz   r   administratoris_timed_out_timeout_mask)rI   basers      rJ   guild_permissionszMember.guild_permissions  s      :$'))?$$$!! 	. 	.AJJ!---JJJ 	%?$$$ 	6JJ+3555JJrL   Optional[Permissions]c                <    | j         dS t          | j                   S )a  Optional[:class:`Permissions`]: Returns the member's resolved permissions
        from an interaction.

        This is only available in interaction contexts and represents the resolved
        permissions of the member in the channel the interaction was executed in.
        This is more or less equivalent to calling :meth:`abc.GuildChannel.permissions_for`
        but stored and returned as an attribute by the Discord API rather than computed.

        .. versionadded:: 2.0
        N)r   r   r   s    rJ   resolved_permissionszMember.resolved_permissions  s#     $44,---rL   Optional[VoiceState]c                J    | j                             | j        j                  S )zHOptional[:class:`VoiceState`]: Returns the member's current voice state.)r   _voice_state_forrq   r   r   s    rJ   voicezMember.voice  s     z**4:=999rL   r   c                4    t          j        | j                  S )zY:class:`MemberFlags`: Returns the member's flags.

        .. versionadded:: 2.2
        )r   _from_valuer   r   s    rJ   r   zMember.flags  s     &t{333rL   N)delete_message_daysdelete_message_secondsreasonrN  rO  rP  c               R   K   | j                             | |||           d{V  dS )zK|coro|

        Bans this member. Equivalent to :meth:`Guild.ban`.
        )rP  rN  rO  N)r   ban)rI   rN  rO  rP  s       rJ   rR  z
Member.ban  sY       jnn 3#9	  
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
rL   rP  c               N   K   | j                             | |           d{V  dS )zO|coro|

        Unbans this member. Equivalent to :meth:`Guild.unban`.
        rS  N)r   unbanrI   rP  s     rJ   rU  zMember.unban  s;      
 jtF33333333333rL   c               N   K   | j                             | |           d{V  dS )zM|coro|

        Kicks this member. Equivalent to :meth:`Guild.kick`.
        rS  N)r   kickrV  s     rJ   rX  zMember.kick   s8      
 jood6o22222222222rL   )r   r9   deafenrA   r   voice_channelr   bypass_verificationr   r   biorP  r   r9   rY  rA   r   !Collection[discord.abc.Snowflake]rZ  rD   r   Optional[datetime.datetime]r[  Optional[bytes]r\  Optional[Member]c               ,  K   | j         j        }| j        j        }| j         j        | j        k    }i }i }|t
          ur|pd}|r||d<   n||d<   |	t
          ur|	d|d<   nt          j        |	          |d<   |
t
          ur|
d|d<   nt          j        |
          |d<   |t
          ur|pd|d<   |s|rt          d          |t
          ur||d<   |t
          ur||d	<   |t
          urd
|i}| j	         | j	        j
        | j	        j
        j        |d<   |s| j        rd|d<   |r|                    ||           d{V  nW|s3t          j                                                                        |d<   |                    || j        |           d{V  |t
          ur|o|j        |d<   |t
          urt#          d |D                       |d<   |t
          ur5|d|d<   n-|j        t'          d          |                                |d<   |t
          ur*t)          j        | j                  }||_        |j        |d<   |r |j        || j        fd|i| d{V }n|r |j        |fd|i| d{V }ndS t7          || j        | j                   S )al  |coro|

        Edits the member's data.

        .. 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()``.

        Depending on the parameter passed, this requires different permissions listed below:

        +---------------------+---------------------------------------+
        |      Parameter      |              Permission               |
        +---------------------+---------------------------------------+
        | nick                | :attr:`Permissions.manage_nicknames`  |
        +---------------------+---------------------------------------+
        | mute                | :attr:`Permissions.mute_members`      |
        +---------------------+---------------------------------------+
        | deafen              | :attr:`Permissions.deafen_members`    |
        +---------------------+---------------------------------------+
        | roles               | :attr:`Permissions.manage_roles`      |
        +---------------------+---------------------------------------+
        | voice_channel       | :attr:`Permissions.move_members`      |
        +---------------------+---------------------------------------+
        | timed_out_until     | :attr:`Permissions.moderate_members`  |
        +---------------------+---------------------------------------+
        | bypass_verification | :attr:`Permissions.moderate_members`  |
        +---------------------+---------------------------------------+

        All parameters are optional.

        .. versionchanged:: 1.1
            Can now pass ``None`` to ``voice_channel`` to kick a member from voice.

        .. versionchanged:: 2.0
            The newly updated member is now optionally returned, if applicable.

        Parameters
        -----------
        nick: Optional[:class:`str`]
            The member's new nickname. Use ``None`` to remove the nickname.
        mute: :class:`bool`
            Indicates if the member should be guild muted or un-muted.
        deafen: :class:`bool`
            Indicates if the member should be guild deafened or un-deafened.
        suppress: :class:`bool`
            Indicates if the member should be suppressed in stage channels.

            .. versionadded:: 1.7

        roles: List[:class:`Role`]
            The member's new list of roles. This *replaces* the roles.
        voice_channel: Optional[Union[:class:`VoiceChannel`, :class:`StageChannel`]]
            The voice channel to move the member to.
            Pass ``None`` to kick them from voice.
        timed_out_until: Optional[:class:`datetime.datetime`]
            The date the member's timeout should expire, or ``None`` to remove the timeout.
            This must be a timezone-aware datetime object. Consider using :func:`utils.utcnow`.

            .. versionadded:: 2.0
        bypass_verification: :class:`bool`
            Indicates if the member should be allowed to bypass the guild verification requirements.

            .. versionadded:: 2.2
        avatar: Optional[:class:`bytes`]
            A :term:`py:bytes-like object` representing the image to upload. Could be ``None`` to denote no avatar.
            Only image formats supported for uploading are JPEG, PNG, GIF, and WEBP.
            This can only be set when editing the bot's own member.

            .. versionadded:: 2.7
        banner: Optional[:class:`bytes`]
            A :term:`py:bytes-like object` representing the image to upload. Could be ``None`` to denote no banner.
            Only image formats supported for uploading are JPEG, PNG, GIF and WEBP..
            This can only be set when editing the bot's own member.

            .. versionadded:: 2.7
        bio: Optional[:class:`str`]
            The new bio for the member. Use ``None`` to remove the bio.
            This can only be set when editing the bot's own member.

            .. versionadded:: 2.7

        reason: Optional[:class:`str`]
            The reason for editing this member. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have the proper permissions to do the action requested.
        HTTPException
            The operation failed.
        TypeError
            The datetime object passed to ``timed_out_until`` was not timezone-aware.
        ValueError
            You tried to edit the bio, avatar or banner of a member that is not the bot's own member.
            Or the wrong image format passed for ``avatar`` or ``banner``.

        Returns
        --------
        Optional[:class:`.Member`]
            The newly updated member, if applicable. This is not returned
            if certain fields are passed, such as ``suppress``.
         r   Nr   r   r\  zCEditing the bio, avatar or banner is only for the bot's own member.r8   r9   rA   
channel_idrN   c              3  $   K   | ]}|j         V  d S rn   r   rV   rC  s     rJ   rX   zMember.edit.<locals>.<genexpr>  s$      $9$9aQT$9$9$9$9$9$9rL   r   r   ztimed_out_until must be an aware datetime. Consider using discord.utils.utcnow() or datetime.datetime.now().astimezone() for local time.r   rP  r   )r   httpr   r   self_idr   r   _bytes_to_base64_data
ValueErrorrK  r?   r   edit_my_voice_statedatetimeutcnow	isoformatedit_voice_statetupletzinfo	TypeErrorr   rM  r   bypasses_verificationrz   edit_memberedit_my_memberr    )rI   r   r9   rY  rA   r   rZ  r   r[  r   r   r\  rP  rg  guild_idmepayloadself_payloadvoice_state_payloadr   rB   s                        rJ   editzMember.edit'  s     r {:=[ DG+"$')w:2D ''+V$$"&  ~)-X&&).)DV)L)LX&  ~)-X&&).)DV)L)LX&g"%)L 	dl 	dbccc  $GFOw"GFO7""H3 z%$**<*H48J4F4I#L1 I48 IDH#$@A T..x9LMMMMMMMMMM oHPHYH`H`HbHbHlHlHnHn'(DE++Hdg?RSSSSSSSSS''$1$Fm6FGL!$$9$95$9$9$999GG'))&:>677")1# c   ;J:S:S:U:U67g--+DK88E*=E'${GG 	))(DGVVFVgVVVVVVVVDD 	,,XUUfUUUUUUUUUDD44tzEEEErL   c                  K   | j         | j         j        t          d          | j         j        j        t          j                                                                        d}| j        j        | j        k    r=d|d<   | j        j	        
                    | j        j        | j        |           d{V  dS | j        j	                            | j        j        |           d{V  dS )a-  |coro|

        Request to speak in the connected channel.

        Only applies to stage channels.

        .. note::

            Requesting members that are not the client is equivalent
            to :attr:`.edit` providing ``suppress`` as ``False``.

        .. versionadded:: 1.7

        Raises
        -------
        ClientException
            You are not connected to a voice channel.
        Forbidden
            You do not have the proper permissions to do the action requested.
        HTTPException
            The operation failed.
        Nz?Cannot request to speak while not connected to a voice channel.)rc  rN   FrA   )rK  r?   r   r   rl  rm  rn  r   rh  rg  ro  r   rk  )rI   rx  s     rJ   request_to_speakzMember.request_to_speak  s      . :!3!;!"cddd *,/*2*;*B*B*D*D*N*N*P*P
 

 ;$'))"'GJ+"33DJM47GTTTTTTTTTTT+"66tz}gNNNNNNNNNNNrL   r?   c               D   K   |                      ||           d{V  dS )a  |coro|

        Moves a member to a new voice channel (they must be connected first).

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

        This raises the same exceptions as :meth:`edit`.

        .. versionchanged:: 1.1
            Can now pass ``None`` to kick a member from voice.

        Parameters
        -----------
        channel: Optional[Union[:class:`VoiceChannel`, :class:`StageChannel`]]
            The new voice channel to move the member to.
            Pass ``None`` to kick them from voice.
        reason: Optional[:class:`str`]
            The reason for doing this action. Shows up on the audit log.
        )rZ  rP  N)r{  )rI   r?   rP  s      rJ   move_tozMember.move_to  s6      ( iigfi===========rL   until6Optional[Union[datetime.timedelta, datetime.datetime]]c              "  K   |d}njt          |t          j                  rt          j                    |z   }n9t          |t          j                  r|}nt          d|j        j                   |                     ||           d{V  dS )a  |coro|

        Applies a time out to a member until the specified date time or for the
        given :class:`datetime.timedelta`.

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

        This raises the same exceptions as :meth:`edit`.

        Parameters
        -----------
        until: Optional[Union[:class:`datetime.timedelta`, :class:`datetime.datetime`]]
            If this is a :class:`datetime.timedelta` then it represents the amount of
            time the member should be timed out for. If this is a :class:`datetime.datetime`
            then it's when the member's timeout should expire. If ``None`` is passed then the
            timeout is removed. Note that the API only allows for timeouts up to 28 days.
        reason: Optional[:class:`str`]
            The reason for doing this action. Shows up on the audit log.

        Raises
        -------
        TypeError
            The ``until`` parameter was the wrong type or the datetime was not timezone-aware.
        Nz<expected None, datetime.datetime, or datetime.timedelta not )r   rP  )	r   rl  	timedeltar   rm  rr  r\   r]   r{  )rI   r  rP  r   s       rJ   timeoutzMember.timeout0  s      8 ="OOx122 	w#lnnu4OOx011 	w#OOu[`[j[suuvvviiiGGGGGGGGGGGrL   T)rP  atomicr/   r  c               ,  K   |sLt          j        d | j        dd         |fD                       }|                     ||           d{V  dS | j        j        j        }| j        j        }| j        }|D ]} ||||j        |           d{V  dS )a  |coro|

        Gives the member a number of :class:`Role`\s.

        You must have :attr:`~Permissions.manage_roles` to
        use this, and the added :class:`Role`\s must appear lower in the list
        of roles than the highest role of the client.

        Parameters
        -----------
        \*roles: :class:`abc.Snowflake`
            An argument list of :class:`abc.Snowflake` representing a :class:`Role`
            to give to the member.
        reason: Optional[:class:`str`]
            The reason for adding these roles. Shows up on the audit log.
        atomic: :class:`bool`
            Whether to atomically add roles. This will ensure that multiple
            operations will always be applied regardless of the current
            state of the cache.

        Raises
        -------
        Forbidden
            You do not have permissions to add these roles.
        HTTPException
            Adding roles failed.
        c              3  J   K   | ]}|D ]}t          |j                   V  dS )re  Nr   r   )rV   srC  s      rJ   rX   z#Member.add_roles.<locals>.<genexpr>u  s;      %b%b!`a%b%b[\fooo%b%b%b%b%b%b%brL   r   Nr   rP  rS  )	r   _uniquer   r{  r   rg  add_roler   r   )	rI   rP  r  r   	new_rolesreqrv  user_idr  s	            rJ   	add_roleszMember.add_rolesW  s      :  	E%b%b
122PU?V%b%b%bbbI)))F);;;;;;;;;;;+"+Cz}HgG E Ec(GTWVDDDDDDDDDDDE ErL   c                 K   |svd | j         dd         D             }|D ];}	 |                    t          |j                             ,# t          $ r Y 8w xY w|                     ||           d{V  dS | j        j        j        }| j	        j        }| j        }|D ]} ||||j        |           d{V  dS )a  |coro|

        Removes :class:`Role`\s from this member.

        You must have :attr:`~Permissions.manage_roles` to
        use this, and the removed :class:`Role`\s must appear lower in the list
        of roles than the highest role of the client.

        Parameters
        -----------
        \*roles: :class:`abc.Snowflake`
            An argument list of :class:`abc.Snowflake` representing a :class:`Role`
            to remove from the member.
        reason: Optional[:class:`str`]
            The reason for removing these roles. Shows up on the audit log.
        atomic: :class:`bool`
            Whether to atomically remove roles. This will ensure that multiple
            operations will always be applied regardless of the current
            state of the cache.

        Raises
        -------
        Forbidden
            You do not have permissions to remove these roles.
        HTTPException
            Removing the roles failed.
        c                8    g | ]}t          |j                   S )re  r  rf  s     rJ   
<listcomp>z'Member.remove_roles.<locals>.<listcomp>  s"    AAAQ14AAArL   r   Nre  r  rS  )
r   remover   r   rj  r{  r   rg  remove_roler   )	rI   rP  r  r   r  r  r  rv  r  s	            rJ   remove_roleszMember.remove_roles~  s      :  	EAA$*QRR.AAAI  $$Vtw%7%7%78888!   D )))F);;;;;;;;;;;+".Cz}HgG E Ec(GTWVDDDDDDDDDDDE Es   (A
AAr   c                  K   | j         j        }| j        j        | j        k    r&| j        j                            |           d{V }n+| j        j                            || j                   d{V }|                    d          }d}|'| j                             t          |                    }t          ||          S )a  |coro|

        Retrieves the current voice state from this member.

        .. versionadded:: 2.5

        Raises
        -------
        NotFound
            The member is not in a voice channel.
        Forbidden
            You do not have permissions to get a voice state.
        HTTPException
            Retrieving the voice state failed.

        Returns
        -------
        :class:`VoiceState`
            The current voice state of the member.
        Nrc  )rB   r?   )r   r   r   rh  rg  get_my_voice_stateget_voice_staterF   get_channelr   r   )rI   rv  rB   rc  r?   s        rJ   fetch_voicezMember.fetch_voice  s      * :=;$')))<<XFFFFFFFFDD)99(DGLLLLLLLLDXXl++
/3!j,,S__==GtW5555rL   r  Optional[Role]c               n    | j                             |          r| j                            |          ndS )aX  Returns a role with the given ID from roles which the member has.

        .. versionadded:: 2.0

        Parameters
        -----------
        role_id: :class:`int`
            The ID to search for.

        Returns
        --------
        Optional[:class:`Role`]
            The role or ``None`` if not found in the member's roles.
        N)r   r2  r   r  )rI   r  s     rJ   r  zMember.get_role  s2     04{w/G/GQtz""7+++TQrL   c                L    | j         t          j                    | j         k     S dS )zReturns whether this member is timed out.

        .. versionadded:: 2.0

        Returns
        --------
        :class:`bool`
            ``True`` if the member is timed out. ``False`` otherwise.
        NF)r   r   rm  r   s    rJ   r@  zMember.is_timed_out  s&     +<>>D$888urL   )rB   r   r   r(   r   r0   ra   )r   r   rP   r   )rP   r   )r   r1   rB   r   rP   r#   )r   r   r   r(   r   r0   rP   r#   )rB   r   rP   r   )rB   r   r   r(   r   r0   rP   r   )r   r#   rP   r#   )rP   r$   )rB   r-   rP   r   )r   r*   r   r   rP   r   )r   r   rP   r   )rP   r   )rz   r   rP   r   )rP   r   )rP   r   )rP   r  )rP   r  )rP   r   )rP   r   )rP   r-  )r   r1   rP   r   )rP   r2   )rP   r   )rP   rE  )rP   rH  )rP   r   )rN  r   rO  r   rP  r   rP   r   )rP  r   rP   r   )r   r   r9   r   rY  r   rA   r   r   r]  rZ  rD   r   r^  r[  r   r   r_  r   r_  r\  r   rP  r   rP   r`  )rP   r   )r?   rD   rP  r   rP   r   )r  r  rP  r   rP   r   )r   r/   rP  r   r  r   rP   r   )rP   r   )r  r   rP   r  )=r]   rb   rc   rd   re   r   ri   rK   r   r`   r   r   r   classmethodr   r   r   r   r   r   rG   r   r   r   r   r   setterr  r  r  r	  r  r  r   r  r  r!  r$  r#  r*  r)  r/  r3  r:  rD  rG  rK  r   r   rR  rU  rX  r{  r}  r  r  r  r  r  r  r@  rU   rL   rJ   r    r       sN        ; ;zI&  (			""""			%%%%''''5555""""%%%%&&&&''''****////####''''w w w w.   
 
 
 
C C C C& & & &        I I I [I
 8 8 8 [8+ + + + C C C [C    [0   J J J J*1 1 1 1,  ,  ,  , \ ) ) ) X) * * * X* ]0 0 0 ]0 0 0 0 X0 1 1 1 X1 - - - X-1 1 1 1       X $    X    X&    X % % % X% : : : X: 	S 	S 	S X	S [ [ [ X[ 6 6 6 X6 [ [ [ X[ & & & X&"O O O O* 
U 
U 
U X
U    X< . . . X. : : : X: 4 4 4 X4 $+&- $
 
 
 
 
 
$ 6: 4 4 4 4 4 4 59 3 3 3 3 3 3 & 3:5<7>$+")")$ $LF LF LF LF LF LF\#O #O #O #OJ ^b > > > > > >. lp%H %H %H %H %H %HN JN^b %E %E %E %E %E %EN MQae +E +E +E +E +E +EZ 6  6  6  6DR R R R"     rL   r    )rf   r!   rP   r!   )]rd   
__future__r   rl  rx   r|   operatorr   typingr   r   r   r   r	   r
   r   r   r   r   r   discord.abcdiscordrb  r   assetr   r   r   r   r   r   r   r   r   enumsr   errorsr   r  r   r   r   r   r   	presencesr   __all__typer!   typing_extensionsr#   r?   r$   r%   r&   r'   r   r(   r/  r)   r*   types.memberr+   r   r    r   r,   r   types.gatewayr-   
types.userr   r.   abcr/   r   r0   r   r1   r  r2   types.voicer3   GuildVoiceStatePayloadr   VoiceStatePayloadr   r4   collectibler5   VocalGuildChannelr   MessageablerU   rL   rJ   <module>r     s   0 # " " " " "             s s s s s s s s s s s s s s s s s s s s s s s s s s                       6 6 6 6 6 6 6 6 6 6 6 6 $ $ $ $ $ $       # # # # # #                   # # # # # #
 GCt :&&&&&&>>>>>>>>>>&&&&&&''''''111111         
 655555EEEEEEEE&&&&&&              ,+++++((((((lL89U6 U6 U6 U6 U6 U6 U6 U6p' ' ' 'T T T T T TW[$h T T T T TrL   