
    cjh˜                    <   U d Z ddlmZ ddlZddlZddl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 erddlmZ ddlmZ d	Zd
 Zej0                  j2                  Z ed      Z edd      Z edej:                  j<                        Z edej@                        Z!e G d dee                Z" ejF                  d      Z$ G d de"e         Z% G d de%ejL                           Z' G d de%ejP                           Z) G d de%ejT                           Z+ G d de"ejX                           Z- G d d e%ej\                           Z/ G d! d"e%ej:                  j<                           Z0 G d# d$e%ejb                           Z2 G d% d&e%ejf                           Z4 G d' d(e%ejj                           Z6 G d) d*e%ejn                           Z8 G d+ d,e%ejr                           Z: G d- d.e%ej@                           Z; G d/ d0e"ejx                           Z=e=Z> G d1 d2e%ej~                           Z@ G d3 d4e"ej                           ZB G d5 d6e"ej                           ZD G d7 d8e%ej                           ZF G d9 d:e%ej                           ZH G d; d<e"ej                           ZJ G d= d>e%ej                           ZL G d? d@e"eM         ZN G dA dBe
e         ZOdKdCZPdLdDZQ eRe
e         ZSeSdEdMdFZTi ejL                  e'ejP                  e)ejT                  e+ej\                  e/ejX                  e-ejb                  e2ej                  eDej                  eFej~                  e@ej                  eBejx                  e=ejf                  e4ejj                  e6ej                  eHej                  eJejn                  e8ejr                  e:ej@                  e;ej:                  j<                  e0ej                  eLiZUdGeVdH<   	 	 	 	 	 	 dNdIZW	 	 	 	 	 	 dOdJZXy)Pae  
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.
    )annotationsN)
TYPE_CHECKINGAnyGenericIterableListLiteralProtocolTypeVarUnionruntime_checkable   )*)PartialMessageableChannel)Context)	ConverterObjectConverterMemberConverterUserConverterMessageConverterPartialMessageConverterTextChannelConverterForumChannelConverterInviteConverterGuildConverterRoleConverterGameConverterColourConverterColorConverterVoiceChannelConverterStageChannelConverterEmojiConverterPartialEmojiConverterCategoryChannelConverterIDConverterThreadConverterGuildChannelConverterGuildStickerConverterclean_contentGreedyrun_convertersc                \    d }| j                   D ]  } t        ||      |      }|s|c S  |S N)guildsgetattr)botgetterargumentresultguilds        Q/var/www/html/venv/lib/python3.12/site-packages/discord/ext/commands/converter.py_get_from_guildsr6   S   s<    F ''1M M    TT_coT)	covariantCT)boundTTc                      e Zd ZdZddZy)r   a  The base class of custom converters that require the :class:`.Context`
    to be passed to be useful.

    This allows you to implement converters that function similar to the
    special cased ``discord`` classes.

    Classes that derive from this should override the :meth:`~.Converter.convert`
    method to do its conversion logic. This method must be a :ref:`coroutine <coroutine>`.
    c                    K   t        d      w)a  |coro|

        The method to override to do conversion logic.

        If an error is found while converting, it is recommended to
        raise a :exc:`.CommandError` derived exception as it will
        properly propagate to the error handlers.

        Parameters
        ----------
        ctx: :class:`.Context`
            The invocation context that the argument is being used in.
        argument: :class:`str`
            The argument that is being converted.

        Raises
        ------
        :exc:`.CommandError`
            A generic exception occurred when converting the argument.
        :exc:`.BadArgument`
            The converter failed to convert the argument.
        z'Derived classes need to implement this.)NotImplementedErrorselfctxr2   s      r5   convertzConverter.converto   s     . ""KLLs   N)rC   r   r2   strreturnr9   __name__
__module____qualname____doc__rD    r7   r5   r   r   c   s    Mr7   r   z([0-9]{15,20})$c                      e Zd Zed        Zy)r%   c                ,    t         j                  |       S r-   )	_ID_REGEXmatch)r2   s    r5   _get_id_matchzIDConverter._get_id_match   s    x((r7   N)rH   rI   rJ   staticmethodrQ   rL   r7   r5   r%   r%      s    ) )r7   r%   c                      e Zd ZdZddZy)r   a   Converts to a :class:`~discord.Object`.

    The argument must follow the valid ID or mention formats (e.g. `<@80088516616269824>`).

    .. versionadded:: 2.0

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by member, role, or channel mention.
    c                   K   | j                  |      xs t        j                  d|      }|t        |      t	        |j                  d            }t        j                  |      S w)Nz<(?:@[!&]?|#)([0-9]{15,20})>$r   id)rQ   rerP   ObjectNotFoundintgroupdiscordObject)rB   rC   r2   rP   r3   s        r5   rD   zObjectConverter.convert   s^     ""8, 
,h1
 = **U[[^$~~((s   A'A)N)rC   r   r2   rE   rF   zdiscord.ObjectrG   rL   r7   r5   r   r      s    

)r7   r   c                  $    e Zd ZdZd Zd ZddZy)r   a}  Converts to a :class:`~discord.Member`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name#discrim
    4. Lookup by name
    5. Lookup by nickname

    .. versionchanged:: 1.5
         Raise :exc:`.MemberNotFound` instead of generic :exc:`.BadArgument`

    .. versionchanged:: 1.5.1
        This converter now lazily fetches members from the gateway and HTTP APIs,
        optionally caching the result if :attr:`.MemberCacheFlags.joined` is enabled.
    c                  K   |j                   j                  j                  }t              dkD  r[d   dk(  rSj	                  d      \  }}}|j                  |d|       d {   }t        j                  j                  |||      S |j                  d|       d {   }t        j                  j                  fd|      S 7 e7 )w)N   #d   )limitcachenamediscriminatorc                N    | j                   | j                  | j                  fv S r-   )nickrf   global_name)mr2   s    r5   <lambda>z4MemberConverter.query_member_named.<locals>.<lambda>   s    h1661661=="AA r7   )
