
    i                       U d Z ddlmZ ddl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mZmZmZmZmZ ddlZddlZddlT er ddlmZ ddlmZ dd	lmZ dd
lm Z m!Z! ddl"m#Z# dZ$djdZ%ej&        j'        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j0        d          Z1 G d d e/e*                   Z2 G d! d"e2ej3                           Z4 G d# d$e2ej5                           Z6 G d% d&e2ej7                           Z8 G d' d(e/ej9                           Z: G d) d*e2ej;                           Z< G d+ d,e2ej+        j,                           Z= G d- d.e2ej>                           Z? G d/ d0e2ej@                           ZA G d1 d2e2ejB                           ZC G d3 d4e2ejD                           ZE G d5 d6e2ej                           ZF G d7 d8e2ejG                           ZH G d9 d:e/ejI                           ZJeJZK G d; d<e2ejL                           ZM G d= d>e/ejN                           ZO G d? d@e/ejP                           ZQ G dA dBe2ejR                           ZS G dC dDe2ejT                           ZU G dE dFe/ejV                           ZW G dG dHe2ejX                           ZYerej        ZZn G dI dJe/e[                   ZZ G dK dLe2ej\                           Z] G dM dNe2ej^                           Z_ G dO dPe/e[                   Z` G dQ dRee)                   ZaerddSlbmcZd n G dT dU          ZddkdWZe efee)                   ZgegdXdld\Zhi ej3        e4ej5        e6ej7        e8ej;        e<ej9        e:ej>        e?ejP        eQejR        eSejL        eMejN        eOejI        eJej@        eAejB        eCejT        eUejV        eWejD        eEej        eFej+        j,        e=ejX        eYej\        e]ejG        eHej^        e_iZid]ejd^<   dmddZkedndg            Zledodh            ZldodiZldS )pa:  
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)TYPE_CHECKINGAnyDictGenericIterableListLiteralOptionaloverloadProtocolTupleTypeTypeVarUnionruntime_checkable   )*)Channel)Thread)	Parameter)BotT_Bot)Context)	ConverterObjectConverterMemberConverterUserConverterMessageConverterPartialMessageConverterTextChannelConverterInviteConverterGuildConverterRoleConverterGameConverterColourConverterColorConverterVoiceChannelConverterStageChannelConverterEmojiConverterPartialEmojiConverterCategoryChannelConverterForumChannelConverterIDConverterThreadConverterGuildChannelConverterGuildStickerConverterScheduledEventConverterSoundboardSoundConverterclean_contentGreedyRange	Timestamprun_convertersbotr   getterstrargumentr   returnc                \    d }| j         D ]!} t          ||          |          }|r|c S "|S N)guildsgetattr)r9   r:   r<   resultguilds        _/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ext/commands/converter.py_get_from_guildsrE   _   sL    F  '''11 	MMM	M    TT_coT)	covariantCT)boundTTc                      e Zd ZdZd
dZd	S )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>`.
    ctxContext[BotT]r<   r;   r=   rH   c                $   K   t          d          )am  |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.

        Note that if this method is called manually, :exc:`Exception`
        should be caught to handle the cases where a subclass does
        not explicitly inherit from :exc:`.CommandError`.

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

        Raises
        -------
        CommandError
            A generic exception occurred when converting the argument.
        BadArgument
            The converter failed to convert the argument.
        z'Derived classes need to implement this.)NotImplementedErrorselfrN   r<   s      rD   convertzConverter.convert{   s      6 ""KLLLrF   N)rN   rO   r<   r;   r=   rH   __name__
__module____qualname____doc__rT    rF   rD   r   r   o   s8         M M M M M MrF   r   z([0-9]{15,20})$c                  $    e Zd Zed             ZdS )r.   c                6    t                               |           S r?   )	_ID_REGEXmatch)r<   s    rD   _get_id_matchzIDConverter._get_id_match   s    x(((rF   N)rV   rW   rX   staticmethodr_   rZ   rF   rD   r.   r.      s-        ) ) \) ) )rF   r.   c                      e Zd ZdZd
dZd	S )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.
    rN   rO   r<   r;   r=   discord.Objectc                   K   |                      |          pt          j        d|          }|t          |          t	          |                    d                    }t          j        |          S )Nz <(?:@(?:!|&)?|#)([0-9]{15,20})>$r   id)r_   rer^   ObjectNotFoundintgroupdiscordObject)rS   rN   r<   r^   rB   s        rD   rT   zObjectConverter.convert   si      ""8,,g9\^f0g0g= ***U[[^^$$~((((rF   N)rN   rO   r<   r;   r=   rb   rU   rZ   rF   rD   r   r      s2        
 
) ) ) ) ) )rF   r   c                  *    e Zd ZdZddZddZddZdS )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 username#discriminator (deprecated).
    4. Lookup by username#0 (deprecated, only gets users that migrated from their discriminator).
    5. Lookup by user name.
    6. Lookup by global name.
    7. Lookup by guild 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.

    .. deprecated:: 2.3
        Looking up users by discriminator will be removed in a future version due to
        the removal of discriminators in an API change.
    rC   discord.Guildr<   r;   r=   Optional[discord.Member]c                d  	K   |j         j        j        }                    d          \  	}	s	c	dk    s't	                    dk    r                                r		}	fd}n}fd}|                    |d|           d {V }t          j        	                    ||          S )N#0   c                0    | j         k    o
| j        k    S r?   namediscriminator)mrv   usernames    rD   <lambda>z4MemberConverter.query_member_named.<locals>.<lambda>       !&H"4"YM9Y rF   c                F    | j         k    p| j        k    p
| j        k    S r?   )ru   global_namenick)rw   r<   s    rD   ry   z4MemberConverter.query_member_named.<locals>.<lambda>   s)    !&H"4"g8Q"gUVU[_gUg rF   d   )limitcache)
_statemember_cache_flagsjoined
rpartitionlenisdigitquery_membersrj   utilsfind)
rS   rC   r<   r   _lookup	predicatemembersrv   rx   s
     `     @@rD   query_member_namedz"MemberConverter.query_member_named   s      /6%-%8%8%=%="!]  	>&.#M8CC$6$6!$;$;@U@U@W@W$;FYYYYYIIFggggI++F#U+KKKKKKKK}!!)W555rF   r9   r   user_idrh   c                t  K   |                     |j                  }|j        j        j        }|                                rL	 |                    |           d {V }n# t          j        $ r Y d S w xY w|r|	                    |           |S |
                    d|g|           d {V }|sd S |d         S )N)shard_idr   )r   user_idsr   r   )_get_websocketr   r   r   r   is_ratelimitedfetch_memberrj   HTTPException_add_memberr   )rS   r9   rC   r   wsr   memberr   s           rD   query_member_by_idz"MemberConverter.query_member_by_id   s      88/6 
	$11'::::::::(   tt  *!!&)))M ++!wiu+UUUUUUUU 	4qzs   A   A32A3rN   rO   discord.Memberc                  K   |j         }|                     |          pt          j        d|          }|j        }d }d }|*|r|                    |          }nxt          |d|          }nft          |                    d                    }|r1|	                    |          pt          |j        j        |          }nt          |d|          }t          |t          j                  s^|t!          |          ||                     |||           d {V }n|                     ||           d {V }|st!          |          |S )N<@!?([0-9]{15,20})>$get_member_namedr   rd   
