
    iY                       d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZ ddlT dd	lmZmZmZmZm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 er4d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e(d          Z)dZ* ej+        e,          Z- G d d          Z. G d d          Z/ G d d          Z0 G d d          Z1 G d d           Z2 G d! d"e
          Z3d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   )AutoShardedConnectionState)Client)ExponentialBackoff)*)ClientExceptionHTTPExceptionGatewayNotFoundConnectionClosedPrivilegedIntentsRequired)Status)TYPE_CHECKINGAnyCallableTupleTypeOptionalListDict)Unpack)DiscordWebSocket)BaseActivity)Intents)SessionStartLimit)_ClientOptionsc                  $    e Zd ZU ded<   ded<   dS )_AutoShardedClientOptionsz	List[int]	shard_idszOptional[float]shard_connect_timeoutN)__name__
__module____qualname____annotations__     T/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/shard.pyr   r   9   s*         ......r&   r   F)total)AutoShardedClient	ShardInfoSessionStartLimitsc                  &    e Zd ZdZdZdZdZdZdZdS )	EventTyper   r               N)	r!   r"   r#   close	reconnectresumeidentify	terminateclean_closer%   r&   r'   r-   r-   G   s,        EIFHIKKKr&   r-   c                  2    e Zd ZdZdd
ZddZddZddZdS )	EventItemtypesharderroretypeintr<   Optional['Shard']r=   Optional[Exception]returnNonec                0    || _         || _        || _        d S Nr:   )selfr>   r<   r=   s       r'   __init__zEventItem.__init__S   s    	(-
*/


r&   otherobjectboolc                Z    t          |t                    st          S | j        |j        k     S rE   
isinstancer9   NotImplementedr;   rF   rH   s     r'   __lt__zEventItem.__lt__X   s)    %++ 	"!!y5:%%r&   c                Z    t          |t                    st          S | j        |j        k    S rE   rL   rO   s     r'   __eq__zEventItem.__eq__]   s)    %++ 	"!!yEJ&&r&   c                *    t          | j                  S rE   )hashr;   rF   s    r'   __hash__zEventItem.__hash__b   s    DIr&   N)r>   r?   r<   r@   r=   rA   rB   rC   )rH   rI   rB   rJ   rB   r?   )r!   r"   r#   	__slots__rG   rP   rR   rV   r%   r&   r'   r9   r9   P   si        *I0 0 0 0
& & & &
' ' ' '
     r&   r9   c                  n    e Zd Zdd	Ze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S )Shardwsr   clientr)   	queue_putCallable[[EventItem], None]rB   rC   c                   || _         || _        |j        | _        || _        d| _        |j        | _        t                      | _        d | _	        t          t          t          t          t          j        t           j        f| _        d S )NF)r[   _clientdispatch	_dispatch
_queue_put_disconnect
_reconnectr   _backoff_taskOSErrorr
   r   r   aiohttpClientErrorasyncioTimeoutError_handled_exceptions)rF   r[   r\   r]   s       r'   rG   zShard.__init__g   so    $&%.4o7@!& +,>,@,@-1
 A
   r&   r?   c                    | j         j        S rE   )r[   shard_idrU   s    r'   idzShard.idy   s     wr&   c                r    | j         j                            |                                           | _        d S rE   )r`   loopcreate_taskworkerrg   rU   s    r'   launchzShard.launch~   s(    \&224;;==AA


r&   c                    | j         4| j                                         s| j                                          d S d S d S rE   )rg   donecancelrU   s    r'   _cancel_taskzShard._cancel_task   sC    :!$*//*;*;!J "!!!r&   c                t   K   |                                   | j                            d           d {V  d S )N  )code)ry   r[   r2   rU   s    r'   r2   zShard.close   sF      gmmm&&&&&&&&&&&r&   c                t   K   |                                   d {V  |                     d| j                   d S )Nshard_disconnect)r2   rb   rp   rU   s    r'   
disconnectzShard.disconnect   sC      jjll)4733333r&   e	Exceptionc           	       K   |                      d           |                      d| j                   | j        s0|                     t	          t
          j        | |                     d S | j                                        rd S t          |t                    rO|j        dv rFt          | j        d          }|                     t	          t
          j        | |                     d S t          |t                    r|j        dk    rB|                     t	          t
          j        | t#          | j                                       d S |j        dk    r0|                     t	          t
          j        | |                     d S | j                                        }t(                              d| j        ||	           t-          j        |           d {V  |                     t	          t
          j        | |                     d S )
Nr   r~   )6   iF'  T)r4     r{   z/Attempting a reconnect for shard ID %s in %.2fs)exc_info)rb   rp   re   rc   r9   r-   r2   r`   	is_closedrM   rh   errnoReconnectWebSocketr4   r   r|   r6   r   rf   delay_logr=   rk   sleepr3   )rF   r   excretrys       r'   _handle_disconnectzShard._handle_disconnect   s     |$$$)47333 	OOIiotQ??@@@F<!!## 	Fa!! 	ag&<&<$TWT:::COOIi&6cBBCCCFa)** 	v~~	)*=tE^_c_fEgEg h hiiiv~~	)/4 C CDDD##%%