_statemember_cache_flagsjoinedlen
rpartitionquery_membersr[   utilsgetfind)rB   r4   r2   rd   username_rg   memberss     `     r5   query_member_namedz"MemberConverter.query_member_named   s     //66x=1"!4)1)<)<S)A&Ha!//5/QQG==$$hm %   ++HCu+MM}}!!A
 	
 R Ns$   A#C&C'=C$C%(CCc                  K   |j                  |j                        }|j                  j                  j                  }|j                         r/	 |j                  |       d {   }|r|j                  |       |S |j                  d|g|       d {   }|sy |d   S 7 ># t        j                  $ r Y y w xY w7 'w)N)shard_idr   )rc   user_idsrd   r   )_get_websocketr{   rm   rn   ro   is_ratelimitedfetch_memberr[   HTTPException_add_memberrr   )rB   r0   r4   user_idwsrd   memberrx   s           r5   query_member_by_idz"MemberConverter.query_member_by_id   s     8//66$11':: !!&)M ++!wiu+UUqz ;((  VsH   AC B% $B#%B% )-C B>C #B% %B;8C :B;;C c                d  K   |j                   }| j                  |      xs t        j                  d|      }|j                  }d }d }|"|r|j                  |      }nxt        |d|      }njt        |j                  d            }|rA|j                  |      }|j                  1|/t        |j                  j                  |      }nt        |d|      }|R|t        |      || j                  |||       d {   }n| j                  ||       d {   }|st        |      |S 7 .7 w)N<@!?([0-9]{15,20})>$get_member_namedr   rU   
get_member)r0   rQ   rW   rP   r4   r   r6   rY   rZ   r   message
_utils_getmentionsMemberNotFoundr   ry   )rB   rC   r2   r0   rP   r4   r3   r   s           r5   rD   zMemberConverter.convert   s+    gg""8, 
#X1
 		=//9)#/A8L%++a.)G))'2;;*v~'(<(<IF)#|WE>}$X.."#66sE7KK#66uhGG$X.. LGs$   C;D0=D,>D0D.D0.D0N)rC   r   r2   rE   rF   zdiscord.Member)rH   rI   rJ   rK   ry   r   rD   rL   r7   r5   r   r      s    *
*#r7   r   c                      e Zd ZdZddZy)r   a  Converts to a :class:`~discord.User`.

    All lookups are via the global user cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name#discrim
    4. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.UserNotFound` instead of generic :exc:`.BadArgument`

    .. versionchanged:: 1.6
        This converter now lazily fetches users from the HTTP APIs if an ID is
        passed, and it's not available in cache.
    c                b  	
K   | j                  |      xs t        j                  d|      }d }|j                  }|t	        |j                  d            }|j                  j                  |      }|j                  #|!t        |j                  j                  |      }|&	 |j                  j                  |       d {   }|S |S |d   dk(  rdd  t              dkD  rTd   dk(  rLd	d  	d d 
	
fd
}t        j                   j#                  ||j$                  j'                               }||S fd}t        j                   j#                  ||j$                  j'                               }|t        |      |S 7 # t        j                  $ r t        |      d w xY ww)Nr   r   rU   r   @r_   r`   ra   c                D    | j                   k(  xr | j                  k(  S r-   re   )udiscrimrf   s    r5   rl   z'UserConverter.convert.<locals>.<lambda>>  s    !&&D."OQ__5O r7   c                8    | j                   | j                  fv S r-   )rf   rj   )r   args    r5   rl   z'UserConverter.convert.<locals>.<lambda>C  s    caffamm%<< r7   )rQ   rW   rP   rm   rY   rZ   r0   get_userr   r   r   
fetch_userr[   r   UserNotFoundrp   rs   ru   _usersvalues)rB   rC   r2   rP   r3   stater   	predicater   r   rf   s           @@@r5   rD   zUserConverter.convert  s    ""8, 
#X1
 

