
    cjh7             	      t   d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZ ddlmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZ dd	lmZmZmZmZm Z  dd
l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; ddl<m=Z=m>Z> ddl?m@Z@mAZA ej                  dk\  rddlmCZCmDZDmEZE n
ddlFmCZCmDZDmEZE dZGerddlFmHZHmIZI ddlJmKZK ddlLmMZM ddlNmOZOmPZP  ed      ZQ edd      ZR ed ed!eeeef   f         ZSer	 eId"      ZTn ed"      ZTd# ZUd$ ZVd?d%ZWd& ZXd' ZY G d( d)      ZZ G d* d+eZeeReTeQf         Z[ G d, d-e[      Z\ G d. d/e[      Z] G d0 d1e[      Z^ G d2 d3e^      Z_ G d4 d5e^      Z`d6 Zad7 Zbd8 Zce\fd9Zdd: Zed;Zfg d<Zgd@dAd=Zhd@dBd>Ziy)Cae  
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)OrderedDict)Enum)TYPE_CHECKINGAnyCallable	Coroutine	GeneratorGenericTypeVarUnion   )PartialMessageable_threaded_guild_channel_factory)IntegrationTypeInteractionContextTypeMessageTypeSlashCommandOptionTypetry_enum)ApplicationCommandErrorApplicationCommandInvokeErrorCheckFailureClientExceptionInvalidArgumentValidationError)Member)
AttachmentMessage)Object)Role)Thread)User)MISSING	async_allfindmaybe_coroutineutcnowwarn_deprecated   )ApplicationContextAutocompleteContext)OptionOptionChoice)      )	Annotatedget_args
get_origin)_BaseCommandApplicationCommandSlashCommandslash_commandapplication_commanduser_commandmessage_commandcommandSlashCommandGroupContextMenuCommandUserCommandMessageCommand)Concatenate	ParamSpec)Permissions)Cog)CooldownMappingMaxConcurrencyTCogTrB   )boundCoro.Pc                R     ddl m t        j                          fd       }|S )Nr   CommandErrorc                    K   	  | i | d {   }|S 7 # t         $ r  $ r  t        j                  $ r Y y t        $ r}t	        |      |d }~ww xY wwN)r   asyncioCancelledError	Exceptionr   )argskwargsretexcrL   coros       H/var/www/html/venv/lib/python3.12/site-packages/discord/commands/core.pywrappedzwrap_callback.<locals>.wrappeds   sm     		>d-f--C 
 .& 	 	%% 	 	>/4#=	>s;   A  A !AAAAAAext.commands.errorsrL   	functoolswraps)rV   rX   rL   s   ` @rW   wrap_callbackr]   p   s(    2__T  N    c                Z     ddl m t        j                         fd       }|S )Nr   rK   c                  K   	  |        d {   }	 t        d      r/j                  #j                  j                         d {    j                         d {    |S 7 [# t         $ r  $ r  t        j                  $ rY Y t        d      r0j                  $j                  j                         d {  7   j                         d {  7   y t        $ r}t        |      |d }~ww xY w7 7 # t        d      r0j                  $j                  j                         d {  7   j                         d {  7   w xY ww)N_max_concurrency)	r   rO   rP   hasattrra   releasecall_after_hooksrQ   r   )argrT   rU   rL   r:   rV   ctxs      rW   rX   z(hooked_wrapped_callback.<locals>.wrapped   sF    	0S	/C !34,,8..66s;;;**3///
! "& 	 	%% 	
 !34,,8..66s;;;**3///  	>/4#=	> </	 !34,,8..66s;;;**3///s   E"A. A,A. 6E"DE"%D&E",A. .!D D 6E"C	E" C#!E"'D /C;;D  D E"E"7E>E?EEEE"rY   )r:   rf   rV   rX   rL   s   ``` @rW   hooked_wrapped_callbackrg      s(    2__T ( Nr^   c                    t         j                  }	 t        | d      r| j                  } nt	        | |      r| j
                  } n| S 5)N__wrapped__)r[   partialrb   ri   
isinstancefunc)functionrj   s     rW   unwrap_functionrn      sB    G
8]+++H'*}}HO r^   c                    t        | j                         | j                  r0| j                  j                         D ]  \  }}t        ||        y y N)locale)validate_chat_input_namenamename_localizationsitemsobjrq   strings      rW   _validate_namesry      sH    SXX&
!44::< 	<NFF$VF;	< r^   c                    t        | j                         | j                  r0| j                  j                         D ]  \  }}t        ||        y y rp   )validate_chat_input_descriptiondescriptiondescription_localizationsru   rv   s      rW   _validate_descriptionsr~      sJ    #COO4
$$!;;AAC 	CNFF+F6B	C %r^   c                      e Zd ZdZy)r3    N)__name__
__module____qualname__	__slots__r   r^   rW   r3   r3      s    Ir^   r3   c                     e Zd ZU ded<   dZd"dZd#dZd$dZd Ze		 	 d%d       Z
e
j                  	 	 	 	 d&d	       Z
e	d$d
       Zej                  d'd       Zd(dZd)dZd*dZd)dZd+dZd)dZd*dZd,dZd Zd Zd$dZd Zd Zd)dZd)dZe	d        Ze	d#d       Ze	d#d       Ze	d-d       Zd.dZ d#d Z!d! Z"y)/r4   dict[str, Any]__original_kwargs__Nc                z   ddl m}m}m} t	        |d|j                  d            }| |||j                        }nt        ||      r|}nt        d      || _	        t	        |d|j                  d            }|| _
        d | _        d | _        |j                  d|j                        | _        	 |j                  }	|	j!                          |	| _        |j                  d
      | _        |j                  dd       | _        |j                  d      | _        t	        |d|j                  dd             | _        t	        |d|j                  dd             | _        t	        |d|j                  dd             }
t	        |d|j                  dd             }t	        |d|j                  dt0                    }|t0        urt3        dddd       |r|rt5        d      | j(                  r||s|
rt5        d      |rt6        j8                  h}|| _        |
| _        y # t"        $ r |j                  d	g       }	Y lw xY w)Nr   
BucketTyperC   rD   __commands_cooldown__cooldown:Cooldown must be a an instance of CooldownMapping or None.__commands_max_concurrency__max_concurrencyrs   checksid	guild_idsparent__default_member_permissions__default_member_permissions__nsfw__nsfw__integration_types__integration_types__contexts__contexts__guild_only__
guild_only2.6Khttps://discord.com/developers/docs/change-log#userinstallable-apps-preview	referenceBcannot pass both 'contexts' and 'guild_only' to ApplicationCommandVthe 'contexts' and 'integration_types' parameters are not available for guild commands)ext.commands.cooldownsr   rC   rD   getattrgetdefaultrk   	TypeError_bucketsra   	_callbackmoduler   rs   __commands_checks__reverseAttributeErrorr   r   r   r   r   r   r#   r(   r   r   guildr   r   )selfrl   rS   r   rC   rD   r   bucketsr   r   r   r   r   s                rW   __init__zApplicationCommand.__init__   s1   XX4!8&**Z:PQ%h
0B0BCG/2GL  *1!0&**=N2O
 8GFDMM:		.--FNN $jj.+1::k4+Hjj* ?F,JJ3T:?
'
 ")z6::fd;S!T	#)6::6I4+P
 4J1MNT#3VZZg5VW
W$g	 
!T  >>!j4E!h  .445H<D>OU  	.ZZ"-F	.s   1H H:9H:c                P    d| j                   j                   d| j                   dS )Nz<discord.commands.z name=>)	__class__r   rs   r   s    rW   __repr__zApplicationCommand.__repr__
  s&    #DNN$;$;#<F499+QOOr^   c                    t        || j                        xr4 | j                  |j                  k(  xr | j                  |j                  k(  S rN   )rk   r   qualified_namer   r   others     rW   __eq__zApplicationCommand.__eq__  sC    udnn- 2##u';';;2%//1	
