
    cjh4                       d Z ddlmZ ddlmZmZmZ ddlZddl	m
Z
mZmZ ddlmZ erbddlmZ ddlZdd	lmZ dd
lmZ ddlmZ ddlmZmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl*m+Z+ ddlm,Z,m-Z- ddl.m/Z/  ed      Z0 edd      Z1er	 ed      Z2n ed      Z2dZ3 G d d ejh                  jj                        Z6 G d! d"      Z7y)#ae  
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.
    )annotations)TYPE_CHECKINGAnyTypeVarN)InteractionInteractionMessageInteractionResponse)Webhook)	ParamSpec   )Bot)ConnectionState)VoiceClient   )ApplicationCommandOption)InteractionChannel)Guild)Member)Message)User)Permissions)
ClientUser)Cog)WebhookMessage)Callable	Awaitable)cached_propertyTCogTr   )boundP)ApplicationContextAutocompleteContextc                     e Zd ZU dZd dZd!dZ	 	 	 	 	 	 	 	 d"dZed!d       Zed#d       Z	ed$d       Z
ed#d       Zed%d	       Zed%d
       Zed&d       Zed'd       Zed(d       Zed)d       ZeZded<   ed*d       Zed+d       Zed,d       Zed-d       Zeej4                  j7                  ej:                        d.d              Zeej4                  j7                  ej>                        	 	 d/d              Zeej4                  j7                  ej@                        d.d              Z!eej4                  j7                  e"jF                        d0d              Z$eej4                  j7                  ejJ                        d1d              Z%ed2d       Z&ddd3dZ'eej4                  j7                  ejP                        d4d              Z)ed5d       Z*y)6r#   a  Represents a Discord application command interaction context.

    This class is not created manually and is instead passed to application
    commands as the first parameter.

    .. versionadded:: 2.0

    Attributes
    ----------
    bot: :class:`.Bot`
        The bot that the command belongs to.
    interaction: :class:`.Interaction`
        The interaction object that invoked the command.
    command: :class:`.ApplicationCommand`
        The command that this context belongs to.
    c                    || _         || _        d | _        d | _        d | _        d | _        | j                  j                  | _        y N)botinteractioncommandfocusedvalueoptions_stateselfr(   r)   s      K/var/www/html/venv/lib/python3.12/site-packages/discord/commands/context.py__init__zApplicationContext.__init__W   sB    & ,0#
!'+'7'7'>'>    c                6   K   | j                   j                  S wr'   r)   channelr0   s    r1   _get_channelzApplicationContext._get_channelc   s     '''s   c               6   K    || g|i | d{   S 7 w)ai  |coro|

        Calls a command with the arguments given.
        This is useful if you want to just call the callback that a
        :class:`.ApplicationCommand` holds internally.

        .. note::

            This does not handle converters, checks, cooldowns, pre-invoke,
            or after-invoke hooks in any matter. It calls the internal callback
            directly as-if it was a regular function.
            You must take care in passing the proper arguments when
            using this function.

        Parameters
        -----------
        command: :class:`.ApplicationCommand`
            The command that is going to be called.
        \*args
            The arguments to use.
        \*\*kwargs
            The keyword arguments to use.

        Raises
        -------
        TypeError
            The command argument to invoke is missing.
        N )r0   r*   argskwargss       r1   invokezApplicationContext.invokef   s$     F T3D3F3333s   c                .    | j                   j                  S )zUnion[:class:`abc.GuildChannel`, :class:`PartialMessageable`, :class:`Thread`]:
        Returns the channel associated with this context's command. Shorthand for :attr:`.Interaction.channel`.
        r5   r7   s    r1   r6   zApplicationContext.channel       
 '''r3   c                .    | j                   j                  S )zReturns the ID of the channel associated with this context's command.
        Shorthand for :attr:`.Interaction.channel_id`.
        )r)   