Ddgu_`
aaamE"""""""""	)"5tQ??@@@@@r&   c                n  K   | j                                         s	 | j                                         d {V  n# t          $ rN}|j        rt          j        nt          j        }|                     t          || |                     Y d }~d S d }~w| j
        $ r&}|                     |           d {V  Y d }~d S d }~wt          j        $ r Y d S t          $ r9}|                     t          t          j        | |                     Y d }~d S d }~ww xY w| j                                         d S d S rE   )r`   r   r[   
poll_eventr   r4   r-   r5   rc   r9   rm   r   rk   CancelledErrorr   r6   )rF   r   r>   s      r'   rt   zShard.worker   s     ,((** 	g((**********%   ,-HL	(():L	%q 9 9:::+   --a000000000)      	)*=tQ G GHHH ,((** 	 	 	 	 	s4   > 
DABDB??D	D.DDr   r   c                  K   |                                   |                     d           |                     d| j                   t                              d|j        | j                   	 t          j        | j        |j	        |j	        sd n| j
        j        | j        | j
        j        | j
        j                  }t          j        |d           d {V | _
        |                                  d S # | j        $ r&}|                     |           d {V  Y d }~d S d }~wt&          $ rz}t                              d|j        |j        | j                   |j	        rt(          j	        nt(          j        }|                     t/          || |                     Y d }~d S d }~wt          j        $ r Y d S t2          $ r9}|                     t/          t(          j        | |                     Y d }~d S d }~ww xY w)Nr   r~   z1Got a request to %s the websocket at Shard ID %s.)r4   gatewayro   sessionsequence      N@timeoutz:Somehow got a signal to %s while trying to %s shard ID %s.)ry   rb   rp   r   debugopr   from_clientr`   r4   r[   r   
session_idr   rk   wait_forru   rm   r   r   r-   r5   rc   r9   r   r   r6   )rF   r   coror   r   s        r'   
reidentifyzShard.reidentify   s0     |$$$)47333