get_member)r9   r_   rf   r^   rC   r   rE   rh   ri   r   
_utils_getmessagementions
isinstancerj   MemberMemberNotFoundr   r   )rS   rN   r<   r9   r^   rC   rB   r   s           rD   rT   zMemberConverter.convert   ss     g""8,,[9PRZ0[0[	= M//99)#/A8LL%++a..))G F))'22bjAUZa6b6b6b)#|WEE&'.11 
	/}$X..."#66sE7KKKKKKKK#66uhGGGGGGGG /$X...rF   N)rC   rm   r<   r;   r=   rn   )r9   r   rC   rm   r   rh   r=   rn   )rN   rO   r<   r;   r=   r   )rV   rW   rX   rY   r   r   rT   rZ   rF   rD   r   r      sZ         66 6 6 6$   *           rF   r   c                      e Zd ZdZd
dZd	S )r   a9  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 username#discriminator (deprecated).
    4. Lookup by username#0 (deprecated, only gets users that migrated from their discriminator).
    5. Lookup by user name.
    6. Lookup by global 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.

    .. deprecated:: 2.3
        Looking up users by discriminator will be removed in a future version due to
        the removal of discriminators in an API change.
    rN   rO   r<   r;   r=   discord.Userc                  	
K   |                                pt          j        d          }d }|j        }|t	          |                    d                    }|j                            |          pt          |j	        j
        |          }|E	 |j                            |           d {V }n## t          j        $ r t                    d w xY w|S                     d          \  
}	
s
	c	
	dk    s't!          	          dk    r	                                r	