%++a.)GWW%%g.F{{&6>#CKK$8$8WE~;#&77#5#5g#>>F M6M q6S=ab'C s8a<CGsN"#hGs8DOI]]''	5<<3F3F3HIF!<	##Iu||/B/B/DE>x((9 ?,, ;&x0d:;s1   B F/&F F
F 	CF/
F  F,,F/N)rC   r   r2   rE   rF   zdiscord.UserrG   rL   r7   r5   r   r     s    &*r7   r   c                  :    e Zd ZdZed        Zedd       ZddZy)r   a7  Converts to a :class:`discord.PartialMessage`.

    .. versionadded:: 1.7

    The creation strategy is as follows (in order):

    1. By "{channel ID}-{message ID}" (retrieved by shift-clicking on "Copy ID")
    2. By message ID (The message is assumed to be in the context channel.)
    3. By message URL
    c                   t        j                  d      }t        j                  d      }|j                  |      xs |j                  |      }|st        |      |j	                         }|j                  d      }|%| j                  xr | j                  j                  }nt        |      }t        |d         }|j                  d      }|%| j                  xr | j                  j                  }n|dk(  rd }nt        |      }|||fS )Nz?(?:(?P<channel_id>[0-9]{15,20})-)?(?P<message_id>[0-9]{15,20})$zhttps?://(?:(ptb|canary|www)\.)?discord(?:app)?\.com/channels/(?P<guild_id>[0-9]{15,20}|@me)/(?P<channel_id>[0-9]{15,20})/(?P<message_id>[0-9]{15,20})/?$
channel_id
message_idguild_idz@me)
rW   compilerP   MessageNotFound	groupdictrt   channelrV   rY   r4   )	rC   r2   id_regex
link_regexrP   datar   r   r   s	            r5   _get_id_matchesz'PartialMessageConverter._get_id_matchesX  s    ::N
 ZZM


 x(FJ,<,<X,F!(++ XXl+
7JZJl+,
88J'yy1SYY\\HH8}HZ//r7   c                    |1| j                   j                  |      }|||j                  |      S y |r| j                   j                  |      S | j                  S r-   )r0   	get_guild_resolve_channelget_channelr   )rC   r   r   r4   s       r5   r   z(PartialMessageConverter._resolve_channelu  s[    GG%%h/E Z%;--j996@377&&z2QckkQr7   c                   K   | j                  ||      \  }}}| j                  |||      }|st        |      t        j                  ||      S w)N)r   rV   )r   r   ChannelNotFoundr[   PartialMessage)rB   rC   r2   r   r   r   r   s          r5   rD   zPartialMessageConverter.convert  sT     +/+?+?X+N(*j''XzB!*--%%g*EEs   AAN)rF   z PartialMessageableChannel | None)rC   r   r2   rE   rF   zdiscord.PartialMessage)rH   rI   rJ   rK   rR   r   r   rD   rL   r7   r5   r   r   L  s7    	 0 08 R RFr7   r   c                      e Zd ZdZddZy)r   a  Converts to a :class:`discord.Message`.

    .. versionadded:: 1.1

    The lookup strategy is as follows (in order):

    1. Lookup by "{channel ID}-{message ID}" (retrieved by shift-clicking on "Copy ID")
    2. Lookup by message ID (the message **must** be in the context channel)
    3. Lookup by message URL

    .. versionchanged:: 1.5
         Raise :exc:`.ChannelNotFound`, :exc:`.MessageNotFound` or :exc:`.ChannelNotReadable`
         instead of generic :exc:`.BadArgument`
    c                  K   t         j                  ||      \  }}}|j                  j                  j	                  |      }|r|S t         j                  |||      }|st        |      	 |j                  |       d {   S 7 # t        j                  $ r t        |      t        j                  $ r t        |      w xY wwr-   )r   r   r0   _connection_get_messager   r   fetch_messager[   NotFoundr   	ForbiddenChannelNotReadable)rB   rC   r2   r   r   r   r   r   s           r5   rD   zMessageConverter.convert  s     +B+R+R,
(*j ''%%22:>N)::3*U!*--	. ..z:::: 	,!(++   	.$W--	.s0   A(C+B ?B B CB <CCN)rC   r   r2   rE   rF   zdiscord.MessagerG   rL   r7   r5   r   r     s    .r7   r   c                  d    e Zd ZdZddZe	 	 	 	 	 	 	 	 	 	 dd       Ze	 	 	 	 	 	 	 	 	 	 dd       Zy)	r'   a:  Converts to a :class:`~discord.abc.GuildChannel`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name.

    .. versionadded:: 2.0
    c                b   K   | j                  ||dt        j                  j                        S w)Nchannels)r   r[   abcGuildChannelrA   s      r5   rD   zGuildChannelConverter.convert  s,     $$:w{{'?'?
 	
s   -/c                
   | j                   }t        j                        xs t        j                  d      }d }| j
                  }|e|r.t        ||      }t        j                  j                  |      }npfd}	t        j                  j                  |	|j                               }n;t        |j                  d            }
|r|j                  |
      }nt        |d|
      }t!        |      st#              |S )N<#([0-9]{15,20})>$rf   c                >    t        |       xr | j                  k(  S r-   )