FPTPWXXX	#/z$'JCDGO*)  D $,T4@@@@@@@@@DG KKMMMMM ' 	- 	- 	-))!,,,,,,,,,,,,,,,! 	4 	4 	4JJSUVUY[^[acgcjkkk%&XE!!93EBOOIb$22333333333% 	 	 	FF 	E 	E 	EOOIi&94CCDDDDDDDDD	Es8   .A1C5 5
G9?D  G9-A/F""G97	G9 .G44G9c                  K   |                                   	 t          j        | j        | j                  }t          j        |d           d {V | _        |                                  d S # | j	        $ r&}| 
                    |           d {V  Y d }~d S d }~wt
          j        $ r Y d S t          $ r9}|                     t          t          j        | |                     Y d }~d S d }~ww xY w)Nro   r   r   )ry   r   r   r`   rp   rk   r   r[   ru   rm   r   r   r   rc   r9   r-   r6   )rF   r   r   s      r'   r3   zShard.reconnect   s7     
	#/twOOOD#,T4@@@@@@@@@DG KKMMMMM ' 	- 	- 	-))!,,,,,,,,,,,,,,,% 	 	 	FF 	E 	E 	EOOIi&94CCDDDDDDDDD	Es*   AA/ /
C19BC1/	C18.C,,C1N)r[   r   r\   r)   r]   r^   rB   rC   rW   rB   rC   )r   r   rB   rC   )r   r   rB   rC   )r!   r"   r#   rG   propertyrp   ru   ry   r2   r   r   rt   r   r3   r%   r&   r'   rZ   rZ   f   s        
 
 
 
$       X B B B B       ' ' ' '4 4 4 4A A A A:   "   8     r&   rZ   c                  ^    e Zd ZdZdZdd	ZddZddZddZddZ	e
dd            ZddZdS )r*   a  A class that gives information and control over a specific shard.

    You can retrieve this object via :meth:`AutoShardedClient.get_shard`
    or :attr:`AutoShardedClient.shards`.

    .. versionadded:: 1.4

    Attributes
    ------------
    id: :class:`int`
        The shard ID for this shard.
    shard_count: Optional[:class:`int`]
        The shard count for this cluster. If this is ``None`` then the bot has not started yet.
    _parentrp   shard_countparentrZ   r   Optional[int]rB   rC   c                :    || _         |j        | _        || _        d S rE   r   )rF   r   r   s      r'   rG   zShardInfo.__init__   s     $y*5r&   rJ   c                &    | j         j        j         S )z@:class:`bool`: Whether the shard connection is currently closed.)r   r[   openrU   s    r'   r   zShardInfo.is_closed   s    <?'''r&   c                t   K   |                                  rdS | j                                         d{V  dS )z|coro|

        Disconnects a shard. When this is called, the shard connection will no
        longer be open.

        If the shard is already disconnected this does nothing.
        N)r   r   r   rU   s    r'   r   zShardInfo.disconnect  sK       >> 	Fl%%'''''''''''r&   c                   K   |                                  s| j                                         d{V  | j                                         d{V  dS )zG|coro|

        Disconnects and then connects the shard again.
        N)r   r   r   r3   rU   s    r'   r3   zShardInfo.reconnect  sl      
 ~~ 	,,))+++++++++l$$&&&&&&&&&&&r&   c                t   K   |                                  sdS | j                                         d{V  dS )z_|coro|

        Connects a shard. If the shard is already connected this does nothing.
        N)r   r   r3   rU   s    r'   connectzShardInfo.connect  sK      
 ~~ 	Fl$$&&&&&&&&&&&r&   floatc                $    | j         j        j        S )zc:class:`float`: Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds for this shard.)r   r[   latencyrU   s    r'   r   zShardInfo.latency!  s     |&&r&   c                >    | j         j                                        S )z:class:`bool`: Whether the websocket is currently rate limited.

        This can be useful to know when deciding whether you should query members
        using HTTP or via the gateway.

        .. versionadded:: 1.6
        )r   r[   is_ratelimitedrU   s    r'   is_ws_ratelimitedzShardInfo.is_ws_ratelimited&  s     |--///r&   N)r   rZ   r   r   rB   rC   rB   rJ   r   rB   r   )r!   r"   r#   __doc__rX   rG   r   r   r3   r   r   r   r   r%   r&   r'   r*   r*      s          1I6 6 6 6
( ( ( (( ( ( (' ' ' '' ' ' ' ' ' ' X'0 0 0 0 0 0r&   r*   c                      e Zd ZdZdZddZdS )r+   a  A class that holds info about session start limits

    .. versionadded:: 2.5

    Attributes
    ----------
    total: :class:`int`
        The total number of session starts the current user is allowed
    remaining: :class:`int`
        Remaining remaining number of session starts the current user is allowed
    reset_after: :class:`int`
        The number of milliseconds until the limit resets
    max_concurrency: :class:`int`
        The number of identify requests allowed per 5 seconds
    r(   	remainingreset_aftermax_concurrencykwargsUnpack[SessionStartLimit]c                n    |d         | _         |d         | _        |d         | _        |d         | _        d S )Nr(   r   r   r   r   )rF   r   s     r'   rG   zSessionStartLimits.__init__D  s:     /
$[1 &} 5$*+<$=r&   N)r   r   )r!   r"   r#   r   rX   rG   r%   r&   r'   r+   r+   1  s:           II> > > > > >r&   r+   c                       e Zd ZU dZerded<   d6 fdZd7ddd8dZd9dZe	d:d            Z
e	d;d            Zd<dZe	d=d            Zd>d Zd!d"d?d'Zd@d(Zd@ fd)Zd*d+dAd-Zd@d.Zdddd/dBd4ZdCd5Z xZS )Dr)   a  A client similar to :class:`Client` except it handles the complications
    of sharding for the user into a more manageable and transparent single
    process bot.

    When using this client, you will be able to use it as-if it was a regular
    :class:`Client` with a single shard when implementation wise internally it
    is split up into multiple shards. This allows you to not have to deal with
    IPC or other complicated infrastructure.

    It is recommended to use this client only if you have surpassed at least
    1000 guilds.

    If no :attr:`.shard_count` is provided, then the library will use the
    Bot Gateway endpoint call to figure out how many shards to use.

    If a ``shard_ids`` parameter is given, then those shard IDs will be used
    to launch the internal shards. Note that :attr:`.shard_count` must be provided
    if this is used. By default, when omitted, the client will launch shards from
    0 to ``shard_count - 1``.

    .. container:: operations

        .. describe:: async with x

            Asynchronously initialises the client and automatically cleans up.

            .. versionadded:: 2.0

    Attributes
    ------------
    shard_ids: Optional[List[:class:`int`]]
        An optional list of shard_ids to launch the shards with.
    shard_connect_timeout: Optional[:class:`float`]
        The maximum number of seconds to wait before timing out when launching a shard.
        Defaults to 180 seconds.

        .. versionadded:: 2.4
    r   _connectionargsr   intentsr   r   !Unpack[_AutoShardedClientOptions]rB   rC   c                   |                     dd            |                     dd            _        |                     dd           _         t                      j        |d|i|  j        F j        t          d          t           j        t          t          f          st          d          i  _
         j         j        _         fd j        _        d S )	Nro   r   r    g     f@r   z>When passing manual shard_ids, you must provide a shard_count.z.shard_ids parameter must be a list or a tuple.c                      S rE   r%   rU   s   r'   <lambda>z,AutoShardedClient.__init__.<locals>.<lambda>  s    t r&   )popr   r    superrG   r   r	   rM   listtuple_AutoShardedClient__shards_get_websocketr   _get_client)rF   r   r   r   	__class__s   `   r'   rG   zAutoShardedClient.__init__v  s    