fd}nfd}t          j                            ||j                                                  }|t                    |S )	Nr   r   rd   rp   rq   rr   c                0    | j         k    o
| j        k    S r?   rt   )urv   rx   s    rD   ry   z'UserConverter.convert.<locals>.<lambda>Q  rz   rF   c                0    | j         k    p
| j        k    S r?   )ru   r|   )r   r<   s    rD   ry   z'UserConverter.convert.<locals>.<lambda>S  s    !&H"4"Q8Q rF   )r_   rf   r^   r   rh   ri   r9   get_userr   r   r   
fetch_userrj   r   UserNotFoundr   r   r   r   r   _usersvalues)rS   rN   r<   r^   rB   stater   r   r   rv   rx   s     `      @@rD   rT   zUserConverter.convert:  s     ""8,,[9PRZ0[0[
%++a..))GW%%g..^*S[=QV]2^2^2^F~;#&7#5#5g#>#>>>>>>>FF, ; ; ;&x00d:; M%-%8%8%=%="!]  	>&.#M8CC$6$6!$;$;@U@U@W@W$;YYYYYIIQQQQI##Iu|/B/B/D/DEE>x(((s    B6 6 CN)rN   rO   r<   r;   r=   r   rU   rZ   rF   rD   r   r      s2         2     rF   r   c                  J    e Zd ZdZedd            Zedd            ZddZdS )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
    rN   rO   r<   r;   r=   Tuple[Optional[int], int, int]c                   t          j        d          }t          j        d          }|                    |          p|                    |          }|st          |          |                                }t
          j                            |d          p| j        j	        }t          |d                   }|                    d          }|| j        o| 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)rf   compiler^   MessageNotFound	groupdictrj   r   _get_as_snowflakechannelre   rh   getrC   )	rN   r<   id_regex
link_regexr^   datar   r   r   s	            rD   _get_id_matchesz'PartialMessageConverter._get_id_matchesh  s    :`aaZM
 


 x((FJ,<,<X,F,F 	,!(+++  ]44T<HHZCKN
l+,,
88J''y1SY\HHHH8}}HZ//rF   r   Optional[int]r    Optional[Union[Channel, Thread]]c                    || j         S |3| j                            |          }|d S |                    |          S | j                            |          S r?   )r   r9   	get_guild_resolve_channelget_channel)rN   r   r   rC   s       rD   r   z(PartialMessageConverter._resolve_channel  sa     ;G%%h//E}t))*555w"":...rF   discord.PartialMessagec                   K   |                      ||          \  }}}|                     |||          }|rt          |t          j        j                  st          |          t          j        ||          S )N)r   re   )r   r   r   rj   abcMessageableChannelNotFoundPartialMessage)rS   rN   r<   r   r   r   r   s          rD   rT   zPartialMessageConverter.convert  s{      +/+?+?X+N+N(*j''XzBB 	.j'+2IJJ 	.!*---%g*EEEErF   N)rN   rO   r<   r;   r=   r   )rN   rO   r   r   r   r   r=   r   )rN   rO   r<   r;   r=   r   )rV   rW   rX   rY   r`   r   r   rT   rZ   rF   rD   r    r    \  sx        	 	 0 0 0 \0, / / / \/F F F F F FrF   r    c                      e Zd ZdZd
dZd	S )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`
    rN   rO   r<   r;   r=   discord.Messagec                  K   t                               ||          \  }}}|j        j                            |          }|r|S t                               |||          }|rt          |t          j        j	                  st          |          	 |                    |           d {V S # t          j        $ r t          |          t          j        $ r t          |          w xY wr?   )r    r   r9   _connection_get_messager   r   rj   r   r   r   fetch_messageNotFoundr   	ForbiddenChannelNotReadable)rS   rN   r<   r   r   r   r   r   s           rD   rT   zMessageConverter.convert  s     +B+R+RSVX`+a+a(*j'%22:>> 	N)::3*UU 	.j'+2IJJ 	.!*---	. ..z::::::::: 	, 	, 	,!(+++  	. 	. 	.$W---	.s   B- -<C)N)rN   rO   r<   r;   r=   r   rU   rZ   rF   rD   r   r     s2         . . . . . .rF   r   c                  b    e Zd ZdZddZedd
            Zedd            Zedd            ZdS )r0   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 channel URL.
    4. Lookup by name.

    .. versionadded:: 2.0

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.abc.GuildChannelc                T   K   |                      ||dt          j        j                  S )Nchannels)r   rj   r   GuildChannelrR   s      rD   rT   zGuildChannelConverter.convert  s%      $$S(J@XYYYrF   Optional[re.Match[str]]c                T    t          j        d          }|                    |           S )Nz|https?://(?:(?:ptb|canary|www)\.)?discord(?:app)?\.com/channels/(?:[0-9]{15,20}|@me)/([0-9]{15,20})(?:/(?:[0-9]{15,20})/?)?$)rf   r   r^   )r<   r   s     rD   _parse_from_urlz%GuildChannelConverter._parse_from_url  s.    Z8
 


 )))rF   	attributetypeType[CT]rJ   c                n   | j         }t                                        p.t          j        d          pt
                                        }d }| j        }|m|r2t          ||          }t          j
                            |          }nfd}	t          j
                            |	|                                          }nKt          |                    d                    }
|r|                    |
          }nt#          |d|
          }t%          |          st'                    |S )N<#([0-9]{15,20})>$ru   c                :    t          |           o
| j        k    S r?   )r   ru   )cr<   r   s    rD   checkz5GuildChannelConverter._resolve_channel.<locals>.check  s    %a..E16X3EErF   r   r   )r9   r.   r_   rf   r^   r0   r   rC   rA   rj   r   r   r   get_all_channelsrh   ri   r   rE   r   r   )rN   r<   r   r   r9   r^   rB   rC   iterabler   r   s    ` `       rD   r   z&GuildChannelConverter._resolve_channel  sK   g %%h// ?x-x88?$44X>> 	
 	= K)0	)B)B'.}'8'8'8'Q'QF F F F F F !++E33G3G3I3IJJU[[^^,,J J**:66)#}jII&$'' 	,!(+++rF   Type[TT]rL   c                   t                               |          p.t          j        d|          pt                              |          }d }| j        }|4|r1t          ||          }t          j	        
                    ||          }n9t          |                    d                    }|r|                    |          }|rt          ||          st          |          |S )Nr   r   r   )r.   r_   rf   r^   r0   r   rC   rA   rj   r   r   rh   ri   
get_threadr   ThreadNotFound)	rN   r<   r   r   r^   rB   rC   r   	thread_ids	            rD   _resolve_threadz%GuildChannelConverter._resolve_thread  s     %%h// ?x-x88?$44X>> 	
 	= R)0	)B)B'.}'8'8'8'Q'QEKKNN++I 5)))44 	+Z55 	+ ***rF   N)rN   rO   r<   r;   r=   r   )r<   r;   r=   r   )