isinstancerf   )cr2   types    r5   checkz5GuildChannelConverter._resolve_channel.<locals>.check  s    %a.E166X3EEr7   r   r   )r0   r%   rQ   rW   rP   r4   r/   r[   rs   rt   ru   get_all_channelsrY   rZ   r   r6   r   r   )rC   r2   	attributer   r0   rP   r3   r4   iterabler   r   s    ` `       r5   r   z&GuildChannelConverter._resolve_channel  s     gg))(3 
rxx!88
 		=)0	)B$+MM$5$5hX$5$NF !++E33G3G3IJU[[^,J**:6)#}jI&$'!(++r7   c                l   t         j                  |      xs t        j                  d|      }d }| j                  }|0|r[t        ||      }t        j                  j                  ||      }n-t        |j                  d            }|r|j                  |      }|rt        ||      st        |      |S )Nr   r   r   )r%   rQ   rW   rP   r4   r/   r[   rs   rt   rY   rZ   
get_threadr   ThreadNotFound)	rC   r2   r   r   rP   r3   r4   r   	thread_ids	            r5   _resolve_threadz%GuildChannelConverter._resolve_thread  s     ))(3 
rxx!88
 		=)0	)B$+MM$5$5hX$5$NEKKN+I)))4Z5 **r7   N)rC   r   r2   rE   rF   zdiscord.abc.GuildChannel)
rC   r   r2   rE   r   rE   r   ztype[CT]rF   r;   )
rC   r   r2   rE   r   rE   r   ztype[TT]rF   r=   )rH   rI   rJ   rK   rD   rR   r   r   rL   r7   r5   r'   r'     s    

    # 03 ;C 	   D  #03;C	 r7   r'   c                      e Zd ZdZddZy)r   a  Converts to a :class:`~discord.TextChannel`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.ChannelNotFound` instead of generic :exc:`.BadArgument`
    c                V   K   t         j                  ||dt        j                        S w)Ntext_channels)r'   r   r[   TextChannelrA   s      r5   rD   zTextChannelConverter.convert  s(     $55?G,?,?
 	
   ')N)rC   r   r2   rE   rF   zdiscord.TextChannelrG   rL   r7   r5   r   r         
r7   r   c                      e Zd ZdZddZy)r    a  Converts to a :class:`~discord.VoiceChannel`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.ChannelNotFound` instead of generic :exc:`.BadArgument`
    c                V   K   t         j                  ||dt        j                        S w)Nvoice_channels)r'   r   r[   VoiceChannelrA   s      r5   rD   zVoiceChannelConverter.convert!  )     $55+W-A-A
 	
r   N)rC   r   r2   rE   rF   zdiscord.VoiceChannelrG   rL   r7   r5   r    r      r   r7   r    c                      e Zd ZdZddZy)r!   a5  Converts to a :class:`~discord.StageChannel`.

    .. versionadded:: 1.7

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name
    c                V   K   t         j                  ||dt        j                        S w)Nstage_channels)r'   r   r[   StageChannelrA   s      r5   rD   zStageChannelConverter.convert6  r   r   N)rC   r   r2   rE   rF   zdiscord.StageChannelrG   rL   r7   r5   r!   r!   '      
r7   r!   c                      e Zd ZdZddZy)r$   a  Converts to a :class:`~discord.CategoryChannel`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.ChannelNotFound` instead of generic :exc:`.BadArgument`
    c                V   K   t         j                  ||dt        j                        S w)N
categories)r'   r   r[   CategoryChannelrA   s      r5   rD   z CategoryChannelConverter.convertL  s(     $55<)@)@
 	
r   N)rC   r   r2   rE   rF   zdiscord.CategoryChannelrG   rL   r7   r5   r$   r$   <  r   r7   r$   c                      e Zd ZdZddZy)r   a5  Converts to a :class:`~discord.ForumChannel`.

    All lookups are via the local guild. If in a DM context, then the lookup
    is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name

    .. versionadded:: 2.0
    c                V   K   t         j                  ||dt        j                        S w)Nforum_channels)r'   r   r[   ForumChannelrA   s      r5   rD   zForumChannelConverter.converta  r   r   N)rC   r   r2   rE   rF   zdiscord.ForumChannelrG   rL   r7   r5   r   r   R  r   r7   r   c                      e Zd ZdZddZy)r&   zCoverts to a :class:`~discord.Thread`.

    All lookups are via the local guild.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name.

    .. versionadded: 2.0
    c                V   K   t         j                  ||dt        j                        S w)Nthreads)r'   r   r[   ThreadrA   s      r5   rD   zThreadConverter.convertu  s&     $449gnn
 	
r   N)rC   r   r2   rE   rF   zdiscord.ThreadrG   rL   r7   r5   r&   r&   g  s    
r7   r&   c                  T    e Zd ZdZ ej
                  d      Zd Zd ZeddZ	d	dZ
y)
r   a  Converts to a :class:`~discord.Colour`.

    .. versionchanged:: 1.5
        Add an alias named ColorConverter

    The following formats are accepted:

    - ``0x<hex>``
    - ``#<hex>``
    - ``0x#<hex>``
    - ``rgb(<number>, <number>, <number>)``
    - Any of the ``classmethod`` in :class:`~discord.Colour`

        - The ``_`` in the name can be optionally replaced with spaces.

    Like CSS, ``<number>`` can be either 0-255 or 0-100% and ``<hex>`` can be
    either a 6 digit hex number or a 3 digit hex shortcut (e.g. #fff).

    .. versionchanged:: 1.5
         Raise :exc:`.BadColourArgument` instead of generic :exc:`.BadArgument`

    .. versionchanged:: 1.7
        Added support for ``rgb`` function and 3-digit hex shortcuts
    zTrgb\s*\((?P<r>[0-9]{1,3}%?)\s*,\s*(?P<g>[0-9]{1,3}%?)\s*,\s*(?P<b>[0-9]{1,3}%?)\s*\)c                   t        |      dk(  rdj                  d |D              n|}	 t        |d      }d|cxk  rdk  st        |       t        |      	 t	        j
                  |      S # t        $ r t        |      w xY w)	N    c              3  &   K   | ]	  }|d z    yw)   NrL   ).0is     r5   	<genexpr>z3ColourConverter.parse_hex_number.<locals>.<genexpr>  s     .a!e.s      )baser   i )value)rp   joinrY   BadColourArgumentr[   Color