:t$$$.4jjd.K.K6<jjAXZ_6`6`"$::6:::>%'%&fgggu>> X%&VWWW *.*=''3|||$$$r&   Nr   guild_idr   ro   r   c               D    ||dz	  | j         z  }| j        |         j        S )N   )r   r   r[   )rF   r   ro   s      r'   r   z AutoShardedClient._get_websocket  s)     B$*::H}X&))r&   optionsc                L    t          d| j        | j        | j        | j        d|S )N)ra   handlershookshttpr%   )r   ra   	_handlers_hooksr   )rF   r   s     r'   
_get_statezAutoShardedClient._get_state  s<    ) 
]^+	
 

 
 
 	
r&   r   c                    | j         st          d          S t          d | j        D                       t	          | j                   z  S )aY  :class:`float`: Measures latency between a HEARTBEAT and a HEARTBEAT_ACK in seconds.

        This operates similarly to :meth:`Client.latency` except it uses the average
        latency of every shard's latency. To get a list of shard latency, check the
        :attr:`latencies` property. Returns ``nan`` if there are no shards ready.
        nanc              3      K   | ]	\  }}|V  
d S rE   r%   ).0_r   s      r'   	<genexpr>z,AutoShardedClient.latency.<locals>.<genexpr>  s&      <<zq'7<<<<<<r&   )r   r   sum	latencieslenrU   s    r'   r   zAutoShardedClient.latency  sH     } 	 <<<<T^<<<<<s4=?Q?QQQr&   List[Tuple[int, float]]c                H    d | j                                         D             S )zList[Tuple[:class:`int`, :class:`float`]]: A list of latencies between a HEARTBEAT and a HEARTBEAT_ACK in seconds.

        This returns a list of tuples with elements ``(shard_id, latency)``.
        c                0    g | ]\  }}||j         j        fS r%   )r[   r   )r   ro   r<   s      r'   