rN   rO   r<   r;   r   r;   r   r   r=   rJ   )
rN   rO   r<   r;   r   r;   r   r   r=   rL   )	rV   rW   rX   rY   rT   r`   r   r   r   rZ   rF   rD   r0   r0     s         $Z Z Z Z * * * \* ! ! ! \!F    \  rF   r0   c                      e Zd ZdZd
dZd	S )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 channel URL.
    4. Lookup by name

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

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.TextChannelc                T   K   t                               ||dt          j                  S )Ntext_channels)r0   r   rj   TextChannelrR   s      rD   rT   zTextChannelConverter.convert'  s$      $55c8_V]VijjjrF   N)rN   rO   r<   r;   r=   r   rU   rZ   rF   rD   r!   r!     s8         &k k k k k krF   r!   c                      e Zd ZdZd
dZd	S )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 channel URL.
    4. Lookup by name

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

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.VoiceChannelc                T   K   t                               ||dt          j                  S )Nvoice_channels)r0   r   rj   VoiceChannelrR   s      rD   rT   zVoiceChannelConverter.convert?  %      $55c8EUW^WklllrF   N)rN   rO   r<   r;   r=   r   rU   rZ   rF   rD   r(   r(   +  s8         &m m m m m mrF   r(   c                      e Zd ZdZd
dZd	S )r)   a  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 channel URL.
    4. Lookup by name

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.StageChannelc                T   K   t                               ||dt          j                  S )Nstage_channels)r0   r   rj   StageChannelrR   s      rD   rT   zStageChannelConverter.convertV  r   rF   N)rN   rO   r<   r;   r=   r   rU   rZ   rF   rD   r)   r)   C  s8         $m m m m m mrF   r)   c                      e Zd ZdZd
dZd	S )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 channel URL.
    4. Lookup by name

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.

    .. versionchanged:: 1.5
         Raise :exc:`.ChannelNotFound` instead of generic :exc:`.BadArgument`
    rN   rO   r<   r;   r=   discord.CategoryChannelc                T   K   t                               ||dt          j                  S )N
categories)r0   r   rj   CategoryChannelrR   s      rD   rT   z CategoryChannelConverter.convertn  s$      $55c8\SZSjkkkrF   N)rN   rO   r<   r;   r=   r  rU   rZ   rF   rD   r,   r,   Z  s8         &l l l l l lrF   r,   c                      e Zd ZdZd
dZd	S )r/   a  Converts 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 channel URL.
    4. Lookup by name.

    .. versionadded: 2.0

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.Threadc                T   K   t                               ||dt          j                  S )Nthreads)r0   r   rj   r   rR   s      rD   rT   zThreadConverter.convert  s"      $44S(Iw~^^^rF   N)rN   rO   r<   r;   r=   r  rU   rZ   rF   rD   r/   r/   r  s8         "_ _ _ _ _ _rF   r/   c                      e Zd ZdZd
dZd	S )r-   a  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 channel URL.
    4. Lookup by name

    .. versionadded:: 2.0

    .. versionchanged:: 2.4
        Add lookup by channel URL, accessed via "Copy Link" in the Discord client within channels.
    rN   rO   r<   r;   r=   discord.ForumChannelc                T   K   t                               ||dt          j                  S )Nforums)r0   r   rj   ForumChannelrR   s      rD   rT   zForumChannelConverter.convert  s#      $55c8XwOcdddrF   N)rN   rO   r<   r;   r=   r
  rU   rZ   rF   rD   r-   r-     s8         $e e e e e erF   r-   c                      e Zd ZdZd
dZd	S )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
    rN   rO   r<   r;   r=   discord.Colourc                t  K   	 t           j                            |          S # t          $ r |                                                    dd          }t          t           j        |d           }|                    d          s|t          j	        |          st          |           |            cY S w xY w)N r   from_)rj   Colourfrom_str
ValueErrorlowerreplacerA   
startswithinspectismethodBadColourArgument)rS   rN   r<   argmethods        rD   rT   zColourConverter.convert  s      	>**8444 	 	 	..""**344CW^S$77F~~g&& -&.@PQW@X@X.',,,688OOO	s   # BB76B7N)rN   rO   r<   r;   r=   r  rU   rZ   rF   rD   r&   r&     s2         2     rF   r&   c                      e Zd ZdZd
dZd	S )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`
    rN   rO   r<   r;   r=   discord.Rolec                  K   |j         }|st                      |                     |          pt          j        d|          }|r6|                    t          |                    d                              }n8t          j	        
                    |j                                        |          }|t          |          |S )Nz<@&([0-9]{15,20})>$r   r   )rC   NoPrivateMessager_   rf   r^   get_rolerh   ri   rj   r   r   _rolesr   RoleNotFound)rS   rN   r<   rC   r^   rB   s         rD   rT   zRoleConverter.convert  s      	 	%"$$$""8,,Z9OQY0Z0Z 	M^^CA$7$788FF]&&u|':':'<'<8&LLF>x(((rF   N)rN   rO   r<   r;   r=   r  rU   rZ   rF   rD   r$   r$     s2              rF   r$   c                      e Zd ZdZd
dZd	S )r%   z%Converts to a :class:`~discord.Game`.rN   rO   r<   r;   r=   discord.Gamec                0   K   t          j        |          S )Nr   )rj   GamerR   s      rD   rT   zGameConverter.convert  s      |****rF   N)rN   rO   r<   r;   r=   r&  rU   rZ   rF   rD   r%   r%     s.        //+ + + + + +rF   r%   c                      e Zd ZdZd
dZd	S )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`
    rN   rO   r<   r;   r=   discord.Invitec                   K   	 |j                             |           d {V }|S # t          $ r}t          |          |d }~ww xY wr?   )r9   fetch_invite	ExceptionBadInviteArgument)rS   rN   r<   inviteexcs        rD   rT   zInviteConverter.convert  sf      	77//99999999FM 	7 	7 	7#H--36	7s   !& 
AA  AN)rN   rO   r<   r;   r=   r*  rU   rZ   rF   rD   r"   r"     s2         7 7 7 7 7 7rF   r"   c                      e Zd ZdZd
dZd	S )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
    rN   rO   r<   r;   r=   rm   c                0  K   |                      |          }d }|<t          |                    d                    }|j                            |          }|<t
          j                            |j        j        |          }|t          |          |S Nr   r   )
r_   rh   ri   r9   r   rj   r   r   r@   GuildNotFound)rS   rN   r<   r^   rB   r   s         rD   rT   zGuildConverter.convert
  s      ""8,,5;;q>>**HW&&x00F>]&&sw~H&EEF~#H---rF   N)rN   rO   r<   r;   r=   rm   rU   rZ   rF   rD   r#   r#     s2              rF   r#   c                      e Zd ZdZd
dZd	S )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`
    rN   rO   r<   r;   r=   discord.Emojic                  K   |                      |          pt          j        d|          }d }|j        }|j        }|Q|r&t
          j                            |j        |          }|&t
          j                            |j        |          }n7t          |
                    d                    }|                    |          }|t          |          |S )Nz(<a?:[a-zA-Z0-9\_]{1,32}:([0-9]{15,20})>$r   r   )r_   rf   r^   r9   rC   rj   r   r   emojisrh   ri   	get_emojiEmojiNotFound)rS   rN   r<   r^   rB   r9   rC   emoji_ids           rD   rT   zEmojiConverter.convert*  s      ""8,,o9dfn0o0og	= H **5<h*GG~ **3:H*EE5;;q>>**H ]]8,,F>)))rF   N)rN   rO   r<   r;   r=   r6  rU   rZ   rF   rD   r*   r*     s2              rF   r*   c                      e Zd ZdZd