channel_idr7   s    r1   rA   zApplicationContext.channel_id   s    
 ***r3   c                .    | j                   j                  S )ztReturns the guild associated with this context's command.
        Shorthand for :attr:`.Interaction.guild`.
        )r)   guildr7   s    r1   rC   zApplicationContext.guild   s    
 %%%r3   c                .    | j                   j                  S )zReturns the ID of the guild associated with this context's command.
        Shorthand for :attr:`.Interaction.guild_id`.
        )r)   guild_idr7   s    r1   rE   zApplicationContext.guild_id       
 (((r3   c                .    | j                   j                  S )zReturns the locale of the guild associated with this context's command.
        Shorthand for :attr:`.Interaction.locale`.
        )r)   localer7   s    r1   rH   zApplicationContext.locale   s    
 &&&r3   c                .    | j                   j                  S )zReturns the locale of the guild associated with this context's command.
        Shorthand for :attr:`.Interaction.guild_locale`.
        )r)   guild_localer7   s    r1   rJ   zApplicationContext.guild_locale   s    
 ,,,r3   c                .    | j                   j                  S r'   )r)   app_permissionsr7   s    r1   rL   z"ApplicationContext.app_permissions   s    ///r3   c                    | j                   j                   | j                   j                  j                  S | j                  j                  S )zUnion[:class:`.Member`, :class:`.ClientUser`]:
        Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message
        message contexts, or when :meth:`Intents.guilds` is absent.
        )r)   rC   mer(   userr7   s    r1   rN   zApplicationContext.me   sD     %%1 ""%%	
 	
r3   c                .    | j                   j                  S )zReturns the message sent with this context's command.
        Shorthand for :attr:`.Interaction.message`, if applicable.
        )r)   messager7   s    r1   rQ   zApplicationContext.message   r?   r3   Member | Userc                .    | j                   j                  S )zlReturns the user that sent this context's command.
        Shorthand for :attr:`.Interaction.user`.
        )r)   rO   r7   s    r1   rO   zApplicationContext.user   s    
 $$$r3   authorc                p    | j                   j                  y| j                   j                  j                  S )zReturns the voice client associated with this context's command.
        Shorthand for :attr:`Interaction.guild.voice_client<~discord.Guild.voice_client>`, if applicable.
        N)r)   rC   voice_clientr7   s    r1   rV   zApplicationContext.voice_client   s1    
 !!)%%222r3   c                .    | j                   j                  S )zReturns the response object associated with this context's command.
        Shorthand for :attr:`.Interaction.response`.
        )r)   responser7   s    r1   rX   zApplicationContext.response   rF   r3   c                N    | j                   j                  j                  dd      S )a  The options and values that were selected by the user when sending the command.

        Returns
        -------
        Optional[List[Dict[:class:`str`, Any]]]
            A dictionary containing the options and values that were selected by the user when the command
            was processed, if applicable. Returns ``None`` if the command has not yet been invoked,
            or if there are no options defined for that command.
        r-   N)r)   datagetr7   s    r1   selected_optionsz#ApplicationContext.selected_options   s#     $$((D99r3   c           
     6   | j                   j                  x| j                  rV| j                   j                  D cg c]4  }|j                         d   | j                  D cg c]  }|d   	 c}vr|6 c}}S | j                   j                  S yc c}w c c}}w )a[  The options that were not provided by the user when sending the command.

        Returns
        -------
        Optional[List[:class:`.Option`]]
            A list of Option objects (if any) that were not selected by the user when the command was processed.
            Returns ``None`` if there are no options defined for that command.
        Nname)r*   r-   r\   to_dict)r0   optionopts      r1   unselected_optionsz%ApplicationContext.unselected_options   s     <<+$$ #',,"6"6~~'/373H3HICCKIJ   ||+++	 J	s   %B!B-BBc                B    | j                   j                  j                  S r'   )r)   rX   