ValueError)rB   r2   r   r   s       r5   parse_hex_numberz ColourConverter.parse_hex_number  s    25h-12Dbgg.X..(	."%E*(*'11 +'11 +
 ==u--  	.#H--	.s   /A0 0Bc                    |d   dk(  rAt        |d d       }d|cxk  rdk  st        |       t        |      t        d|dz  z        S t        |      }d|cxk  rdk  st        |       t        |      |S )N%r   rb      )rY   r   round)rB   r2   numberr   s       r5   parse_rgb_numberz ColourConverter.parse_rgb_number  s    ":s$E%#%'11 &'11,--FU!c!#H-- "#H--r7   )regexc               F   |j                  |      }|t        |      | j                  ||j                  d            }| j                  ||j                  d            }| j                  ||j                  d            }t        j
                  j                  |||      S )Nrgb)rP   r   r  rZ   r[   r   from_rgb)rB   r2   r  rP   redgreenblues          r5   	parse_rgbzColourConverter.parse_rgb  s    H%=#H--##Hekk#.>?%%hC0@A$$Xu{{3/?@}}%%c5$77r7   c                  K   |d   dk(  r| j                  |dd        S |dd dk(  r;|dd  }|j                  d      r| j                  |dd        S | j                  |      S |j                         }|dd dk(  r| j                  |      S |j	                  dd	      }t        t        j                  |d       }|j                  d
      s|t        j                  |      st        |       |       S w)Nr   ra   r   r   0xr   rgb rw   from_)r   
startswithlowerr  replacer/   r[   Colourinspectismethodr   )rB   rC   r2   restr   methods         r5   rD   zColourConverter.convert  s     A;#((!"66Aa=D AB<Ds#,,T!"X66((..nnq8u>>#&&kk#s#d3>>'"fnG<L<LV<T#C((xs   C0C2N)rC   r   r2   rE   rF   zdiscord.Colour)rH   rI   rJ   rK   rW   r   	RGB_REGEXr   r  r  rD   rL   r7   r5   r   r   {  s5    2 