dZd	S )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`
    rN   rO   r<   r;   r=   discord.PartialEmojic                ^  K   t          j        d|          }|rt          |                    d                    }|                    d          }t	          |                    d                    }t
          j                            |j        j	        |||          S t          |          )Nz,<(a?):([a-zA-Z0-9\_]{1,32}):([0-9]{15,20})>$r         )animatedru   re   )rf   r^   boolri   rh   rj   PartialEmoji
with_stater9   r   PartialEmojiConversionFailure)rS   rN   r<   r^   emoji_animated
emoji_namer;  s          rD   rT   zPartialEmojiConverter.convertL  s      H(SS 	!%++a..11NQJ5;;q>>**H'22#n:RZ 3    ,H555rF   N)rN   rO   r<   r;   r=   r=  rU   rZ   rF   rD   r+   r+   C  s2         6 6 6 6 6 6rF   r+   c                      e Zd ZdZd
dZd	S )r1   a4  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.
    2. Lookup by name.

    .. versionadded:: 2.0
    rN   rO   r<   r;   r=   discord.GuildStickerc                  K   |                      |          }d }|j        }|j        }|Q|r&t          j                            |j        |          }|&t          j                            |j        |          }n7t          |                    d                    }|	                    |          }|t          |          |S )Nr   r   )r_   r9   rC   rj   r   r   stickersrh   ri   get_stickerGuildStickerNotFound)rS   rN   r<   r^   rB   r9   rC   
sticker_ids           rD   rT   zGuildStickerConverter.converti  s      ""8,,g	= J **5>*II~ **3<h*GGU[[^^,,J __Z00F>&x000rF   N)rN   rO   r<   r;   r=   rI  rU   rZ   rF   rD   r1   r1   [  s2              rF   r1   c                      e Zd ZdZd
dZd	S )r7   ab  Converts to a :class:`datetime.datetime`.

        Conversion is attempted based on the :ddocs:`Discord style timestamp <reference#message-formatting>` input format.

        .. versionadded:: 2.7

        .. warning::
            Due to a Discord limitation, no timezone is provided with the input. The UTC timezone has been supplanted instead.
        rN   rO   r<   r;   r=   datetime.datetimec                   K   t           j        j                            |          }|st	          |          t
          j                            t          |d                   t
          j        j	                  S )Nr   )tz)