send_modalr7   s    r1   rd   zApplicationContext.send_modal	  s     ((333r3   c                .    | j                   j                  S r'   )r)   respond)r0   r;   r<   s      r1   rf   zApplicationContext.respond  r?   r3   c                    | j                   j                  j                         s | j                   j                  j                  S t	        dt        |       j                   d      )Nz5Interaction was already issued a response. Try using z.send_followup() instead.)r)   rX   is_donesend_messageRuntimeErrortype__name__r7   s    r1   send_responsez ApplicationContext.send_response  s_     ((002##,,999J''((AC r3   c                    | j                   j                  j                         r| j                  j                  S t        dt        |       j                   d      )Nz5Interaction was not yet issued a response. Try using z.respond() first.)r)   rX   rh   followupsendrj   rk   rl   r7   s    r1   send_followupz ApplicationContext.send_followup   sV     $$,,.==%%%J''((9; r3   c                B    | j                   j                  j                  S r'   )r)   rX   deferr7   s    r1   rs   zApplicationContext.defer+  s     ((...r3   c                .    | j                   j                  S )z7Returns the followup webhook for followup interactions.)r)   ro   r7   s    r1   ro   zApplicationContext.followup0  s     (((r3   Ndelayc                  K   | j                   j                  j                         s| j                          d{    | j                   j	                  |       d{   S 7 (7 w)a  |coro|

        Deletes the original interaction response message.

        This is a higher level interface to :meth:`Interaction.delete_original_response`.

        Parameters
        ----------
        delay: Optional[:class:`float`]
            If provided, the number of seconds to wait before deleting the message.

        Raises
        ------
        HTTPException
            Deleting the message failed.
        Forbidden
            You do not have proper permissions to delete the message.
        Nru   )r)   rX   rh   rs   delete_original_response)r0   rv   s     r1   deletezApplicationContext.delete5  sU     & ((002**,%%>>U>KKK Ks!   8A'A##A'A%A'%A'c                .    | j                   j                  S r'   )r)   edit_original_responser7   s    r1   editzApplicationContext.editM  s     666r3   c                H    | j                   y| j                   j                  S zgReturns the cog associated with this context's command.
        ``None`` if it does not exist.
        Nr*   cogr7   s    r1   r   zApplicationContext.cogR  !    
 <<||r3   r(   r   r)   r   )returnzInteractionChannel | None)r*   zApplicationCommand[CogT, P, T]r;   zP.argsr<   zP.kwargsr   r   )r   z
int | None)r   zGuild | None)r   z
str | None)r   r   )r   zMember | ClientUser | None)r   zMessage | None)r   rR   )r   zVoiceClient | None)r   r	   )r   zlist[dict[str, Any]] | None)r   zlist[Option] | None)r   z%Callable[..., Awaitable[Interaction]])r   z6Callable[..., Awaitable[Interaction | WebhookMessage]])r   z(Callable[..., Awaitable[WebhookMessage]])r   zCallable[..., Awaitable[None]])r   r
   )rv   zfloat | Noner   None)r   z,Callable[..., Awaitable[InteractionMessage]]r   z
Cog | None)+rl   
__module____qualname____doc__r2   r8   r=   r   r6   rA   rC   rE   rH   rJ   rL   rN   rQ   rO   rT   __annotations__propertyrV   rX   r\   rb   discordutilscopy_docr	   rd   r   rf   ri   rm   r
   rp   rq   rs   ro   ry   r{   r|   r   r:   r3   r1   r#   r#   E   s   "
?(#4/#4 	#4
 #4 
#4J ( ( + + & & ) ) ' ' - - 0 0 	
 	
 ( ( % % !FM 3 3 ) ) 
: 
:  * ]]/::;4 < 4 ]]K//0(	?( 1 (
 ]]/<<= >  ]]GLL) *  ]]/556/ 7 / ) ) 59 L0 ]]K>>?7 @ 7    r3   r#   c                  .    e Zd ZdZdZddZedd       Zy)r$   a  Represents context for a slash command's option autocomplete.

    This class is not created manually and is instead passed to an :class:`.Option`'s autocomplete callback.

    .. versionadded:: 2.0

    Attributes
    ----------
    bot: :class:`.Bot`
        The bot that the command belongs to.
    interaction: :class:`.Interaction`
        The interaction object that invoked the autocomplete.
    command: :class:`.ApplicationCommand`
        The command that this context belongs to.
    focused: :class:`.Option`
        The option the user is currently typing.
    value: :class:`.str`
        The content of the focused option.
    options: Dict[:class:`str`, Any]
        A name to value mapping of the options that the user has selected before this option.
    r(   r)   r*   r+   r,   r-   c                X    || _         || _        d | _        d | _        d | _        d | _        y r'   r   r/   s      r1   r2   zAutocompleteContext.__init__v  s-    &+/#
!r3   c                H    | j                   y| j                   j                  S r~   r   r7   s    r1   r   zAutocompleteContext.cog  r   r3   Nr   r   )rl   r   r   r   	__slots__r2   r   r   r:   r3   r1   r$   r$   ]  s(    , QI"    r3   r$   )8r   
__future__r   typingr   r   r   discord.abcr   discord.interactionsr   r   r	   discord.webhook.async_r
   typing_extensionsr    r   stater   rV   r   corer   r   interactionsr   rC   r   memberr   rQ   r   rO   r   permissionsr   clientr   r   r   webhookr   r   r   r   r   r   r    r"   __all__abcMessageabler#   r$   r:   r3   r1   <module>r      s   2 # . .  U U *+'*01!)#(* #CLvU##AA
7U 00 U p*  * r3   