_I	.
 ,5 8r7   r   c                      e Zd ZdZddZy)r   a  Converts to a :class:`~discord.Role`.

    All lookups are via the local guild. If in a DM context, the converter raises
    :exc:`.NoPrivateMessage` exception.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by mention.
    3. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.RoleNotFound` instead of generic :exc:`.BadArgument`
    c                t  K   |j                   }|s
t               | j                  |      xs t        j                  d|      }|r*|j                  t        |j                  d                  }n9t        j                  j                  |j                  j                         |      }|t        |      |S w)Nz<@&([0-9]{15,20})>$r   r   )r4   NoPrivateMessagerQ   rW   rP   get_rolerY   rZ   r[   rs   rt   _rolesr   RoleNotFound)rB   rC   r2   r4   rP   r3   s         r5   rD   zRoleConverter.convert  s     		"$$""8, 
"H1
 ^^CA$78F]]&&u||':':'<8&LF>x((s   B6B8N)rC   r   r2   rE   rF   zdiscord.RolerG   rL   r7   r5   r   r     s    r7   r   c                      e Zd ZdZddZy)r   z#Converts to :class:`~discord.Game`.c                6   K   t        j                  |      S w)Nr   )r[   GamerA   s      r5   rD   zGameConverter.convert  s     ||**s   N)rC   r   r2   rE   rF   zdiscord.GamerG   rL   r7   r5   r   r     s
    -+r7   r   c                      e Zd ZdZddZy)r   zConverts to a :class:`~discord.Invite`.

    This is done via an HTTP request using :meth:`.Bot.fetch_invite`.

    .. versionchanged:: 1.5
         Raise :exc:`.BadInviteArgument` instead of generic :exc:`.BadArgument`
    c                   K   	 |j                   j                  |       d {   }|S 7 # t        $ r}t        |      |d }~ww xY wwr-   )r0   fetch_invite	ExceptionBadInviteArgument)rB   rC   r2   inviteexcs        r5   rD   zInviteConverter.convert  sH     	777//99FM : 	7#H-36	7s0   A+ )+ A+ 	AA  AAN)rC   r   r2   rE   rF   zdiscord.InviterG   rL   r7   r5   r   r     s    7r7   r   c                      e Zd ZdZddZy)r   zConverts to a :class:`~discord.Guild`.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by name. (There is no disambiguation for Guilds with multiple matching names).

    .. versionadded:: 1.7
    c                *  K   | j                  |      }d }|5t        |j                  d            }|j                  j	                  |      }|Bt
        j                  j                  |j                  j                  |      }|t        |      |S w)Nr   r   )
rQ   rY   rZ   r0   r   r[   rs   rt   r.   GuildNotFound)rB   rC   r2   rP   r3   r   s         r5   rD   zGuildConverter.convert  s     ""8,5;;q>*HWW&&x0F>]]&&sww~~H&EF~#H--s   BBN)rC   r   r2   rE   rF   zdiscord.GuildrG   rL   r7   r5   r   r     s    r7   r   c                      e Zd ZdZddZy)r"   a  Converts to a :class:`~discord.Emoji`.

    All lookups are done for the local guild first, if available. If that lookup
    fails, then it checks the client's global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by extracting ID from the emoji.
    3. Lookup by name

    .. versionchanged:: 1.5
         Raise :exc:`.EmojiNotFound` instead of generic :exc:`.BadArgument`
    c                  K   | j                  |      xs t        j                  d|      }d }|j                  }|j                  }|[|r+t
        j                  j                  |j                  |      }|Wt
        j                  j                  |j                  |      }n+t        |j                  d            }|j                  |      }|t        |      |S w)Nz<a?:\w{1,32}:([0-9]{15,20})>$r   r   )rQ   rW   rP   r0   r4   r[   rs   rt   emojisrY   rZ   	get_emojiEmojiNotFound)rB   rC   r2   rP   r3   r0   r4   emoji_ids           r5   rD   zEmojiConverter.convert8  s     ""8, 
,h1
 gg		= **5<<h*G~ **3::H*E5;;q>*H ]]8,F>))s   CCN)rC   r   r2   rE   rF   zdiscord.EmojirG   rL   r7   r5   r"   r"   (  s    r7   r"   c                      e Zd ZdZddZy)r#   zConverts to a :class:`~discord.PartialEmoji`.

    This is done by extracting the animated flag, name and ID from the emoji.

    .. versionchanged:: 1.5
         Raise :exc:`.PartialEmojiConversionFailure` instead of generic :exc:`.BadArgument`
    c                H  K   t        j                  d|      }|r|t        |j                  d            }|j                  d      }t	        |j                  d            }t
        j                  j                  |j                  j                  |||      S t        |      w)Nz!<(a?):(\w{1,32}):([0-9]{15,20})>$r   r   r   )animatedrf   rV   )rW   rP   boolrZ   rY   r[   PartialEmoji
with_stater0   r   PartialEmojiConversionFailure)rB   rC   r2   rP   emoji_animated
emoji_namer3  s          r5   rD   zPartialEmojiConverter.convert\  s     =xH!%++a.1NQJ5;;q>*H''22##'	 3   ,H55s   B B"N)rC   r   r2   rE   rF   zdiscord.PartialEmojirG   rL   r7   r5   r#   r#   S  s    6r7   r#   c                      e Zd ZdZddZy)r(   a3  Converts to a :class:`~discord.GuildSticker`.

    All lookups are done for the local guild first, if available. If that lookup
    fails, then it checks the client's global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    3. Lookup by name

    .. versionadded:: 2.0
    c                  K   | j                  |      }d }|j                  }|j                  }|[|r+t        j                  j                  |j                  |      }|Wt        j                  j                  |j                  |      }n+t        |j                  d            }|j                  |      }|t        |      |S w)Nr   r   )rQ   r0   r4   r[   rs   rt   stickersrY   rZ   get_stickerGuildStickerNotFound)rB   rC   r2   rP   r3   r0   r4   
sticker_ids           r5   rD   zGuildStickerConverter.convert|  s     ""8,gg		= **5>>*I~ **3<<h*GU[[^,J __Z0F>&x00s   CCN)rC   r   r2   rE   rF   zdiscord.GuildStickerrG   rL   r7   r5   r(   r(   n  s    r7   r(   c                  >    e Zd ZdZddddd	 	 	 	 	 	 	 	 	 ddZd	dZy)
r)   au  Converts the argument to mention scrubbed version of
    said content.

    This behaves similarly to :attr:`~discord.Message.clean_content`.

    Attributes
    ----------
    fix_channel_mentions: :class:`bool`
        Whether to clean channel mentions.
    use_nicknames: :class:`bool`
        Whether to use nicknames when transforming mentions.
    escape_markdown: :class:`bool`
        Whether to also escape special markdown characters.
    remove_markdown: :class:`bool`
        Whether to also remove special markdown characters. This option is not supported with ``escape_markdown``

        .. versionadded:: 1.7
    FTfix_channel_mentionsuse_nicknamesescape_markdownremove_markdownc               <    || _         || _        || _        || _        y r-   rD  )rB   rE  rF  rG  rH  s        r5   __init__zclean_content.__init__  s$     %9!*..r7   c                   	K   j                   j                  rd
 fd}d
fd}nd
fd}d
d} j                  rj                  rd
fd}nd
d}||||d	d	fd}t        j                  d	||      } j
                  r t        j                  j                  |      }n+ j                  rt        j                  j                  |      }t        j                  j                  |      S w)Nc                    d nt        j                  |       xs j                  j                  |       }|r)dj                  r|j
                   S |j                   S dS NrU   r   z@deleted-user)r   r   r4   r   rF  display_namerf   )rV   rk   rC   msgrB   s     r5   resolve_memberz-clean_content.convert.<locals>.resolve_member  sr    KDZ-L.YY))"- 
  $*<*<IJBC&&IJ )r7   c                    d nt        j                  |       xs j                  j                  |       }|rd|j                   S dS )NrU   r   @deleted-role)r   r   r4   r  rf   )rV   r  rC   rO  s     r5   resolve_rolez+clean_content.convert.<locals>.resolve_role  sL    KDZ-L,YY''+  ()166(|=o=r7   c                    d nt        j                  |       xs j                  j                  |       }|rd|j                   S dS rM  )r   r   r0   r   rf   )rV   rk   rC   rO  s     r5   rP  z-clean_content.convert.<locals>.resolve_member  sL    KDZ-L*WW%%b)  ()166(|=o=r7   c                     y)NrR  rL   rU   s    r5   rS  z+clean_content.convert.<locals>.resolve_role  s    &r7   c                `    j                   j                  |       }|rd|j                   S dS )Nra   z#deleted-channel)r4   r   rf   )rV   r   rC   s     r5   resolve_channelz.clean_content.convert.<locals>.resolve_channel  s/    II))"-'(166(|@.@@r7   c                    d|  dS )Nz<#>rL   rU   s    r5   rW  z.clean_content.convert.<locals>.resolve_channel  s    B4qz!r7   )r   z@!ra   z@&c                D    | d   }t        | d         } |   |      }|S )Nr   r   )rY   )rP   r   rV   transformed