rj   r   TIMESTAMP_PATTERNr^   BadTimestampArgumentdatetimefromtimestamprh   timezoneutc)rS   rN   r<   r^   s       rD   rT   zTimestamp.convert  s`      M399(CCE 5*8444$223uQx==XEVEZ2[[[rF   N)rN   rO   r<   r;   r=   rP  rU   rZ   rF   rD   r7   r7     s8        	 		\ 	\ 	\ 	\ 	\ 	\rF   r7   c                      e Zd ZdZd
dZd	S )r2   aB  Converts to a :class:`~discord.ScheduledEvent`.

    Lookups are done for the local guild if available. Otherwise, for a DM context,
    lookup is done by the global cache.

    The lookup strategy is as follows (in order):

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

    .. versionadded:: 2.0
    rN   rO   r<   r;   r=   discord.ScheduledEventc                *  K   |j         }|                     |          }d }|rdt          |                    d                    }|r|                    |          }n$|j        j        D ]}|                    |          }|r nnd}t          j        ||t          j	                  }|rt|j        
                    t          |                    d                              }|r7t          |                    d                    }|                    |          }nb|r't          j                            |j        |          }n9|j        j        D ],}t          j                            |j        |          }|r n-|t          |          |S )Nr   zjhttps?://(?:(ptb|canary|www)\.)?discord\.com/events/(?P<guild_id>[0-9]{15,20})/(?P<event_id>[0-9]{15,20})$)flagsr   event_idr   )rC   r_   rh   ri   get_scheduled_eventr9   r@   rf   r^   Ir   rj   r   r   scheduled_eventsScheduledEventNotFound)rS   rN   r<   rC   r^   rB   r]  patterns           rD   rT   zScheduledEventConverter.convert  s     	""8,,  	"5;;q>>**H 228<< W^  E"66x@@F / 
 HWhbd;;;E "))#ekk*.E.E*F*FGG A"5;;z#:#:;;H"66x@@F  "$]..u/EH.UUFF!$ " "!(!2!253IPX!2!Y!Y! "!E">(222rF   N)rN   rO   r<   r;   r=   rZ  rU   rZ   rF   rD   r2   r2     s2         ) ) ) ) ) )rF   r2   c                      e Zd ZdZd
dZd	S )r3   a-  Converts to a :class:`~discord.SoundboardSound`.

    Lookups are done for the local guild if available. Otherwise, for a DM context,
    lookup is done by the global cache.

    The lookup strategy is as follows (in order):

    1. Lookup by ID.
    2. Lookup by name.

    .. versionadded:: 2.5
    rN   rO   r<   r;   r=   discord.SoundboardSoundc                  K   |j         }|                     |          }d }|rUt          |                    d                    }|r|                    |          }no|j                            |          }nT|r't          j                            |j	        |          }n+t          j                            |j        j	        |          }|t          |          |S r3  )rC   r_   rh   ri   get_soundboard_soundr9   rj   r   r   soundboard_soundsSoundboardSoundNotFound)rS   rN   r<   rC   r^   rB   sound_ids          rD   rT   z SoundboardSoundConverter.convert  s      	""8,, 	U5;;q>>**H @33H==55h??  U **5+B*RR **37+D8*TT>)(333rF   N)rN   rO   r<   r;   r=   rd  rU   rZ   rF   rD   r3   r3     s2              rF   r3   c                  .    e Zd ZdZdddddddZddZdS )r4   aw  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_markdownrl  rB  rm  rn  ro  r=   Nonec               >    || _         || _        || _        || _        d S r?   rk  )rS   rl  rm  rn  ro  s        rD   __init__zclean_content.__init__  s*     %9!*..rF   rN   rO   r<   r;   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                            |          }n& j        rt          j                            |          }t          j        	                    |          S )Nre   rh   r=   r;   c                    t          j        |           pj                            |           }|rdj        r|j        n|j         ndS Nrd   @z@deleted-user)r   r   rC   r   rm  display_nameru   )re   rw   rN   msgrS   s     rD   resolve_memberz-clean_content.convert.<locals>.resolve_member  sV    s|333Osy7K7KB7O7OQRgMT-?K1>>QVMMMXggrF   c                    t          j        |           pj                            |           }|r
d|j         ndS )Nrd   rv  @deleted-role)r   role_mentionsrC   r"  ru   )re   rrN   rx  s     rD   resolve_rolez+clean_content.convert.<locals>.resolve_role#  sD    s0R888RCI<N<Nr<R<R'(=|16|||o=rF   c                    t          j        |           pj                            |           }|r
d|j         ndS ru  )r   r   r9   r   rw  )re   rw   rN   rx  s     rD   ry  z-clean_content.convert.<locals>.resolve_member)  sG    s|333Ksw7G7G7K7K/0E+1>+++oErF   c                    dS )Nr{  rZ   rd   s    rD   r~  z+clean_content.convert.<locals>.resolve_role-  s    &rF   c                T    j                             |           }|r
d|j         ndS )Nrp   z#deleted-channel)rC   r   ru   )re   r   rN   s     rD   resolve_channelz.clean_content.convert.<locals>.resolve_channel2  s0    I..r22'(@|16|||.@@rF   c                    d|  dS )Nz<#>rZ   rd   s    rD   r  z.clean_content.convert.<locals>.resolve_channel8  s    !Bzzz!rF   )rv  z@!rp   z@&r^   re.Matchc                d    | d         }t          | d                   } |         |          }|S )Nr   r?  )rh   )r^   r   re   transformed
transformss       rD   replz#clean_content.convert.<locals>.replB  s5    8DU1XB**T*2..KrF   z<(@[!&]?|#)([0-9]{15,20})>)re   rh   r=   r;   )r^   r  r=   r;   )
r   rC   rl  rf   subrn  rj   r   ro  escape_mentions)
rS   rN   r<   ry  r~  r  r  rB   rx  r  s
   ``      @@rD   rT   zclean_content.convert  s     k9 	'h h h h h h h h> > > > > > > >F F F F F F F' ' ' ' $ 		" 		"A A A A A A A" " " "    	
 

	 	 	 	 	 	 5tXFF 	;]226::FF! 	;]226::F },,V444rF   N)
rl  rB  rm  rB  rn  rB  ro  rB  r=   rp  )rN   rO   r<   r;   r=   r;   )rV   rW   rX   rY   rr  rT   rZ   rF   rD   r4   r4     s^         , &+" % %/ / / / / /55 55 55 55 55 55rF   r4   c                  F    e Zd ZdZdZddZdd	ZddZedd            Z	dS )r5   a  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`.

    .. note::

        For interaction based contexts the conversion error is propagated
        rather than swallowed due to the difference in user experience with
        application commands.
    	converterr  rG   r=   rp  c                   || _         d S r?   r  rS   r  s     rD   rr  zGreedy.__init__p  s    %rF   r;   c                ^    t          | j        dt          | j                            }d| dS )NrV   Greedy[])rA   r  reprr  s     rD   __repr__zGreedy.__repr__s  s0    DNJT^8L8LMM	%%%%%rF   paramsUnion[Tuple[T], T]	Greedy[T]c                z   t          |t                    s|f}t          |          dk    rt          d          |d         }t	          |dd          }t
          j        j        r |j        t          j
        u rt          |         }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   __args__rZ   