r^   c                   K   | j                   ) | j                  | j                   |g|i | d{   S  | j                  |g|i | d{   S 7 "7 w)z|coro|
        Calls the command's callback.

        This method bypasses all checks that a command has and does not
        convert the arguments beforehand, so take care to pass the correct
        arguments in.
        N)cogcallback)r   rf   rR   rS   s       rW   __call__zApplicationCommand.__call__  s^      88&txxFtFvFFF"T]]388888 G8s!   1AAAAAAc                    | j                   S rN   )r   r   s    rW   r   zApplicationCommand.callback   s     ~~r^   c                J    || _         t        |      }|j                  | _        y rN   )r   rn   r   r   )r   rm   unwraps      rW   r   zApplicationCommand.callback)  s"     " *''r^   c                    t        dddd       t        j                  | j                  v xr t	        | j                        dk(  S )Nr   r   r   r   r   r)   r(   r   r   r   lenr   s    rW   r   zApplicationCommand.guild_only5  sA    c		
 &++t}}<XT]]ASWXAXXr^   c                    t        dddd       |rt        j                  h| _        y t        j                  t        j                  t        j
                  h| _        y )Nr   r   r   r   r   r(   r   r   r   bot_dmprivate_channelr   values     rW   r   zApplicationCommand.guild_only?  sQ    c		
 399:DM ',,&--&66DMr^   c                6   | j                   j                  rt        j                  j                         j	                         }| j                   j                  ||      }|8|j                  |      }|r$ddlm}  |||| j                   j                        y y y )Nr   )CommandOnCooldown)
r   validdatetimenow	timestamp
get_bucketupdate_rate_limitrZ   r   type)r   rf   currentbucketretry_afterr   s         rW   _prepare_cooldownsz%ApplicationCommand._prepare_cooldownsP  s    ==''++-779G]]--c7;F!$66w?G+FKASASTT  "	 r^   c                  K   | |_         | j                  |       d {   st        d| j                   d      | j                  #| j                  j                  |       d {    	 | j                  |       | j                  |       d {    y 7 x7 27 	#  | j                  $| j                  j                  |       d {  7    xY ww)Nz$The check functions for the command z failed)	r:   can_runr   rs   ra   acquirer   call_before_hooksrc   )r   rf   s     rW   preparezApplicationCommand.prepare]  s     \\#&&&6tyykI    ,''//444	##C(((--- ' 5 .	$$0++33C888sX   CBAC&B'C,%B BB CCB ,C	C
CCc                    | j                   j                  sy| j                   j                  |      }t               j	                         }|j                  |      dk(  S )a  Checks whether the command is currently on cooldown.

        .. note::

            This uses the current time instead of the interaction time.

        Parameters
        ----------
        ctx: :class:`.ApplicationContext`
            The invocation context to use when checking the command's cooldown status.

        Returns
        -------
        :class:`bool`
            A boolean indicating if the command is on cooldown.
        Fr   )r   r   r   r'   r   