transformss       r5   replz#clean_content.convert.<locals>.repl  s0    8DU1XB**T*2.Kr7   z<(@[!&]?|#)([0-9]{15,20})>)rV   rY   rF   rE   )rP   zre.MatchrF   rE   )
r   r4   rE  rW   subrG  r[   rs   rH  escape_mentions)
rB   rC   r2   rP  rS  rW  r]  r3   rO  r\  s
   ``      @@r5   rD   zclean_content.convert  s     kk99>>' $$A"    	

	 5tXF]]226:F!!]]226:F }},,V44s   C1C7N)
rE  r7  rF  r7  rG  r7  rH  r7  rF   None)rC   r   r2   rE   rF   rE   )rH   rI   rJ   rK   rJ  rD   rL   r7   r5   r)   r)     sQ    , &+" % %/ #/ 	/
 / / 
/?5r7   r)   c                  *    e Zd ZdZdZddZd ZddZy)	r*   a6  A special converter that greedily consumes arguments until it can't.
    As a consequence of this behaviour, most input errors are silently discarded,
    since it is used as an indicator of when to stop parsing.

    When a parser error is met the greedy converter stops converting, undoes the
    internal string parsing routine, and continues parsing regularly.

    For example, in the following code:

    .. code-block:: python3

        @commands.command()
        async def test(ctx, numbers: Greedy[int], reason: str):
            await ctx.send("numbers: {}, reason: {}".format(numbers, reason))

    An invocation of ``[p]test 1 2 3 4 5 6 hello`` would pass ``numbers`` with
    ``[1, 2, 3, 4, 5, 6]`` and ``reason`` with ``hello``\.

    For more information, check :ref:`ext_commands_special_converters`.
    	converterc                   || _         y r-   rb  rB   rc  s     r5   rJ  zGreedy.__init__  s	    "r7   c                b    t        | j                  dt        | j                              }d| dS )NrH   Greedy[])r/   rc  reprre  s     r5   __repr__zGreedy.__repr__  s,    DNNJT^^8LM	1%%r7   c                   t        |t              s|f}t        |      dk7  rt        d      |d   }t	        |dd       }t	        |dd      }t        |      st        |t              s|t        d      |t        t        d       fv s|t        u rt        d|j                   d	      |t        u rt        d       |v rt        d|d	       | |
      S )Nr   z(Greedy[...] only takes a single argumentr   
__origin____args__rL   z3Greedy[...] expects a type or a Converter instance.rg  z] is invalid.rb  )r   tuplerp   	TypeErrorr/   callabler   rE   r   r*   rH   r   )clsparamsrc  originargss        r5   __class_getitem__zGreedy.__class_getitem__  s    &%(YFv;!FGG1I	L$7y*b1 Y)Y/!QRRd4j))Vv-=gi&8&8%9GHHU?tDzT1gi]-@AAY''r7   N)rc  r8   )rr  ztuple[T] | TrF   z	Greedy[T])rH   rI   rJ   rK   	__slots__rJ  rj  ru  rL   r7   r5   r*   r*     s    * I#&(r7   r*   c                L    | j                         }|dv ry|dv ryt        |      )N)yesytruet1enableonT)nonfalsef0disableoffF)r  BadBoolArgument)r2   lowereds     r5   _convert_to_boolr  1  s1    nnG@@	D	Dg&&r7   c                    | j                   }|| j                  u rI| j                  | j                  ur+| j                  t        }|S t	        | j                        }|S t        }|S r-   )
annotationemptydefaultrE   r   )paramrc  s     r5   get_converterr  ;  sd      IEKK==+$}}4I  ;?u}}:MI  Ir7   )_GenericAliasc               b    t        | t              xr t        | t              xs t        | |      S r-   )r   r   
issubclassr   )tpr  s     r5   is_generic_typer  H  s'    b$;Jr7$;\z"m?\\r7   zdict[type[Any], Any]CONVERTER_MAPPINGc                p  K   |t         u rt        |      S 	 |j                  }|9|j                  d      r(|j	                  d      st
        j                  ||      }	 	 t        j                  |      rht        |t              rXt        j                  |j                        r|j                  | |       d {   S  |       j                  | |       d {   S t        |t              r|j                  | |       d {   S 	 	  ||      S # t        $ r Y w xY w7 f7 I7 !# t        $ r  t         $ r}t#        ||      |d }~ww xY w# t        $ r  t         $ rU}	 |j$                  }n%# t        $ r |j&                  j$                  }Y nw xY wt)        d| d|j*                   d      |d }~ww xY ww)Nzdiscord.rc  zConverting to "z" failed for parameter "z".)r7  r  rI   r  endswithr  rt   AttributeErrorr  isclassr  r   r  rD   r   CommandErrorr'  ConversionErrorrH   	__class__BadArgumentrf   )rC   rc  r2   r  moduler*  rf   s          r5   _actual_conversionr  d  s     D))D%% j)&//+2N)--iCI7??9%*Y	*J	 1 12&..sH===&[00h???	9-"**3999 .""-   >?9  7i-367
   	0%%D 	0&&//D	0 dV#;EJJ<rJ
	s   F6D ;F6AD% 8D9D% <F6=D% D!D% F6%D% D#D% F6E F6	DF6DF6D% !D% #D% %E	7EE		F6F3E,+F.,FF.F F..F33F6c                v  K   t        |dd      }|t        u rg }t        d      }|j                  }|D ]}  }||u r]|j                  |j
                  k7  rD| j                  j                          |j                  |j                  u rdc S |j                  c S 	 t        | |||       d{   }	|	c S  t        |||      |t        u r>g }i }|j                  }|D ]  }t        |      }	 ||   }	|	|k(  s|	c S  t%        |||      |t'        |      r|}t!        | |||       d{   S 7 # t        $ r}
|j                  |
       Y d}