__origin__z3Greedy[...] expects a type or a Converter instance.r  z] is invalid.r  )r   tupler   	TypeErrorrA   rj   r   PY_310	__class__types	UnionTyper   callabler   r;   r   r5   rV   )clsr  r  argsorigins        rD   __class_getitem__zGreedy.__class_getitem__w  sE   &%(( 	YFv;;!FGGG1I	y*b11= 	$I$75?$J$JdIL$77## 	Sz)Y'G'G 	S6K]QRRRd4jj)))Vv-=-=Gi&8GGGHHHU??tDzzT11@i@@@AAAsY''''rF   r   c                    t          j        | j                  rLt          | j        t                    r2t          j        | j        j                  s|                                 S | j        S r?   )r  isclassr  
issubclassr   r  rT   rS   s    rD   constructed_converterzGreedy.constructed_converter  s`     ODN++	$4>955	$ $T^%;<<	$
 >>###~rF   N)r  rG   r=   rp  r=   r;   )r  r  r=   r  r=   r   )
rV   rW   rX   rY   	__slots__rr  r  r  propertyr  rZ   rF   rD   r5   r5   R  s         6 I& & & && & & &( ( ( (0    X  rF   r5   )	Annotatedc                  J    e Zd ZdZdddddZddZddZddZddZddZ	dS )r6   a<  A special converter that can be applied to a parameter to require a numeric
        or string type to fit within the range provided.

        During type checking time this is equivalent to :obj:`typing.Annotated` so type checkers understand
        the intent of the code.

        Some example ranges:

        - ``Range[int, 10]`` means the minimum is 10 with no maximum.
        - ``Range[int, None, 10]`` means the maximum is 10 with no minimum.
        - ``Range[int, 1, 10]`` means the minimum is 1 and the maximum is 10.
        - ``Range[float, 1.0, 5.0]`` means the minimum is 1.0 and the maximum is 5.0.
        - ``Range[str, 1, 10]`` means the minimum length is 1 and the maximum length is 10.

        Inside a :class:`HybridCommand` this functions equivalently to :class:`discord.app_commands.Range`.

        If the value cannot be converted to the provided type or is outside the given range,
        :class:`~.ext.commands.BadArgument` or :class:`~.ext.commands.RangeError` is raised to
        the appropriate error handlers respectively.

        .. versionadded:: 2.0

        Examples
        ----------

        .. code-block:: python3

            @bot.command()
            async def range(ctx: commands.Context, value: commands.Range[int, 10, 12]):
                await ctx.send(f'Your value is {value}')
        N)minmax
annotationr   r  Optional[Union[int, float]]r  r=   rp  c               j    || _         || _        || _        |r|r||k    rt          d          d S d S d S )Nz%minimum cannot be larger than maximum)r  r  r  r  )rS   r  r  r  s       rD   rr  zRange.__init__  s]     $.DO47DH47DH Is IsSyy GHHHI I I IyyrF   rN   rO   valuer;   Union[int, float]c                f  K   	 |                      |          x}}n8# t          $ r+ t          d| j         j         d|j        j         d          w xY w| j         t          u rt          |          }| j        || j        k     s| j	        '|| j	        k    rt          || j        | j	                  |S )NConverting to "" failed for parameter "".)minimummaximum)r  r  BadArgumentrV   current_parameterru   r;   r   r  r  
RangeError)rS   rN   r  count	converteds        rD   rT   zRange.convert  s      $(OOE$:$::		   !vdo&>vvX[XmXrvvv  
 #%%E

$)9)9tx?SX]`d`hXhXh DHdhOOOOs	    5Ac                    d S r?   rZ   r  s    rD   __call__zRange.__call__  s    DrF   c                     t           | |f         S r?   )r   )rS   rhss     rD   __or__zRange.__or__  s    s##rF   c                Z    | j         j         d| j        j         d| j         d| j         dS )N[z, r  )r  rV   r  r  r  r  s    rD   r  zRange.__repr__  s9    n-cc0HccDHccX\X`ccccrF   c                X   t          |t                    st          d|j        j         d          t          |          dk    rg |d R }n"t          |          dk    rt          d          |\  }}}||t          d          |1|/t          |          t          |          k    rt          d          |t          t          t          fvrt          d|d          |t          t          fv rt          }nt          } | || ||          nd | ||          nd 	          S )
Nz'expected tuple for arguments, received z insteadr?  r@  zSRange accepts either two or three arguments with the first being the type of range.zRange must not be emptyz/Both min and max in Range must be the same typez4expected int, float, or str as range type, received )r  r  r  )
r   r  r  r  rV   r   r   rh   floatr;   )r  objr  r  r  casts         rD   r  zRange.__class_getitem__  sO   c5)) l j#-J` j j jkkk3xx1}}"lTllSQ uvvv#& JS{s{ 9:::3?99S		))#$UVVV#uc!222 mWa m m mnnnc3Z''3%!$DDIIId!$DDIIId   rF   )r  r   r  r  r  r  r=   rp  )rN   rO   r  r;   r=   r  )r=   rp  r  r  )r=   r6   )
rV   rW   rX   rY   rr  rT   r  r  r  r  rZ   rF   rD   r6   r6     s        	 	H 04/3	I 	I 	I 	I 	I 	I	 	 	 	 	 	 	 		$ 	$ 	$ 	$	d 	d 	d 	d	 	 	 	 	 	rF   r6   rB  c                `    |                                  }|dv rdS |dv rdS t          |          )N)yesytruet1enableonT)nonfalsefrq   disableoffF)r  BadBoolArgument)r<   lowereds     rD   _convert_to_boolr  
  sA    nnG@@@t	D	D	Dug&&&rF   )_GenericAliastpr  r   c               v    t          | t                    rt          | t                    pt          | |          S r?   )r   r   r  r   )r  r  s     rD   is_generic_typer    s0    b$;Jr7$;$;\z"m?\?\\rF   zDict[type, Any]CONVERTER_MAPPINGrN   rO   r  paraminspect.Parameterc                  K   |t           u rt          |          S 	 |j        }|E|                    d          r0|                    d          st
                              ||          }n# t          $ r Y nw xY w	 t          j	        |          rnt          |t                    rYt          j        |j                  r|                    | |           d {V S  |                                | |           d {V S t          |t                    r|                    | |           d {V S n-# t          $ r  t           $ r}t#          ||          |d }~ww xY w	  ||          S # t          $ r  t           $ rF}	 |j        }n# t          $ r |j        j        }Y nw xY wt)          d| d|j         d          |d }~ww xY w)Nzdiscord.r  r  r  r  )rB  r  rW   r  endswithr  r   AttributeErrorr  r  r  r   r  rT   r   CommandErrorr-  ConversionErrorrV   r  r  ru   )rN   r  r<   r  moduler0  ru   s          rD   _actual_conversionr  5  s\     D)))D% 6#4#4Z#@#@YdIeIe)--iCCI	    7?9%% 	:*Y	*J*J 	:	 122 @&..sH=========&Y[[00h?????????	9-- 	:"**3999999999	:    7 7 7i--367
cy"""    c c c	0%DD 	0 	0 	0&/DDD	0 XDXX%*XXXYY_bbcsl   A+ +
A87A8<AD0 #D0 >0D0 0EEE
E) )G>FF>FF>FF>>G'Union[Type[Converter[T]], Converter[T]]r   c                
   K   d S r?   rZ   rN   r  r<   r  s       rD   r8   r8   [  s       	rF   c                
   K   d S r?   rZ   r  s       rD   r8   r8   a  s      fifirF   c                  K   t          |dd          }|t          u rg }t          d          }|j        }|D ]}||u rO|j        |j        k    r?| j                                         |j        rdn|	                    |            d{V c S 	 t          | |||           d{V }	|	c S # t          $ r}
|                    |
           Y d}
~
d}
~
ww xY wt          |||          |t          u rg }i }|j        }|D ]}t          |          }	 ||         }	nm# t          $ r` 	 t!          | |||           d{V }	|	||<   n># t          $ r1}
|                    |
           t#                      ||<   Y d}