<listcomp>z/AutoShardedClient.latencies.<locals>.<listcomp>  s&    ZZZ558+,ZZZr&   r   itemsrU   s    r'   r   zAutoShardedClient.latencies  s'     [ZDMDWDWDYDYZZZZr&   r?   Optional[ShardInfo]c               j    	 | j         |         }t          || j                  S # t          $ r Y dS w xY w)aL  
        Gets the shard information at a given shard ID or ``None`` if not found.

        .. versionchanged:: 2.0

            ``shard_id`` parameter is now positional-only.

        Returns
        --------
        Optional[:class:`ShardInfo`]
            Information about the shard with given ID. ``None`` if not found.
        N)r   r*   r   KeyError)rF   ro   r   s      r'   	get_shardzAutoShardedClient.get_shard  sL    	7]8,F VT%5666  	 	 	44	s   $ 
22Dict[int, ShardInfo]c                N      fd j                                         D             S )zaMapping[int, :class:`ShardInfo`]: Returns a mapping of shard IDs to their respective info object.c                B    i | ]\  }}|t          |j                  S r%   )r*   r   )r   ro   r   rF   s      r'   
<dictcomp>z,AutoShardedClient.shards.<locals>.<dictcomp>  s-    lllBR(F)FD,<==lllr&   r   rU   s   `r'   shardszAutoShardedClient.shards  s0     mlllVZVcViViVkVkllllr&   r+   c                d   K   | j                                          d{V \  }}}t          di |S )a  |coro|

        Get the session start limits.

        This is not typically needed, and will be handled for you by default.

        At the point where you are launching multiple instances
        with manual shard ranges and are considered required to use large bot
        sharding by Discord, this function when used along IPC and a
        before_identity_hook can speed up session start.

        .. versionadded:: 2.5

        Returns
        -------
        :class:`SessionStartLimits`
            A class containing the session start limits

        Raises
        ------
        GatewayNotFound
            The gateway was unreachable
        Nr%   )r   get_bot_gatewayr+   )rF   r   limitss      r'   fetch_session_start_limitsz,AutoShardedClient.fetch_session_start_limits  sG      0 "Y66888888881f!++F+++r&   Finitialr   yarl.URLr   rJ   c                 K   	 t          j        | |||          }t          j        || j                   d {V }na# t
          $ rT t                              d|           t          j        d           d {V  | 	                    ||           d {V cY S w xY wt          || | j        j                  x| j        |<   }|                                 d S )N)r   r   ro   r   z/Failed to connect for shard_id: %s. Retrying...g      @)r   r   rk   r   r    r   r   	exceptionr   launch_shardrZ   _AutoShardedClient__queue
put_nowaitr   ru   )rF   r   ro   r   r   r[   rets          r'   r   zAutoShardedClient.launch_shard  s     	>#/gwaijjjD'd6PQQQQQQQQQBB 	> 	> 	>NNLhWWW-$$$$$$$$$**7H===========	> ).b$8O(P(PPh#

s   9> ABBc                  K   |                                  rd S | j        ?|  | j                                         d {V \  | _        }}t	          j        |          }nt          j        }| j        | j        _        | j	        pt          | j                  }|| j        _	        |D ],}||d         k    }|                     |||           d {V  -d S )Nr   r   )r   r   r   r   yarlURLr   DEFAULT_GATEWAYr   r   ranger   )rF   gateway_url_session_start_limitr   r   ro   r   s          r'   launch_shardszAutoShardedClient.launch_shards  s      >> 	F#!HL	HaHaHcHcBcBcBcBcBcBc?Dk+?h{++GG&6G'+'7$N=eD,<&=&=	%."! 	H 	HH)A,.G##GXw#GGGGGGGGGG	H 	Hr&   c                   K   t                                                       d {V  t          j                    | _        d S rE   )r   _async_setup_hookrk   PriorityQueuer   )rF   r   s    r'   r  z#AutoShardedClient._async_setup_hook  sC      gg''))))))))),..r&   T)r3   r3   c                 K   || _         |                                  d {V  |                                 s| j                                         d {V }|j        t          j        k    rw|                                  d {V  t          |j	        t                    rA|j	        j        dk    rt          |j        j                  d |j	        j        dk    r|j	        d S |j        t          j        t          j        fv r&|j                            |j	                   d {V  n|j        t          j        k    r |j                                         d {V  nM|j        t          j        k    r!|                                  d {V  |j	        |j        t          j        k    rd S |                                 d S d S )Nr   r{   )re   r	  r   r   getr;   r-   r2   rM   r=   r   r|   r   r<   rp   r5   r4   r   r3   r6   r7   )rF   r3   items      r'   r   zAutoShardedClient.connect  s     #  """"""""".."" 	))++++++++DyIO++jjll"""""""dj*:;; )z$..7
FFDPz$.."j(y193CDDDj++DJ7777777777i111j**,,,,,,,,,,i111jjll"""""""j i333% .."" 	 	 	 	 	r&   c                    K    j         r j          d{V S  fd}t          j         |                       _          j          d{V  dS )z:|coro|

        Closes the connection to Discord.
        Nc                 p  K   j                                          d {V  fdj                                        D             } | rt	          j        |            d {V  j                                         d {V  j                            t          t          j        d d                      d S )Nc                j    g | ]/}t          j        |                                j                   0S ))rr   )rk   ensure_futurer2   rr   )r   r<   rF   s     r'   r   z;AutoShardedClient.close.<locals>._close.<locals>.<listcomp>(  s4    qqqQV-ekkmm$)LLLqqqr&   )r   r2   r   valuesrk   waitr   r   r   r9   r-   r7   )to_closerF   s    r'   _closez'AutoShardedClient.close.<locals>._close%  s      "((*********qqqqZ^ZgZnZnZpZpqqqH -l8,,,,,,,,,)//#########L##Ii.CT4$P$PQQQQQr&   )_closing_taskrk   rs   )rF   r  s   ` r'   r2   zAutoShardedClient.close  s      
  	,++++++++	R 	R 	R 	R 	R %0::          r&   )activitystatusro   r  Optional[BaseActivity]r  Optional[Status]c                 K   |d}t           j        }n.|t           j        u rd}t           j        }n|}t          |          }K| j                                        D ]$}|j                            ||           d{V  %| j        j	        }nG| j                 }|j                            ||           d{V  fd| j        j	        D             }|dn|f}|D ]}	|	j
        }