get_tokensr   rf   r   r   s       rW   is_on_cooldownz!ApplicationCommand.is_on_cooldownr  sN    " }}""))#.($$&  )Q..r^   c                    | j                   j                  r,| j                   j                  |      }|j                          yy)zResets the cooldown on this command.

        Parameters
        ----------
        ctx: :class:`.ApplicationContext`
            The invocation context to reset the cooldown under.
        N)r   r   r   reset)r   rf   r   s      rW   reset_cooldownz!ApplicationCommand.reset_cooldown  s3     ==]]--c2FLLN r^   c                    | j                   j                  rD| j                   j                  |      }t               j	                         }|j                  |      S y)a  Retrieves the amount of seconds before this command can be tried again.

        .. note::

            This uses the current time instead of the interaction time.

        Parameters
        ----------
        ctx: :class:`.ApplicationContext`
            The invocation context to retrieve the cooldown from.

        Returns
        -------
        :class:`float`
            The amount of time left on this command's cooldown in seconds.
            If this is ``0.0`` then the command isn't on cooldown.
        g        )r   r   r   r'   r   get_retry_afterr   s       rW   get_cooldown_retry_afterz+ApplicationCommand.get_cooldown_retry_after  sI    $ ==]]--c2Fh((*G))'22r^   c                   K   | j                  |       d {    t        | || j                        } ||       d {    y 7 ,7 wrN   )r   rg   _invoke)r   rf   injecteds      rW   invokezApplicationCommand.invoke  sB     ll3*4dllCsm 	  	s   AA&AAAAc                  K   j                   j                         d {   st        d| j                   d      | j                  }| j
                  | j
                  j                  |z   }| j                  }|4|j                  |j                        }|t        |       d {   }|sy|syt        fd|D               d {   S 7 7 (7 w)Nz'The global check functions for command z failed.FTc              3  .   K   | ]  } |        y wrN   r   ).0	predicaterf   s     rW   	<genexpr>z-ApplicationCommand.can_run.<locals>.<genexpr>  s     J)y~Js   )botr   r   rs   r   r   r   _get_overridden_method	cog_checkr&   r$   )r   rf   
predicatesr   local_checkrT   s    `    rW   r   zApplicationCommand.can_run  s     WW__S)))9$))HM  [[
;;"++j8Jhh?44S]]CK&+K== JzJJJJ- * > Ks4   CCBC+C,!CCCCCc                  K   d|_         | j                  }	 | j                  }t        |      }| ||||       d {    n |||       d {    	 	 |C|j
                  j                  |j                        }|t        |      } |||       d {    |j                  j                  d||       y 7 {7 k# t        $ r Y sw xY w7 5# |j                  j                  d||       w xY ww)NTapplication_command_error)
command_failedr   on_errorr]   r   r   r   cog_command_errorr   dispatch)r   rf   errorr   rV   r   localrX   s           rW   dispatch_errorz!ApplicationCommand.dispatch_error  s     !hh		+==D %T*HsC///sE***	F<<S=R=RS$+E2G!#u---GG8#uE 0*  		 .GG8#uEsn   C0B= C0B9C0B;C0A C CC C0;C0=	C	C0C		C0C C--C0c                f    t        t        j                  | j                        j                        S rN   )r   inspect	signaturer   
parametersr   s    rW   _get_signature_parametersz,ApplicationCommand._get_signature_parameters  s"    7,,T]];FFGGr^   c                T    t        j                  |      st        d      || _        |S )a  A decorator that registers a coroutine as a local error handler.

        A local error handler is an :func:`.on_command_error` event limited to
        a single command. However, the :func:`.on_command_error` is still
        invoked afterwards as the catch-all.

        Parameters
        ----------
        coro: :ref:`coroutine <coroutine>`
            The coroutine to register as the local error handler.

        Raises
        ------
        TypeError
            The coroutine passed is not actually a coroutine.
        z&The error handler must be a coroutine.)rO   iscoroutinefunctionr   r   r   rV   s     rW   r   zApplicationCommand.error  s*    $ **40DEEr^   c                    t        | d      S )z;Checks whether the command has an error handler registered.r   )rb   r   s    rW   has_error_handlerz$ApplicationCommand.has_error_handler   s    tZ((r^   c                T    t        j                  |      st        d      || _        |S )a  A decorator that registers a coroutine as a pre-invoke hook.
        A pre-invoke hook is called directly before the command is
        called. This makes it a useful function to set up database
        connections or any type of set up required.

        This pre-invoke hook takes a sole parameter, an :class:`.ApplicationContext`.
        See :meth:`.Bot.before_invoke` for more info.

        Parameters
        ----------
        coro: :ref:`coroutine <coroutine>`
            The coroutine to register as the pre-invoke hook.

        Raises
        ------
        TypeError
            The coroutine passed is not actually a coroutine.
        z(The pre-invoke hook must be a coroutine.)rO   r  r   _before_invoker  s     rW   before_invokez ApplicationCommand.before_invoke  s+    & **40FGG"r^   c                T    t        j                  |      st        d      || _        |S )a  A decorator that registers a coroutine as a post-invoke hook.
        A post-invoke hook is called directly after the command is
        called. This makes it a useful function to clean-up database
        connections or any type of clean up required.

        This post-invoke hook takes a sole parameter, an :class:`.ApplicationContext`.
        See :meth:`.Bot.after_invoke` for more info.

        Parameters
        ----------
        coro: :ref:`coroutine <coroutine>`
            The coroutine to register as the post-invoke hook.

        Raises
        ------
        TypeError
            The coroutine passed is not actually a coroutine.
        z)The post-invoke hook must be a coroutine.)rO   r  r   _after_invoker  s     rW   after_invokezApplicationCommand.after_invoke  s+    & **40GHH!r^   c                  K   | j                   }| j                  Mt        | j                  d|      }|r| j                  ||       d {    n| j                  |       d {    |7|j                  j	                  |j
                        }| ||       d {    |j                  j                  }| ||       d {    y y 7 7 i7 27 wN__self__)r   r  r   r   r   cog_before_invoker   r   rf   r   instancehooks        rW   r   z$ApplicationCommand.call_before_hooks6  s      hh*t22JDH ))(C888))#... ?==778M8MND3i ww%%s)OO  9.  
 H   AC	C
C#C$8CC'CCCCCCc                  K   | j                   }| j                  Mt        | j                  d|      }|r| j                  ||       d {    n| j                  |       d {    |7|j                  j	                  |j
                        }| ||       d {    |j                  j                  }| ||       d {    y y 7 7 i7 27 wr  )r   r  r   r   r   cog_after_invoker   r  s        rW   rd   z#ApplicationCommand.call_after_hooksO  s     hh)t11:sCH((3777((--- ?==778L8LMD3iww$$s)OO  8-   r  c                .    | j                   j                  S rN   )r   	_cooldownr   s    rW   r   zApplicationCommand.cooldownb  s    }}&&&r^   c                   g }| }|j                   `t        |j                   d      rJ|j                   }|j                  |j                         |j                   t        |j                   d      rJdj	                  t        |            S )zRetrieves the fully qualified parent command name.

        This the base command name required to execute it. For example,
        in ``/one two three`` the parent name would be ``one two``.
        rs    )r   rb   appendrs   joinreversed)r   entriesr:   s      rW   full_parent_namez#ApplicationCommand.full_parent_namef  sm     nn(WW^^V-LnnGNN7<<( nn(WW^^V-L xx)**r^   c                X    | j                   }|r| d| j                   S | j                  S )zRetrieves the fully qualified command name.

        This is the full parent name with the command name as well.
        For example, in ``/one two three`` the qualified name would be
        ``one two three``.
        r  )r"  rs   )r   r   s     rW   r   z!ApplicationCommand.qualified_nameu  s1     &&XQtyyk**99r^   c                ^    | j                   | j                  j                  S | j                   S )zRetrieves the fully qualified command ID.

        This is the root parent ID. For example, in ``/one two three``
        the qualified ID would return ``one.id``.
        )r   r   qualified_idr   s    rW   r%  zApplicationCommand.qualified_id  s&     77?;;+++wwr^   c                    t         rN   )NotImplementedErrorr   s    rW   to_dictzApplicationCommand.to_dict  s    !!r^   c                    | j                   S rN   )r   r   s    rW   __str__zApplicationCommand.__str__  s    """r^   c                    || _         y rN   )r   )r   r   s     rW   _set_cogzApplicationCommand._set_cog  s	    r^   rl   r   returnNoner.  strr.  bool)r.  sCallable[Concatenate[CogT, ApplicationContext, P], Coro[T]] | Callable[Concatenate[ApplicationContext, P], Coro[T]])rm   r4  r.  r/  r   r3  r.  r/  rf   r*   rf   r*   r.  r/  )rf   r*   r.  r3  )rf   r*   r.  float)rf   r*   r   rQ   r.  r/  )r.  int)r.  r   )#r   r   r   __annotations__r   r   r   r   r   propertyr   setterr   r   r   r   r   r   r   r   r   r  r   r	  r  r  r   rd   r   r"  r   r%  r(  r*  r,  r   r^   rW   r4   r4      sO   ''
CHPTP

9 	@  __	(D	( 
	( 	( Y Y   U*/0
2K2F.H0)222& ' ' + +    "#r^   r4   c                       e Zd ZdZdZd fdZd fdZd Zd Zdddd	Z	d
 Z
d Zd Zd Zed        Zej                   d        Zedd       Zedd       ZddZddZddZd Zd Zd dZ xZS )!r5   a  A class that implements the protocol for a slash command.

    These are not created manually, instead they are created via the
    decorator or functional interface.

    .. versionadded:: 2.0

    Attributes
    -----------
    name: :class:`str`
        The name of the command.
    callback: :ref:`coroutine <coroutine>`
        The coroutine that is executed when the command is called.
    description: Optional[:class:`str`]
        The description for the command.
    guild_ids: Optional[List[:class:`int`]]
        The ids of the guilds where this command will be registered.
    options: List[:class:`Option`]
        The parameters for this command.
    parent: Optional[:class:`SlashCommandGroup`]
        The parent group that this command belongs to. ``None`` if there
        isn't one.
    mention: :class:`str`
        Returns a string that allows you to mention the slash command.
    guild_only: :class:`bool`
        Whether the command should only be usable inside a guild.

        .. deprecated:: 2.6
            Use the :attr:`contexts` parameter instead.
    nsfw: :class:`bool`
        Whether the command should be restricted to 18+ channels and users.
        Apps intending to be listed in the App Directory cannot have NSFW commands.
    default_member_permissions: :class:`~discord.Permissions`
        The default permissions a member needs to be able to run the command.
    cog: Optional[:class:`Cog`]
        The cog that this command belongs to. ``None`` if there isn't one.
    checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
        A list of predicates that verifies if the command could be executed
        with the given :class:`.ApplicationContext` as the sole parameter. If an exception
        is necessary to be thrown to signal failure, then one inherited from
        :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
        :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
        event.
    cooldown: Optional[:class:`~discord.ext.commands.Cooldown`]
        The cooldown applied when the command is invoked. ``None`` if the command
        doesn't have a cooldown.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this command. The values of this should be ``"locale": "name"``. See
        `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    description_localizations: Dict[:class:`str`, :class:`str`]
        The description localizations for this command. The values of this should be ``"locale": "description"``.
        See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    integration_types: Set[:class:`IntegrationType`]
        The type of installation this command should be available to. For instance, if set to
        :attr:`IntegrationType.user_install`, the command will only be available to users with
        the application installed on their account. Unapplicable for guild commands.
    contexts: Set[:class:`InteractionContextType`]
        The location where this command can be used. Cannot be set if this is a guild command.
    r)   c                P    t         |   |       }|j                         |_        |S rN   super__new__copyr   clsrR   rS   r   r   s       rW   rA  zSlashCommand.__new__  $    ws##);;= r^   c                   t        |   |fi | t        j                  |      st	        d      || _        |j                  dt              | _        t        |        |j                  d      xs> |j                  0t        j                  |j                        j                         d   nd}|| _        |j                  dt              | _        t!        |        d| _        |j                  dg       | _        g | _        | j)                          	 |j*                  }|j-                          || _        d | _        d | _        y # t.        $ r |j                  d	g       }Y 3w xY w)
NCallback must be a coroutine.rt   r|   r   No description providedr}   Foptionsr   )r@  r   rO   r  r   r   r   r#   rt   ry   __doc__r  cleandoc
splitlinesr|   r}   r~   attached_to_group_options_kwargsrI  _validate_parametersr   r   r   r   r  r  )r   rl   rR   rS   r|   r   r   s         rW   r   zSlashCommand.__init__  sG   ((**40;<<28** '3
 	jj/ 
||' T\\*557:* 	 !,9?':
& 	t$',%zz)R8%'!!#	.--FNN "!  	.ZZ"-F	.s   E E#"E#c                    | j                         }| j                  x}r| j                  ||      | _        y | j	                  |      | _        y rN   )r  rN  _match_option_param_namesrI  _parse_options)r   paramskwops      rW   rO  z!SlashCommand._validate_parameters  sG    //1'''4'99&$GDL..v6DLr^   c           	         t        |j                               }| j                  s| j                  rddgndg}|D ]  }	 t	        |        |S # t
        $ r t        d| j                   d| d      w xY w)Nr   contextCallback for  command is missing "" parameter.)iterru   rM  r   nextStopIterationr   rs   )r   rS  required_paramsps       rW   _check_required_paramsz#SlashCommand._check_required_params  s    flln%#'#9#9TXXVYI; 	 ! 	AV	  ! %#DII;.CA3lS s   A&A4Tcheck_paramsc                  |r| j                  |      }nt        |j                               }g }|D ]  \  }}|j                  }|t        j
                  j                  k(  rt        }| j                  |      rt        |      d   }|j                  }d |D        }	t        |	t                     }| j                  |      r.t        j                  t        |      d         |_        d |_        nt        j                  |      |_        | j%                  |      rA| j                  |      rt        |j&                  d   d       }nt        |j&                        }t)        |t              slt)        |j"                  t              rG|j"                  j                   $t        j                  |      |j"                  _        |j"                  }nt        |      }|j"                  |j"                  t        j
                  j                  k(  st)        |j"                  t              rnht)        |j"                  t*              r6t-        |j"                  t.        t0        f      rt        |j"                        }n|j"                  |_        d|_        |j4                  ||_        |j4                  |k7  s|j6                  ||_        t9        |       t;        |       |j=                  |        |S )Nr   c              3  B   K   | ]  }t        |t              s|  y wrN   )rk   r,   )r   elems     rW   r   z.SlashCommand._parse_options.<locals>.<genexpr>-  s     Tt:dF;SdTs   )r   F)r_  rZ  ru   
annotationr  	Parameteremptyr1  _is_typing_annotatedr1   __metadata__r[  r,   _is_typing_optionalr   from_datatype
input_typer   _is_typing_union__args__rk   r   
issubclassDiscordEnumr   requiredrs   _parameter_namery   r~   r  )
r   rS  ra  final_optionsp_namep_objoption	type_hintmetadata
option_gens
             rW   rR  zSlashCommand._parse_options  sO   008F&,,.)F# 6	)MFE%%F**000((0$V,Q/	!..TxT
j&(3++I6(>(L(L +A.)F% &*FN(>(L(LY(WF%$$V,++F3#FOOA$6EF#FOO4Fff-emmV4}}//73I3W3W"40 #]]F#F^F~~%emmw?P?P?V?V.VemmV4t4MMK#6: $EMM2F%*]]FN&+FO{{"${{f$(>(>(F)/&F#"6*  (m6	)p r^   c                   	 t        |      } j                  |      }d d d  fdd g}|D ]k  t               t               	 t	        |      \  }		j                  	t        	fd|D              st        d| d	j                   d
      |_        m t               }|D ]
  \  }}|||<    |j                   j                  |d             |S # t
        $ r t        d      w xY w)Nc                \    | j                   t        j                  k(  xr | j                  d uS rN   )rl  r   rx   	converteroas     rW   <lambda>z8SlashCommand._match_option_param_names.<locals>.<lambda>c  s*    )?)F)FF (4' r^   c                6    t        | j                  t              S rN   )rk   rl  r   r}  s     rW   r  z8SlashCommand._match_option_param_names.<locals>.<lambda>e  s    4 r^   c                f    t        | j                  t              xr |t        | j                     k(  S rN   )rk   	_raw_typetupler   r}  s     rW   r  z8SlashCommand._match_option_param_names.<locals>.<lambda>h  s$    AKK7SAq{{AS<S r^   c                x    j                  |      xr' | j                   xr | j                  |j                  v S rN   )rj  rq  r  rn  )r~  r  r   s     rW   r  z8SlashCommand._match_option_param_names.<locals>.<lambda>i  s8    11!4 *JJ*qzz) r^   c                R    t        |t              xr t        || j                        S rN   )rk   r   ro  r  r}  s     rW   r  z8SlashCommand._match_option_param_names.<locals>.<lambda>l  s#    At, +1akk* r^   z/Too many arguments passed to the options kwarg.c              3  0   K   | ]  } |        y wrN   r   )r   checkr~  ru  s     rW   r   z9SlashCommand._match_option_param_names.<locals>.<genexpr>x  s     F5uQFs   z
Parameter z does not match input type of .Fr`  )listr_  ry   r~   r[  r\  r   re  anyr   rs   rr  r   extendrR  )
r   rS  rI  check_annotationsrt  left_out_paramskvr~  ru  s
   `       @@rW   rQ  z&SlashCommand._match_option_param_names^  s#   w-,,V4( T*+C
  	'AA"1%Y $V $$EF4EFF (FqvvhaP  !'A	' &- 	#DAq!"OA	#t**?*OP ! Y%&WXXYs   
CC0c                l    t        |dd       t        u xs  t        |      t        t        dt              u S )N
__origin__	UnionType)r   r   r   typesr   re  s     rW   rm  zSlashCommand._is_typing_union  s=    z<6%? 
4D
;
D
 	
r^   c                V    | j                  |      xr t        d       |j                  v S rN   )rm  r   rn  r  s     rW   rj  z SlashCommand._is_typing_optional  s'    $$Z0VT$Z:CVCV5VVr^   c                $    t        |      t        u S rN   )r2   r0   r  s     rW   rh  z!SlashCommand._is_typing_annotated  s    *%22r^   c                    t        | dd       S )N_cog)r   r   s    rW   r   zSlashCommand.cog  s    tVT**r^   c                ^    | j                   }|| _        ||||| j                          y y y rN   )r   r  rO  )r   r   old_cogs      rW   r   zSlashCommand.cog  s@    ((	 O!}#%%' $ r^   c                    | j                   d uS rN   )r   r   s    rW   is_subcommandzSlashCommand.is_subcommand  s    {{$&&r^   c                <    d| j                    d| j                   dS )Nz</:r   )r   r%  r   s    rW   mentionzSlashCommand.mention  s%    D''($*;*;)<A>>r^   c                   | j                   | j                  | j                  D cg c]  }|j                          c}d}| j                  t
        ur| j                  |d<   | j                  t
        ur| j                  |d<   | j                  rt        j                  j                  |d<   | j                  | j                  |d<   | j                  | j                  j                  |d<   | j                  sZ| j                  sN| j                  D cg c]  }|j                   c}|d<   | j                  D cg c]  }|j                   c}|d<   |S c c}w c c}w c c}w 	N)rs   r|   rI  rt   r}   r   r   r   r   r   )rs   r|   rI  r(  rt   r#   r}   r  r   sub_commandr   r   r   r   r   r   )r   r~  as_dictitrf   s        rW   r(  zSlashCommand.to_dict  s-   II++-1\\:		:

 ""'1,0,C,CG()))8373Q3QG/04@@FFGFO99 "iiGFO**6//55 01 ~~d&8&8?C?U?U+VBHH+VG'(8<"F399"FGJ+ ;$ ,W"Fs   EE9Ec                  K   i }|j                   j                  j                  dg       D ]  t        fd| j                        }| d   |j
                  t        j                  t        j                  t        j                  t        j                  t        j                  fv r|j                   j                  j                  di       }|j
                  t        j                  t        j                  fv r|j                  di       j                        x}z|j                  di       j                        x}||d<   |j                   j                  j                  j                   }|j                  j                  |t!              |      n!|j
                  t        j                  u r|j                  di       j                        x}#t#        |j                   j                  |      n|j                  d	i       j                        x}.t%        |j                   j                  ||j                  
      nnt'        t!                    nW|j                  |j
                  j(                   di       j                        x}	 |j
                  t        j                  u rt!              |j                  j*                  v s!t!              |j                  j,                  v rh|j                  j/                  t!                    d|d<   t1        t2              rj5                  |      nj5                  |j                  |       nUd }i }	|j
                  t        j                  u rt"        }n|j
                  t        j                  u rt$        }|j                  |	d<   n_|j
                  t        j                  u r!t7        |d         d   }|j                  |	d<   n"|j
                  t        j                  u rt8        } |d|j                   j                  |d|	n|t'        t!                    ne|j
                  t        j:                  k(  rl|j<                  x}
^ddlm } t1        |
|      r't1        |
tB              r  |
       jE                  |       d {   n|
jE                  |       d {   n|jF                  t        jH                  t        jJ                  t        j:                  t        jL                  fv rntO        |jF                  tP              rwt1        tR              r,jU                         r	 |jG                  t!                    n;t        fd|jX                        x}r t[        |jF                  |j(                        ||j\                  <    | j                  D ]*  }|j\                  |vs|j^                  ||j\                  <   , | j`                  ' | jb                  | j`                  |fi | d {    y | jd                  5| jf                  du r' | jb                  | jd                  |fi | d {    y  | jb                  |fi | d {    y 7 7 # tV        $ r |jG                        Y w xY w7 7 I7 /w)NrI  c                (    | j                   d   k(  S Nrs   rs   )xre   s    rW   r  z&SlashCommand._invoke.<locals>.<lambda>  s    #f+ 5 r^   r   resolvedmembersusersuserstatedataroles)r  r  r   )r   sT_invoke_flagr   r   r   )	Converterc                "    | j                   k(  S rN   )r   )cre   s    rW   r  z&SlashCommand._invoke.<locals>.<lambda>,  s    aggn r^   r   )4interactionr  r   r%   rI  rl  r   r  rolechannel
attachmentmentionable_statemember_cache_flagsr   _get_and_update_memberr9  r"   r    r   rs   	_channels_threadsget_channel_or_threadrk   r!   _updater   r   rx   r|  discord.ext.commandsr  r   convertr  integernumberbooleanro  r   r1  isdigit
ValueErrorchoicesr   rr  r   r   r   r   rM  )r   rf   rS   opr  _data
_user_data
cache_flagobj_typekwr|  r  choicer~  re   s                 @rW   r   zSlashCommand._invoke  s    ??''++Ir: f	-C5t||DBzg,C }}&++&++&..&11&22!  ??//33JCMM.335K5W5WXY"*,,y""="A"A#"FFS '/ll7B&?&C&CC&HH
U(2f!$!7!7!J!J!V!VJ))::5#c(JWC]]&<&H&HH!)gr!:!>!>s!CCP")?)?eL#+<<#<#@#@#EE%R""%//"8"8uCII %C1%\\R]]-?-?,@*BBGKKCPPE }}(>(F(FFCCII$7$77s8syy'9'99!ii==c#hG04n-  *#v6  KK.!$SYY!> $(==,B,G,GG'+H]].D.I.II'+H*-))BwK]].D.L.LL (GuV}'UVW'XH*-))BwK]].D.O.OO'1H&VS__-C-C%VSUV !CH-C !7!>!>>"$,,.Y;:i3!)T2$-K$7$7S$AA$-$5$5c3$??&..&--&--&..	"  BLL$/c3'CKKM0 ll3s84  $$<bjjIIVI!",,<C),F2%%&Mf	-P  	6A  .,-IIq(()	6 88$--#8888[[$)?)?4)G$--S;F;;;$--.v...A B? & 0 ll3/0 9;.s   R;[>Z?[ZB
[%Z?A+[+A[3Z<4A [4Z>5[[ [[Z96[8Z99[>[ [c           	       	K   | j                   D ci c]  }|j                  |j                   }}|j                  j                  j                  dg       D ]  		j                  dd      st        	fd| j                         }|j                  |j                  j                  d   D ci c]  }|d   |d    c}       | |_        ||_	        	j                  d      |_
        ||_         t        t        j                  |j                        j                        dk(  r4t!        |j                  d|j"                        }|j                  ||      }n|j                  |      }t%        j&                  |j                        r
| d {   }|D cg c]  }t)        |t*              r|n
t+        |      ! c}d d	 }|j                  j,                  j/                  |
       d {   c S  y c c}w c c}w 7 nc c}w 7 w)NrI  focusedFc                (    | j                   d   k(  S r  r  )r~  r  s    rW   r  z;SlashCommand.invoke_autocomplete_callback.<locals>.<lambda>A  s    "V*(< r^   rs   r   r   r     )r  )rI  rs   r   r  r  r   r%   updater:   r  r   r   r  r  autocompleter  r   r   rO   r  rk   r-   responsesend_autocomplete_result)
r   rf   ivaluesrv  r  resultr~  r  r  s
            @rW   invoke_autocomplete_callbackz)SlashCommand.invoke_autocomplete_callback<  s    -1\\:!&&!))#:://&&**9b9 	Bvvi'<dllK47OO4H4H4STqQvY'
*T #$FF7O	$w(()<)<=HHIQN&v':':JPH#003?F#005F..v/B/BC#)\F $ $A|4A,q/I 2 !__55NN# O   1	 ; U *sL   HG3>H/?H.G8
>CHG=H$G?;/H*H+H?Hc                r     | j                   | j                  fi | j                  }| j                  |      S )zCreates a copy of this command.

        Returns
        -------
        :class:`SlashCommand`
            A new instance of this command.
        r   r   r   _ensure_assignment_on_copyr   rT   s     rW   rB  zSlashCommand.copy[  4     dnnT]]Gd.F.FG..s33r^   c                    | j                   |_         | j                  |_        | j                  |j                  k7  r| j                  j                         |_        	 | j                  |_        |S # t
        $ r Y |S w xY wrN   r  r  r   rB  r   r   r   s     rW   r  z'SlashCommand._ensure_assignment_on_copyf  r    #22"00;;%,,&;;++-EL	!]]EN   		   A/ /	A<;A<c                    |rY|j                         }|j                  | j                          | j                  | j                  fi |}| j                  |      S | j                         S rN   rB  r  r   r   r   r  r   rS   r  rB  s       rW   _update_copyzSlashCommand._update_copyw  X    BIId../!4>>$--626D2248899;r^   )r.  r5   r-  )ra  r3  r.  zlist[Option]r2  r0  r.  dictr7  )rf   r+   rS   r   )r   r   r   rJ  r   rA  r   rO  r_  rR  rQ  rm  rj  rh  r;  r   r<  r  r  r(  r   r  rB  r  r  __classcell__r   s   @rW   r5   r5     s    :x D&"P7 >B ?B%N
W3 + + 	ZZ
( 
( ' ' ? ?6t/l>	4"r^   r5   c                  N    e Zd ZU dZded<   dZd fdZ	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       Z	edd       Z
e
j                  dd	       Z
dd
ZddZef	 	 	 d dZ	 	 d!	 	 	 	 	 	 	 d"dZ	 	 	 d#	 	 	 	 	 	 	 d$dZd%dZd&dZd%dZd%dZd'dZd Zd Zd(dZ fdZ xZS ))r;   aF
  A class that implements the protocol for a slash command group.

    These can be created manually, but they should be created via the
    decorator or functional interface.

    Attributes
    -----------
    name: :class:`str`
        The name of the command.
    description: Optional[:class:`str`]
        The description for the command.
    guild_ids: Optional[List[:class:`int`]]
        The ids of the guilds where this command will be registered.
    parent: Optional[:class:`SlashCommandGroup`]
        The parent group that this group belongs to. ``None`` if there
        isn't one.
    guild_only: :class:`bool`
        Whether the command should only be usable inside a guild.

        .. deprecated:: 2.6
            Use the :attr:`contexts` parameter instead.
    nsfw: :class:`bool`
        Whether the command should be restricted to 18+ channels and users.
        Apps intending to be listed in the App Directory cannot have NSFW commands.
    default_member_permissions: :class:`~discord.Permissions`
        The default permissions a member needs to be able to run the command.
    checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
        A list of predicates that verifies if the command could be executed
        with the given :class:`.ApplicationContext` as the sole parameter. If an exception
        is necessary to be thrown to signal failure, then one inherited from
        :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
        :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
        event.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this command. The values of this should be ``"locale": "name"``. See
        `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    description_localizations: Dict[:class:`str`, :class:`str`]
        The description localizations for this command. The values of this should be ``"locale": "description"``.
        See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    integration_types: Set[:class:`IntegrationType`]
        The type of installation this command should be available to. For instance, if set to
        :attr:`IntegrationType.user_install`, the command will only be available to users with
        the application installed on their account. Unapplicable for guild commands.
    contexts: Set[:class:`InteractionContextType`]
        The location where this command can be used. Unapplicable for guild commands.
    z&list[SlashCommand | SlashCommandGroup]__initial_commands__r)   c                   t         |   |       }|j                         |_        g |_        | j
                  j                         D ]  \  }}t        |t              rat        |j                  v rO ||j                  | j                  0t        j                  | j                        j                         d   nd      }t        |t         t        f      s||_        d|_        |j                  j'                  |        |S )Nr   rH  T)r@  rA  rB  r   r  __dict__ru   rk   r   r;   	__bases__r   rJ  r  rK  rL  r5   r   rM  r  )rD  rR   rS   r   r  r  r   s         rW   rA  zSlashCommandGroup.__new__  s    ws##);;= $&!LL&&( 	4DAq!T"'8AKK'GJJ ;;2  ((5@@B1E6 !l,=>?&*#))003	4 r^   c                   t        |      | _        |xs d| _        t        | j                         t	        | j                         t
        j                  | _        | j                  | _	        || _
        || _        d| _        |j                  dg       | _        d | _        d | _        d | _        d | _        |j                  dd       | _        |j                  dd       | _        |j                  dd       }|j                  dd       }	|j                  dt*              }
|
t*        urt-        ddd	       |	r|
rt/        d
      | j                  r|	|
s|rt/        d      |	| _        |
r|
| _        || _        |j                  dt*              | _        |j                  dt*              | _        ddlm}m}m } | |||jB                        }ntE        ||      r|}ntG        d      || _$        |tE        ||      stG        d      || _%        y )NrH  Fr   r   r   r   r   r   r   r   r   rt   r}   r   r   r   z=max_concurrency must be an instance of MaxConcurrency or None)&r1  rs   r|   rr   r{   r   sub_command_grouprl  r  subcommandsr   r   rM  r   r   r  r  r   r   r   r   r#   r(   r   r   r   r   rt   r}   r   r   rC   rD   r   rk   r   r   ra   )r   rs   r|   r   r   r   r   rS   r   r   r   r   rC   rD   r   s                  rW   r   zSlashCommandGroup.__init__  s    I	&C*C +'(8(890BB%% 	 #',jj2."! ?Ejj($?
' "(FD!9	"JJ':DA::j$/ZZg6
W$L*e<
!T  >>!j4E!h 
 =E+5DO>O28** '3
 :@':
&
 	YX %h
0B0BCG/2GL  *1 &z^0
 O  8Gr^   c                    | j                   S rN   )r   r   s    rW   r   zSlashCommandGroup.module$  s    r^   c                    t        ddd       t        j                  | j                  v xr t	        | j                        dk(  S )Nr   r   r   r)   r   r   s    rW   r   zSlashCommandGroup.guild_only(  s7    j%8%++t}}<XT]]ASWXAXXr^   c                    t        ddd       |rt        j                  h| _        y t        j                  t        j                  t        j
                  h| _        y )Nr   r   r   r   r   s     rW   r   zSlashCommandGroup.guild_only-  sG    j%8399:DM ',,&--&66DMr^   c                   | j                   | j                  | j                  D cg c]  }|j                          c}d}| j                  t
        ur| j                  |d<   | j                  t
        ur| j                  |d<   | j                  | j                  j                  |d<   | j                  | j                  |d<   | j                  | j                  j                  |d<   | j                  sZ| j                  N| j                  D cg c]  }|j                   c}|d<   | j                  D cg c]  }|j                   c}|d<   |S c c}w c c}w c c}w r  )rs   r|   r  r(  rt   r#   r}   r   rl  r   r   r   r   r   r   )r   r  r  r  rf   s        rW   r(  zSlashCommandGroup.to_dict9  s/   II++-1-=-=>		>

 ""'1,0,C,CG()))8373Q3QG/0;;""oo33GFO99 "iiGFO**6//55 01 ~~$++"5?C?U?U+VBHH+VG'(8<"F399"FGJ- ?& ,W"Fs   EE5Ec                    |j                   | j                   | j                   |_         | j                  j                  |       y rN   )r   r  r  r   r:   s     rW   add_commandzSlashCommandGroup.add_commandU  s4    ;;488#7((GK(r^   c                     d fd}|S )Nc                @     | fdi}j                  |       |S )Nr   )r   )rl   r:   rD  rS   r   s     rW   wrapz'SlashCommandGroup.command.<locals>.wrap^  s*    $6t6v6GW%Nr^   )r.  rE   r   )r   rD  rS   r  s   ``` rW   r:   zSlashCommandGroup.command[  s    	
 r^   c                    | j                   t        d      t        |||fd| i|}| j                  j	                  |       |S )au  
        Creates a new subgroup for this SlashCommandGroup.

        Parameters
        ----------
        name: :class:`str`
            The name of the group to create.
        description: Optional[:class:`str`]
            The description of the group to create.
        guild_ids: Optional[List[:class:`int`]]
            A list of the IDs of each guild this group should be added to, making it a guild command.
            This will be a global command if ``None`` is passed.
        guild_only: :class:`bool`
            Whether the command should only be usable inside a guild.
        nsfw: :class:`bool`
            Whether the command should be restricted to 18+ channels and users.
            Apps intending to be listed in the App Directory cannot have NSFW commands.
        default_member_permissions: :class:`~discord.Permissions`
            The default permissions a member needs to be able to run the command.
        checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
            A list of predicates that verifies if the command could be executed
            with the given :class:`.ApplicationContext` as the sole parameter. If an exception
            is necessary to be thrown to signal failure, then one inherited from
            :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
            :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
            event.
        name_localizations: Dict[:class:`str`, :class:`str`]
            The name localizations for this command. The values of this should be ``"locale": "name"``. See
            `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
        description_localizations: Dict[:class:`str`, :class:`str`]
            The description localizations for this command. The values of this should be ``"locale": "description"``.
            See `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.

        Returns
        -------
        SlashCommandGroup
            The slash command group that was created.
        z8A subcommand group cannot be added to a subcommand groupr   )r   rQ   r;   r  r  )r   rs   r|   r   rS   r  s         rW   create_subgroupz!SlashCommandGroup.create_subgroupe  sZ    \ ;;"VWW-+y
15
9?
 	 12  r^   c                      d fd}|S )a+  A shortcut decorator that initializes the provided subclass of :class:`.SlashCommandGroup`
        as a subgroup.

        .. versionadded:: 2.0

        Parameters
        ----------
        name: Optional[:class:`str`]
            The name of the group to create. This will resolve to the name of the decorated class if ``None`` is passed.
        description: Optional[:class:`str`]
            The description of the group to create.
        guild_ids: Optional[List[:class:`int`]]
            A list of the IDs of each guild this group should be added to, making it a guild command.
            This will be a global command if ``None`` is passed.

        Returns
        -------
        Callable[[Type[SlashCommandGroup]], SlashCommandGroup]
            The slash command group that was created.
        c                     | xs | j                   xs> | j                  0t        j                  | j                        j	                         d   nd      }j                  |       |S )Nr   rH  )r   r   )r   rJ  r  rK  rL  r   )rD  groupr|   r   rs   r   s     rW   innerz)SlashCommandGroup.subgroup.<locals>.inner  sm    $  {{. $$S[[1<<>qA2#
E U#Lr^   )rD  ztype[SlashCommandGroup]r.  r;   r   )r   rs   r|   r   r	  s   ```` rW   subgroupzSlashCommandGroup.subgroup  s    6	 	 r^   c                &  K   |j                   j                  d   d   |j                   j                  j                  dd       }t        fd| j                        }|d<   |j                   _        |j                  |       d {    y 7 w)NrI  r   r  c                (    | j                   d   k(  S r  r  r  rv  s    rW   r  z+SlashCommandGroup._invoke.<locals>.<lambda>      6&>!9 r^   )r  r  r   r%   r  r   )r   rf   r  r:   rv  s       @rW   r   zSlashCommandGroup._invoke  sw     %%i03??''++J=94;K;KL%z%nnS!!!s   BB	B
Bc                   K   |j                   j                  d   d   t        fd| j                        }|j                   _        |j	                  |       d {    y 7 w)NrI  r   c                (    | j                   d   k(  S r  r  r  s    rW   r  z@SlashCommandGroup.invoke_autocomplete_callback.<locals>.<lambda>  r  r^   )r  r  r%   r  r  )r   rf   r:   rv  s      @rW   r  z.SlashCommandGroup.invoke_autocomplete_callback  sS     %%i0394;K;KL%223777s   AA&A$A&c                   K   | j                   }| j                  Nt        | j                  d|      }|r| j                  ||       d {    y | j                  |       d {    y y 7  7 wr  )r   r  r   r   rf   r   r  s       rW   r   z#SlashCommandGroup.call_before_hooks  sl     hh*t22JDH ))(C888))#... + 9.$   AA.	A*
A.#A,$A.,A.c                   K   | j                   }| j                  Nt        | j                  d|      }|r| j                  ||       d {    y | j                  |       d {    y y 7  7 wr  )r   r  r   r  s       rW   rd   z"SlashCommandGroup.call_after_hooks  sj     hh)t11:sCH((3777((--- * 8-r  c              #     K   | j                   D ].  }t        |t              r|j                         E d{    | 0 y7 w)a  An iterator that recursively walks through all slash commands and groups in this group.

        Yields
        ------
        :class:`.SlashCommand` | :class:`.SlashCommandGroup`
            A nested slash command or slash command group from the group.
        N)r  rk   r;   walk_commandsr  s     rW   r  zSlashCommandGroup.walk_commands  sB      '' 	G'#45"00222M	2s   3AAAc           
          | j                   d| j                  | j                  d| j                  j	                         D ci c]  \  }}|dvr|| c}}}| j                  |      S c c}}w )zCreates a copy of this command group.

        Returns
        -------
        :class:`SlashCommandGroup`
            A new instance of this command group.
        )rs   r|   r   )r   rs   r|   r   ru   r  )r   paramr   rT   s       rW   rB  zSlashCommandGroup.copy  s~     dnn 
((

 %)$<$<$B$B$D E5 77 u
 ..s33s   A+c                L   | j                   |_         | j                  |_        | j                  |_        | j                  |j                  k7  r| j                  j	                         |_        | j
                  |j
                  k7  r| j
                  j	                         |_        |S rN   )r   r  r  r  rB  r   r   s     rW   r  z,SlashCommandGroup._ensure_assignment_on_copy  s}    {{#22"00u000 $ 0 0 5 5 7E;;%,,&;;++-ELr^   c                    |rN|j                         }|j                  | j                          | j                  di |}| j	                  |      S | j                         S )Nr   )rB  r  r   r   r  r  s       rW   r  zSlashCommandGroup._update_copy  sR    BIId../!4>>'B'D2248899;r^   c                h    t         |   |       | j                  D ]  }|j                  |        y rN   )r@  r,  r  )r   r   
subcommandr   s      rW   r,  zSlashCommandGroup._set_cog#  s3    ** 	%J$	%r^   )r.  r;   )NNNNN)rs   r1  r|   
str | Noner   list[int] | Noner   zSlashCommandGroup | Noner   zCooldownMapping | Noner   zMaxConcurrency | Noner.  r/  )r.  r  r2  r5  r  )r:   z SlashCommand | SlashCommandGroupr.  r/  )rD  ztype[T]r.  z"Callable[[Callable], SlashCommand])NN)rs   r1  r|   r  r   r  r.  r;   )NNN)rs   r  r|   r  r   r  r.  z6Callable[[type[SlashCommandGroup]], SlashCommandGroup]r7  )rf   r+   r.  r/  )r.  z7Generator[SlashCommand | SlashCommandGroup, None, None]r  )r   r   r   rJ  r:  r   rA  r   r;  r   r   r<  r(  r   r5   r:   r  r
  r   r  r   rd   r  rB  r  r  r,  r  r  s   @rW   r;   r;     s   -^ A@D2 #'&*+/+/15XGXG  XG $	XG
 )XG )XG /XG 
XGt   Y Y 	 	8) *	+ #'&*	5!5!  5! $	5! 
5!r  "&&*	**  * $	*
 
@*X"8/.4&% %r^   r;   c                  N     e Zd ZdZd fdZd fdZd Zed        Zd	dZ	 xZ
S )
r<   aP	  A class that implements the protocol for context menu commands.

    These are not created manually, instead they are created via the
    decorator or functional interface.

    .. versionadded:: 2.0

    Attributes
    -----------
    name: :class:`str`
        The name of the command.
    callback: :ref:`coroutine <coroutine>`
        The coroutine that is executed when the command is called.
    guild_ids: Optional[List[:class:`int`]]
        The ids of the guilds where this command will be registered.
    guild_only: :class:`bool`
        Whether the command should only be usable inside a guild.

        .. deprecated:: 2.6
            Use the ``contexts`` parameter instead.
    nsfw: :class:`bool`
        Whether the command should be restricted to 18+ channels and users.
        Apps intending to be listed in the App Directory cannot have NSFW commands.
    default_member_permissions: :class:`~discord.Permissions`
        The default permissions a member needs to be able to run the command.
    cog: Optional[:class:`Cog`]
        The cog that this command belongs to. ``None`` if there isn't one.
    checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
        A list of predicates that verifies if the command could be executed
        with the given :class:`.ApplicationContext` as the sole parameter. If an exception
        is necessary to be thrown to signal failure, then one inherited from
        :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
        :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
        event.
    cooldown: Optional[:class:`~discord.ext.commands.Cooldown`]
        The cooldown applied when the command is invoked. ``None`` if the command
        doesn't have a cooldown.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this command. The values of this should be ``"locale": "name"``. See
        `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    integration_types: Set[:class:`IntegrationType`]
        The installation contexts where this command is available. Unapplicable for guild commands.
    contexts: Set[:class:`InteractionContextType`]
        The interaction contexts where this command is available. Unapplicable for guild commands.
    c                P    t         |   |       }|j                         |_        |S rN   r?  rC  s       rW   rA  zContextMenuCommand.__new__X  rE  r^   c                h   t        |   |fi | t        j                  |      st	        d      || _        |j                  dt              | _        d| _	        t        | j                  t              st	        d      d | _        d | _        d | _        d | _        | j#                          d | _        y )NrG  rt    z#Name of a command must be a string.)r@  r   rO   r  r   r   r   r#   rt   r|   rk   rs   r1  r   r   r  r  validate_parametersr   )r   rl   rR   rS   r   s       rW   r   zContextMenuCommand.__init__^  s    ((**40;<<28** '3

 $))S)ABB"!  " r^   c                H   | j                         }t        |j                               d   d   dk(  r5t        |j                               }|j                  d       t	        |      }t        |      }	 t        |       	 t        |       	 t        |       t        d| j                   d	      # t        $ r t        d| j                   d      w xY w# t        $ r3 t        |       t        k(  rdnd}t        d| j                   d| d      w xY w# t        $ r Y y w xY w)
Nr   r   rW  z$ command is missing "ctx" parameter.r  messagerX  rY  z! command has too many parameters.)r  r  ru   popr  rZ  r[  r\  r   rs   r   r=   )r   rS  tempcmds       rW   r#  z&ContextMenuCommand.validate_parametersx  s$   //1"1%/'DHHQK$ZFf	L	L	L!		{*KL #  	!		{*NO 	  	 J+5&9C!		{*?uLQ 	  		s*   4B0  C $D 0#C<D	D! D!c                    | j                   S rN   r  r   s    rW   r   z!ContextMenuCommand.qualified_name  s    yyr^   c                   | j                   | j                  | j                  d}| j                  sN| j                  D cg c]  }|j
                   c}|d<   | j                  D cg c]  }|j
                   c}|d<   | j                  | j                  |d<   | j                  | j                  j
                  |d<   | j                  r| j                  |d<   |S c c}w c c}w )N)rs   r|   r   r   r   r   r   rt   )
rs   r|   r   r   r   r   r   r   r   rt   )r   r  r  rf   s       rW   r(  zContextMenuCommand.to_dict  s    II++II
 ~~?C?U?U+VBHH+VG'(8<"F399"FGJ99 "iiGFO**6//55 01 "",0,C,CG() ,W"Fs   C&C!)r.  r<   r-  )r.  zdict[str, str | int])r   r   r   rJ  rA  r   r#  r;  r   r(  r  r  s   @rW   r<   r<   )  s2    ,\4 D  r^   r<   c                  D     e Zd ZdZdZd fdZd	dZd Zd Zd
dZ	 xZ
S )r=   a:	  A class that implements the protocol for user context menu commands.

    These are not created manually, instead they are created via the
    decorator or functional interface.

    Attributes
    -----------
    name: :class:`str`
        The name of the command.
    callback: :ref:`coroutine <coroutine>`
        The coroutine that is executed when the command is called.
    guild_ids: Optional[List[:class:`int`]]
        The ids of the guilds where this command will be registered.
    guild_only: :class:`bool`
        Whether the command should only be usable inside a guild.

        .. deprecated:: 2.6
            Use the ``contexts`` parameter instead.
    nsfw: :class:`bool`
        Whether the command should be restricted to 18+ channels and users.
        Apps intending to be listed in the App Directory cannot have NSFW commands.
    default_member_permissions: :class:`~discord.Permissions`
        The default permissions a member needs to be able to run the command.
    cog: Optional[:class:`Cog`]
        The cog that this command belongs to. ``None`` if there isn't one.
    checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
        A list of predicates that verifies if the command could be executed
        with the given :class:`.ApplicationContext` as the sole parameter. If an exception
        is necessary to be thrown to signal failure, then one inherited from
        :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
        :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
        event.
    cooldown: Optional[:class:`~discord.ext.commands.Cooldown`]
        The cooldown applied when the command is invoked. ``None`` if the command
        doesn't have a cooldown.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this command. The values of this should be ``"locale": "name"``. See
        `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    integration_types: Set[:class:`IntegrationType`]
        The installation contexts where this command is available. Unapplicable for guild commands.
    contexts: Set[:class:`InteractionContextType`]
        The interaction contexts where this command is available. Unapplicable for guild commands.
    r   c                P    t         |   |       }|j                         |_        |S rN   r?  rC  s       rW   rA  zUserCommand.__new__  rE  r^   c                \  K   d|j                   j                  d   vrf|j                   j                  d   d   }|j                         D ]  \  }}t        |      |d<   |} t	        |j                   j
                        }n|j                   j                  d   d   }|j                         D ]  \  }}t        |      |d<   |} |j                   j                  d   d   }|j                         D ]  \  }}t        |      |d<   |} d<   |j                   j
                  j                  j                   }|j                  j                  ||d   |      }| j                  &| j                  | j                  ||       d {    y | j                  ||       d {    y 7  7 w)Nr  r  r  r   r  r  )r  r  ru   r9  r"   r  r  r   r  r   r   )	r   rf   r  r  r  r  targetmemberr  s	            rW   r   zUserCommand._invoke  s    COO00<<OO((4W=E 1a&$  6 6TBFOO((4Y?E 1a&$ OO((4W=E 1a&$ "F6N//BBNNJYY55fd4j*UF88--#v666--V,,, 7,s$   FF,F(F,"F*#F,*F,c                r     | j                   | j                  fi | j                  }| j                  |      S )zCreates a copy of this command.

        Returns
        -------
        :class:`UserCommand`
            A new instance of this command.
        r  r  s     rW   rB  zUserCommand.copy  r  r^   c                    | j                   |_         | j                  |_        | j                  |j                  k7  r| j                  j                         |_        	 | j                  |_        |S # t
        $ r Y |S w xY wrN   r  r   s     rW   r  z&UserCommand._ensure_assignment_on_copy  r  r  c                    |rY|j                         }|j                  | j                          | j                  | j                  fi |}| j                  |      S | j                         S rN   r  r  s       rW   r  zUserCommand._update_copy   r  r^   )r.  r=   r7  r  r   r   r   rJ  r   rA  r   rB  r  r  r  r  s   @rW   r=   r=     s)    *X D-0	4"r^   r=   c                  D     e Zd ZdZdZd fdZd	dZd Zd Zd
dZ	 xZ
S )r>   a=	  A class that implements the protocol for message context menu commands.

    These are not created manually, instead they are created via the
    decorator or functional interface.

    Attributes
    -----------
    name: :class:`str`
        The name of the command.
    callback: :ref:`coroutine <coroutine>`
        The coroutine that is executed when the command is called.
    guild_ids: Optional[List[:class:`int`]]
        The ids of the guilds where this command will be registered.
    guild_only: :class:`bool`
        Whether the command should only be usable inside a guild.

        .. deprecated:: 2.6
            Use the ``contexts`` parameter instead.
    nsfw: :class:`bool`
        Whether the command should be restricted to 18+ channels and users.
        Apps intending to be listed in the App Directory cannot have NSFW commands.
    default_member_permissions: :class:`~discord.Permissions`
        The default permissions a member needs to be able to run the command.
    cog: Optional[:class:`Cog`]
        The cog that this command belongs to. ``None`` if there isn't one.
    checks: List[Callable[[:class:`.ApplicationContext`], :class:`bool`]]
        A list of predicates that verifies if the command could be executed
        with the given :class:`.ApplicationContext` as the sole parameter. If an exception
        is necessary to be thrown to signal failure, then one inherited from
        :exc:`.ApplicationCommandError` should be used. Note that if the checks fail then
        :exc:`.CheckFailure` exception is raised to the :func:`.on_application_command_error`
        event.
    cooldown: Optional[:class:`~discord.ext.commands.Cooldown`]
        The cooldown applied when the command is invoked. ``None`` if the command
        doesn't have a cooldown.
    name_localizations: Dict[:class:`str`, :class:`str`]
        The name localizations for this command. The values of this should be ``"locale": "name"``. See
        `here <https://discord.com/developers/docs/reference#locales>`_ for a list of valid locales.
    integration_types: Set[:class:`IntegrationType`]
        The installation contexts where this command is available. Unapplicable for guild commands.
    contexts: Set[:class:`InteractionContextType`]
        The interaction contexts where this command is available. Unapplicable for guild commands.
    r.   c                P    t         |   |       }|j                         |_        |S rN   r?  rC  s       rW   rA  zMessageCommand.__new__Y  rE  r^   c                4  K   |j                   j                  d   d   }|j                         D ]  \  }}t        |      |d<   |} |j                   j                  }|j
                  t        d         k7  r-t        |j                   j                  t        |d               }t        |j                   j                  ||      }| j                  &| j                  | j                  ||       d {    y | j                  ||       d {    y 7  7 w)Nr  messagesr   
channel_id)r  r   )r  r  r  )r  r  ru   r9  r  r   r   r  r   r   r   )r   rf   r  r  r  r%  r  r.  s           rW   r   zMessageCommand._invoke_  s     $$Z0<KKM 	DAq!fAdGG	 //))::W\233(oo,,W\5J1KG s55wWU88--#v666--V,,, 7,s$   C1D3D4DDDDc                r     | j                   | j                  fi | j                  }| j                  |      S )zCreates a copy of this command.

        Returns
        -------
        :class:`MessageCommand`
            A new instance of this command.
        r  r  s     rW   rB  zMessageCommand.copyr  r  r^   c                    | j                   |_         | j                  |_        | j                  |j                  k7  r| j                  j                         |_        	 | j                  |_        |S # t
        $ r Y |S w xY wrN   r  r   s     rW   r  z)MessageCommand._ensure_assignment_on_copy}  r  r  c                    |rY|j                         }|j                  | j                          | j                  | j                  fi |}| j                  |      S | j                         S rN   r  r  s       rW   r  zMessageCommand._update_copy  r  r^   )r.  r>   r6  r  r3  r  s   @rW   r>   r>   *  s)    *X D-&	4"r^   r>   c                 $    t        ddt        i| S )zDecorator for slash commands that invokes :func:`application_command`.

    .. versionadded:: 2.0

    Returns
    -------
    Callable[..., :class:`.SlashCommand`]
        A decorator that converts the provided method into a :class:`.SlashCommand`.
    rD  r   )r7   r5   rS   s    rW   r6   r6     s     :<:6::r^   c                 $    t        ddt        i| S )zDecorator for user commands that invokes :func:`application_command`.

    .. versionadded:: 2.0

    Returns
    -------
    Callable[..., :class:`.UserCommand`]
        A decorator that converts the provided method into a :class:`.UserCommand`.
    rD  r   )r7   r=   r=  s    rW   r8   r8     s     9;9&99r^   c                 $    t        ddt        i| S )a  Decorator for message commands that invokes :func:`application_command`.

    .. versionadded:: 2.0

    Returns
    -------
    Callable[..., :class:`.MessageCommand`]
        A decorator that converts the provided method into a :class:`.MessageCommand`.
    rD  r   )r7   r>   r=  s    rW   r9   r9     s     <><V<<r^   c                     d fd}|S )a  A decorator that transforms a function into an :class:`.ApplicationCommand`. More specifically,
    usually one of :class:`.SlashCommand`, :class:`.UserCommand`, or :class:`.MessageCommand`. The exact class
    depends on the ``cls`` parameter.
    By default, the ``description`` attribute is received automatically from the
    docstring of the function and is cleaned up with the use of
    ``inspect.cleandoc``. If the docstring is ``bytes``, then it is decoded
    into :class:`str` using utf-8 encoding.
    The ``name`` attribute also defaults to the function name unchanged.

    .. versionadded:: 2.0

    Parameters
    ----------
    cls: :class:`.ApplicationCommand`
        The class to construct with. By default, this is :class:`.SlashCommand`.
        You usually do not change this.
    attrs
        Keyword arguments to pass into the construction of the class denoted
        by ``cls``.

    Returns
    -------
    Callable[..., :class:`.ApplicationCommand`]
        A decorator that converts the provided method into an :class:`.ApplicationCommand`, or subclass of it.

    Raises
    ------
    TypeError
        If the function is not a coroutine or is already a command.
    c                |    t        | t              r| j                  } nt        |       st	        d       | fi S )Nz@func needs to be a callable or a subclass of ApplicationCommand.)rk   r4   r   callabler   )rl   attrsrD  s    rW   	decoratorz&application_command.<locals>.decorator  s@    d./==D$R  4!5!!r^   )rl   r   r.  rD  r   )rD  rC  rD  s   `` rW   r7   r7     s    @" r^   c                     t        di | S )aC  An alias for :meth:`application_command`.

    .. note::
        This decorator is overridden by :func:`ext.commands.command`.

    .. versionadded:: 2.0

    Returns
    -------
    Callable[..., :class:`.ApplicationCommand`]
        A decorator that converts the provided method into an :class:`.ApplicationCommand`.
    r   )r7   r=  s    rW   r:   r:     s     (((r^   z#https://discord.com/developers/docs)dadezen-GBzen-USzes-ESfrhrr  lthunlnoplzpt-BRrofizsv-SEvitrcselbgruukhithzzh-CNjazzh-TWkoc                f   ||t         vrt        d| dt         d      d }t        | t              st        d|  d      }nOt        j                  d|       st        dt         d|  d      }n"| j                         | k7  rt        d	|  d      }|r|r|j                  d
    d| f|_	        |y )NLocale '' is not a valid locale, see 1/reference#locales for list of supported locales.z9Command names and options must be of type str. Received ""z*^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$zzCommand names and options must follow the regex \"^[-_\w\d\u0901-\u097D\u0E00-\u0E7F]{1,32}$\". For more information, see zd/interactions/application-commands#application-command-object-application-command-naming. Received "z7Command names and options must be lowercase. Received "r    in locale )
valid_localesr   docsrk   r1  r   rematchlowerrR   )rs   rq   r   s      rW   rr   rr     s    fM9vh;D6 B* *
 	
 EdC GvQO
 XXCTJ v 559F!	=
 	

EdV1M
 "ZZ]O;vh?AEJ r^   c                   ||t         vrt        d| dt         d      d }t        | t              st        d|  d      }n%dt        |       cxk  rdk  sn t        d|  d      }|r|r|j                  d	    d
| f|_        |y )Nr]  r^  r_  z>Command and option description must be of type str. Received "r`  r)   d   zHCommand and option description must be 1-100 characters long. Received "r   ra  )rb  r   rc  rk   r1  r   r   rR   )r|   rq   r   s      rW   r{   r{   @  s    fM9vh;D6 B* *
 	
 Ek3'Q 
 #k")c)Q 

 "ZZ]O;vh?AEJ r^   )rm   Callable[..., Any]r.  ri  rN   )rs   r   rq   r  )r|   r   rq   r  )jrJ  
__future__r   rO   r   r[   r  rd  sysr  collectionsr   enumr   typingr   r   r   r	   r
   r   r   r   r  r   r   enumsrp  r   r   r   r   r   errorsr   r   r   r   r   r   r/  r   r%  r   r   objectr   r  r    threadsr!   r  r"   utilsr#   r$   r%   r&   r'   r(   rV  r*   r+   rI  r,   r-   version_infor0   r1   r2   typing_extensions__all__r?   r@   r"  rA   r   rB   r   rC   rD   rE   rF   rH   rI   r]   rg   rn   ry   r~   r3   r4   r5   r;   r<   r=   r>   r6   r8   r9   r7   r:   rc  rb  rr   r{   r   r^   rW   <module>rw     s  2 #     	 
  # 	 	 	 J '    )     V V < )w66AA 8HCLvU#vXc9S#s]+C&CDE#AA(6<C [wtQz': [|d% dNe%* e%PK+ K\p$ pfk' k\
;
:
= ) )X)  -FBr^   