~
Y zd}
~
ww xY wY nw xY w|	|k    r|	c S t%          ||||          |t'          |          r|}t!          | |||           d{V S )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: :class:`str`
        The argument to convert to.
    param: :class:`Parameter`
        The parameter being converted. This is mainly for error reporting.

    Raises
    -------
    CommandError
        The converter failed to convert.

    Returns
    --------
    Any
        The resulting conversion.
    r  N)rA   r   r   r  kindVAR_POSITIONALviewundorequiredget_defaultr8   r  appendBadUnionArgumentr
   KeyErrorr  objectBadLiteralArgumentr  )rN   r  r<   r  r  errors	_NoneType
union_argsconvr  r0  conversionsliteral_argsliteralliteral_types                  rD   r8   r8   e  s     < Yd33FJJ	'
 	 	D y  UZ53G%G%G$~Ott9J9J39O9O3O3O3O3O3O3OOOO,S$%HHHHHHHH    # # #c""""""""# uj&999 )# 	 	G==L
6#L1 6 6 66"4S,RW"X"XXXXXXXE 16K-- $   MM#&&&06K-HHHHH
 .-6    !fhGGG oi88	#CHeDDDDDDDDDsT   B))
C3CCD
F"E :F 
E;
&E60F6E;;F F)r9   r   r:   r;   r<   r   r=   r   )r<   r;   r=   rB  )r  r   r  r   r=   rB  )rN   rO   r  r   r<   r;   r  r  )
rN   rO   r  r  r<   r;   r  r   r=   rG   )
rN   rO   r  r   r<   r;   r  r   r=   r   )mrY   
__future__r   rU  r  rf   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r  rj   r  discord.stater   discord.threadsr   
parametersr   _typesr   r   contextr   __all__rE   r   r   r   rG   rH   r   r   rJ   rL   r   r   r]   r.   rk   r   r   r   Userr   r   r    Messager   r0   r   r!   r   r(   r   r)   r  r,   r/   r  r-   r  r&   r'   Roler$   r(  r%   Inviter"   Guildr#   Emojir*   rC  r+   GuildStickerr1   r7   r;   ScheduledEventr2   SoundboardSoundr3   r4   r5   typing_extensionsr  r6   r  r   r  r  r  __annotations__r  r8   rZ   rF   rD   <module>r     s3
    0 # " " " " "   				                                 "       !%%%%%%&&&&&&%%%%%%""""""""      D    ]
GCLLwv&&&WT1222WT((( &M &M &M &M &M &M &M &MR BJ)**	) ) ) ) ))D/ ) ) )) ) ) ) )k'.1 ) ) )0c c c c ck'.1 c c cL9 9 9 9 9K- 9 9 9x8F 8F 8F 8F 8Fi(>? 8F 8F 8Fv. . . . .{7?3 . . .>Z Z Z Z ZK(@A Z Z Zzk k k k k;w':; k k k0m m m m mK(<= m m m0m m m m mK(<= m m m.l l l l l{7+BC l l l0_ _ _ _ _k'.1 _ _ _,e e e e eK(<= e e e." " " " "i/ " " "J !    K-   @+ + + + +Igl+ + + +7 7 7 7 7i/ 7 7 7"    [/   6& & & & &[/ & & &R6 6 6 6 6Ig&:; 6 6 60$ $ $ $ $K(<= $ $ $N  \!II\ \ \ \ \IcN \ \ \$8 8 8 8 8k'*@A 8 8 8v# # # # #{7+BC # # #LV5 V5 V5 V5 V5IcN V5 V5 V5rF F F F FT!W F F FR  l4444444h h h h h h h hV' ' ' ' T!W 7D ] ] ] ] ] ]&NO&NO& L-& O%	&
 3& -& NO& M>& L-& L-& NO& /& /& M>& /&  5!&" NO#&$ K3/3/5-& &     4#c #c #c #cL 
   

 
 i i i 
 iUE UE UE UE UE UErF   