|
||
_        ||
_        dS )a>  |coro|

        Changes the client's presence.

        Example: ::

            game = discord.Game("with the API")
            await client.change_presence(status=discord.Status.idle, activity=game)

        .. versionchanged:: 2.0
            Removed the ``afk`` keyword-only parameter.

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

        Parameters
        ----------
        activity: Optional[:class:`BaseActivity`]
            The activity being done. ``None`` if no currently active activity is done.
        status: Optional[:class:`Status`]
            Indicates what status to change to. If ``None``, then
            :attr:`Status.online` is used.
        shard_id: Optional[:class:`int`]
            The shard_id to change the presence to. If not specified
            or ``None``, then it will change the presence of every
            shard the bot can see.

        Raises
        ------
        TypeError
            If the ``activity`` parameter is not of proper type.
        Nonline	invisible)r  r  c                *    g | ]}|j         k    |S r%   r   )r   gro   s     r'   r   z5AutoShardedClient.change_presence.<locals>.<listcomp>m  s%    SSSAAJ(<R<Ra<R<R<Rr&   r%   )r   r  offlinestrr   r  r[   change_presencer   guildsme
activitiesr  )rF   r  r  ro   status_valuestatus_enumr<   r%  r'  guildr&  s      `       r'   r$  z!AutoShardedClient.change_presence2  sL     R >#L -KKv~%%&L .KK Kv;;L--// W Wh...VVVVVVVVVV%,FFM(+E(**H\*RRRRRRRRRSSSS!1!8SSSF#+RR(
 	$ 	$EBz 'BM#BII	$ 	$r&   c                b    t          d | j                                        D                       S )a}  :class:`bool`: Whether the websocket is currently rate limited.

        This can be useful to know when deciding whether you should query members
        using HTTP or via the gateway.

        This implementation checks if any of the shards are rate limited.
        For more granular control, consider :meth:`ShardInfo.is_ws_ratelimited`.

        .. versionadded:: 1.6
        c              3  H   K   | ]}|j                                         V  d S rE   )r[   r   )r   r<   s     r'   r   z6AutoShardedClient.is_ws_ratelimited.<locals>.<genexpr>  s0      QQ58**,,QQQQQQr&   )anyr   r  rU   s    r'   r   z#AutoShardedClient.is_ws_ratelimitedy  s/     QQ$-:N:N:P:PQQQQQQr&   )r   r   r   r   r   r   rB   rC   rE   )r   r   ro   r   rB   r   )r   r   rB   r   r   )rB   r   )ro   r?   rB   r   )rB   r   )rB   r+   )r   r   ro   r?   r   rJ   rB   rC   r   )r3   rJ   rB   rC   )r  r  r  r  ro   r   rB   rC   r   )r!   r"   r#   r   r   r$   rG   r   r   r   r   r   r   r   r   r   r	  r  r   r2   r$  r   __classcell__)r   s   @r'   r)   r)   K  s        % %N  0////4 4 4 4 4 4&*Z^ * * * * * *
 
 
 
 	R 	R 	R X	R [ [ [ X[7 7 7 7( m m m Xm, , , ,6 W\      H H H H(/ / / / / / 26      0! ! ! !0 ,0#'"&E$ E$ E$ E$ E$ E$NR R R R R R R Rr&   r)   )4r   
__future__r   rk   loggingri   r  stater   r\   r   backoffr   r   errorsr	   r
   r   r   r   enumsr   typingr   r   r   r   r   r   r   r   typing_extensionsr   r   r  r   flagsr   types.gatewayr   r   r   __all__	getLoggerr!   r   r-   r9   rZ   r*   r+   r)   r%   r&   r'   <module>r;     s   0 # " " " " "     - - - - - -       ' ' ' ' ' '                        R R R R R R R R R R R R R R R R R R R R 
/(((((())))))&&&&&&000000&&&&&&/ / / / /N% / / / /
 w""              ,} } } } } } } }@H0 H0 H0 H0 H0 H0 H0 H0V> > > > > > > >4yR yR yR yR yR yR yR yR yR yRr&   