~
d}
~
ww xY w# t        $ rV 	 t!        | |||       d{  7  }	|	||<   n5# t        $ r)}
|j                  |
       t#               ||<   Y d}
~
Y d}
~
ww xY wY w xY w7 w)a  |coro|

    Runs converters for a given converter, argument, and parameter.

    This function does the same work that the library does under the hood.

    .. versionadded:: 2.0

    Parameters
    ----------
    ctx: :class:`Context`
        The invocation context to run the converters under.
    converter: Any
        The converter to run, this corresponds to the annotation in the function.
    argument: Optional[:class:`str`]
        The argument to convert to.
    param: :class:`inspect.Parameter`
        The parameter being converted. This is mainly for error reporting.

    Returns
    -------
    Any
        The resulting conversion.

    Raises
    ------
    CommandError
        The converter failed to convert.
    rl  N)r/   r   r   rm  kindVAR_POSITIONALviewundor  r  r+   r  appendBadUnionArgumentr	   KeyErrorr  objectBadLiteralArgumentr  )rC   rc  r2   r  rs  errors	_NoneType
union_argsconvr   r*  conversionsliteral_argsliteralliteral_types                  r5   r+   r+     s    @ Yd3FJ	''
 	D y UZZ53G3G%G$}};tNN,S$%HH 	  uj&99 ))# 	G=L
6#L1 	$ !f== oi8	#CHeDDDQ I #c""#   66"4S,RW"XXXE 16K- $ MM#&06K-
 .6. Es   BF9D-)D+*D-.:F9)E.F942F9&F7'F9+D--	E6EF9EF9	F4E<0E31E<6F4<	F.F)#F4'F9)F..F41F93F44F9)r2   rE   rF   r7  )r  inspect.ParameterrF   r   )r  r   r  r   rF   r7  )rC   r   r2   rE   r  r  )rC   r   r2   z
str | Noner  r  )YrK   
__future__r   r  rW   typingr   r   r   r   r   r	   r
   r   r   r   r[   r  discord.messager   contextr   __all__r6   rs   rt   r   r8   r9   r   r   r;   r   r=   r   r   rO   r%   r\   r   Memberr   Userr   r   r   Messager   r'   r   r   r   r    r   r!   r   r$   r   r   r&   r  r   r   Roler   r#  r   Inviter   Guildr   Emojir"   r8  r#   GuildStickerr(   rE   r)   r*   r  r  r   r  r  r  __annotations__r  r+   rL   r7   r5   <module>r     s  2 #  	    9 < ]]
CLv&T112T( "M "M "MJ BJJ)*	))D/ ))k'..1 )4\k'..1 \~>K- >B9Fi(>(>? 9Fx.{7??3 .DNK(@(@A Nb
;w':':; 
,
K(<(<= 
,
K(<(<= 
*
{7+B+BC 
,
K(<(<= 
*
k'..1 
(Ri/ Rj !K- D+Igll+ +7i/ 7"[/ 6([/ (V6Ig&:&:; 66$K(<(<= $N`5IcN `5F6(T!W 6(r' T!W 7D ]+NNO+NNO+ LL-+ OO%	+
 3+ -+ NNO+ MM>+ LL-+ LL-+ NNO+ /+ /+ MM>+ /+  5!+" /#+$ NNOKK3/)+ ' 0)	)'*)3D)XWE	WE'1WE:KWEr7   