
    cjh8                       U d Z ddlmZ ddlZddlZddlmZmZmZm	Z	m
Z
 ddlZddlZddlmZ erFd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 ddlmZm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& dZ'ejP                  jR                  Z)de*d<    e	d      Z+ e	dd      Z, e	dd      Z-er	 ed      Z.n e	d      Z. G d dej^                  j`                  ee,         Z1y)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.
    )annotationsN)TYPE_CHECKINGAnyGenericTypeVarUnion)Message)	ParamSpec)MessageableChannel)Guild)Member)ConnectionState)
ClientUserUser)VoiceProtocol   )AutoShardedBotBot)Cog)Command)
StringView)Contextr   MISSINGTBotTzUnion[Bot, AutoShardedBot])boundCogTr   Pc                  $   e Zd ZdZeedddeddddd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 ddZddddd	Zedd
       Z	ddZ
edd       Zedd       Zej                  j                  dd       Zej                  j                  dd       Zej                  j                  dd       Zej                  j                  dd       Zed d       Zd!dZej                  j-                  ej0                        d"d#d       Zy)$r   a	  Represents the context in which a command is being invoked under.

    This class contains a lot of metadata to help you understand more about
    the invocation context. This class is not created manually and is instead
    passed around to commands as the first parameter.

    This class implements the :class:`~discord.abc.Messageable` ABC.

    Attributes
    -----------
    message: :class:`.Message`
        The message that triggered the command being executed.
    bot: :class:`.Bot`
        The bot that contains the command being executed.
    args: :class:`list`
        The list of transformed arguments that were passed into the command.
        If this is accessed during the :func:`.on_command_error` event
        then this list could be incomplete.
    kwargs: :class:`dict`
        A dictionary of transformed arguments that were passed into the command.
        Similar to :attr:`args`\, if this is accessed in the
        :func:`.on_command_error` event then this dict could be incomplete.
    current_parameter: Optional[:class:`inspect.Parameter`]
        The parameter that is currently being inspected and converted.
        This is only of use for within converters.

        .. versionadded:: 2.0
    prefix: Optional[:class:`str`]
        The prefix that was used to invoke the command.
    command: Optional[:class:`Command`]
        The command that is being invoked currently.
    invoked_with: Optional[:class:`str`]
        The command name that triggered this invocation. Useful for finding out
        which alias called the command.
    invoked_parents: List[:class:`str`]
        The command names of the parents that triggered this invocation. Useful for
        finding out which aliases called the command.

        For example in commands ``?a b c test``, the invoked parents are ``['a', 'b', 'c']``.

        .. versionadded:: 1.7

    invoked_subcommand: Optional[:class:`Command`]
        The subcommand that was invoked.
        If no valid subcommand was invoked then this is equal to ``None``.
    subcommand_passed: Optional[:class:`str`]
        The string that was attempted to call a subcommand. This does not have
        to point to a valid registered subcommand and could just point to a
        nonsense string. If nothing was passed to attempt a call to a
        subcommand then this is set to ``None``.
    command_failed: :class:`bool`
        A boolean that indicates if the command failed to be parsed, checked,
        or invoked.
    NF)
argskwargsprefixcommandinvoked_withinvoked_parentsinvoked_subcommandsubcommand_passedcommand_failedcurrent_parameterc                  || _         || _        |xs g | _        |xs i | _        || _        || _        || _        || _        |	xs g | _        |
| _	        || _
        || _        || _        | j                   j                  | _        y N)messagebotr    r!   r"   r#   viewr$   r%   r&   r'   r(   r)   _state)selfr,   r-   r.   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   s                 O/var/www/html/venv/lib/python3.12/site-packages/discord/ext/commands/context.py__init__zContext.__init__z   s    " !(#zr	&,l"('. $	(4*9*?R2D->$2;L'+||':':    c               6   K    || g|i | d{   S 7 w)aU  |coro|

        Calls a command with the arguments given.

        This is useful if you want to just call the callback that a
        :class:`.Command` 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:`.Command`
            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#   r    r!   s       r1   invokezContext.invoke   s$     B T3D3F3333s   T)
call_hooksrestartc                 K   | j                   }| j                  }|t        d      |j                  |j                  }}| j
                  }| j                  }| j                  }	| j                  }
|rR|j                  xs |}t        | j                  xs d      |_        d|_        g | _        |j                         | _        n|}	 |j                  | |       d{    || _         ||_        ||_        || _        || _        |	| _        |
| _        y7 6# || _         ||_        ||_        || _        || _        |	| _        |
| _        w xY ww)a  |coro|

        Calls the command again.

        This is similar to :meth:`~.Context.invoke` except that it bypasses
        checks, cooldowns, and error handlers.

        .. note::

            If you want to bypass :exc:`.UserInputError` derived exceptions,
            it is recommended to use the regular :meth:`~.Context.invoke`
            as it will work more naturally. After all, this will end up
            using the old arguments the user has used and will thus just
            fail again.

        Parameters
        ----------
        call_hooks: :class:`bool`
            Whether to call the before and after invoke hooks.
        restart: :class:`bool`
            Whether to start the call chain from the very beginning
            or where we left off (i.e. the command that caused the error).
            The default is to start where we left off.

        Raises
        ------
        ValueError
            The context to reinvoke is not valid.
        NzThis context is not valid. r   )r7   )r#   r.   
ValueErrorindexpreviousr$   r&   r%   r'   root_parentlenr"   get_wordreinvoke)r0   r7   r8   cmdr.   r<   r=   r$   r&   r%   r'   to_calls               r1   rA   zContext.reinvoke   sC    < llyy;9:: **dmmx((!44.. 22oo,GT[[.B/DJDM#%D  $DG		7""4J"???DLDJ$DM ,D&8D##2D %6D" @DLDJ$DM ,D&8D##2D %6D"s0   CED DD "2ED 3E		Ec                >    | j                   duxr | j                  duS )z=Checks if the invocation context is valid to be invoked with.N)r"   r#   r0   s    r1   validzContext.valid   s!     {{$&C4<<t+CCr3   c                "   K   | j                   S wr+   )channelrE   s    r1   _get_channelzContext._get_channel   s     ||s   c                    | j                   y| j                  }t        j                  d|j                  z        }|j                  d|j                  j                  dd      z  | j                         S )zwThe cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``.

        .. versionadded:: 2.0
        r:   z<@!?%s>z@%s\z\\)r"   merecompileidsubdisplay_namereplace)r0   userpatterns      r1   clean_prefixzContext.clean_prefix  s`     ;;ww
 **Z$''12{{54#4#4#<#<T5#II4;;WWr3   c                H    | j                   y| j                   j                  S )zcReturns the cog associated with this context's command.
        None if it does not exist.
        N)r#   cogrE   s    r1   rW   zContext.cog  s!     <<||r3   c                .    | j                   j                  S )zaReturns the guild associated with this context's command.
        None if not available.
        )r,   guildrE   s    r1   rY   zContext.guild  s    
 ||!!!r3   c                .    | j                   j                  S )ztReturns the channel associated with this context's command.
        Shorthand for :attr:`.Message.channel`.
        )r,   rH   rE   s    r1   rH   zContext.channel%  s    
 ||###r3   c                .    | j                   j                  S )zUnion[:class:`~discord.User`, :class:`.Member`]:
        Returns the author associated with this context's command. Shorthand for :attr:`.Message.author`
        )r,   authorrE   s    r1   r\   zContext.author,  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.
        )rY   rL   r-   rS   rE   s    r1   rL   z
Context.me3  s:     !%

 64::==;Ttzz}}gZ^ZbZbZgZggr3   c                :    | j                   }|r|j                  S dS )z:A shortcut to :attr:`.Guild.voice_client`\, if applicable.N)rY   voice_client)r0   gs     r1   r_   zContext.voice_client<  s     JJ!"q~~,,r3   c                $  K   ddl m}m}m} ddlm} | j                  }|j                  }|y|j                         }| |_	        t        |      dk(  rM|j                  | d       d{    |j                         } ||j                        }		  |	|       d{   S |d   }t        |t               r$|j#                  |      xs |j%                  |      }|y	 |j&                   |j                  | |j&                         d{    	 t+        |d      r" ||j,                        }	 |	|       d{   S t        ||      r" ||j.                        }	 |	|       d{   S t        ||      r" ||j0                        }	 |	|       d{   S y7 17 # |$ r%}
|j                  | |
       d{  7   Y d}
~
yd}
~
ww xY w# t(        $ r Y yw xY w7 7 7 y7 M# |$ r%}
|j                  | |
       d{  7   Y d}
~
yd}
~
ww xY ww)aT  send_help(entity=<bot>)

        |coro|

        Shows the help command for the specified entity if given.
        The entity can be a command or a cog.

        If no entity is given, then it'll show help for the
        entire bot.

        If the entity is a string, then it looks up whether it's a
        :class:`Cog` or a :class:`Command`.

        .. note::

            Due to the way this function works, instead of returning
            something similar to :meth:`~.commands.HelpCommand.command_not_found`
            this returns :class:`None` on bad input or no help command.

        Parameters
        ----------
        entity: Optional[Union[:class:`Command`, :class:`Cog`, :class:`str`]]
            The entity to show help for.

        Returns
        -------
        Any
            The result of the help command, if any.
        r   )r   Groupwrap_callback)CommandErrorNr   __cog_commands__)corer   rb   rc   errorsrd   r-   help_commandcopycontextr?   prepare_help_commandget_bot_mappingsend_bot_helpon_help_command_error
isinstancestrget_cogget_commandqualified_nameAttributeErrorhasattrsend_cog_helpsend_group_helpsend_command_help)r0   r    r   rb   rc   rd   r-   rB   mappinginjectedeentitys               r1   	send_helpzContext.send_helpB  s    < 	87(hh;hhjt9>**4666))+G$S%6%67H%g...
 afc"[[(CCOOF,CF>	!!
 &&tV-B-BCCC	5v12():):;%f---FE*()<)<=%f---FG,()>)>?%f---G 7 / //a888  		 	D
 . . .  	5++D!444	5s  A&H(F)&HF FF =HG )HG	H)G# 7G8G# ;H<)G# %G&G# )H*)G# G!G# HF G	$G9F<:G?HG		H	GHGHG# G# !G# #H(H=H >HHHHc                X   K    | j                   j                  |fi | d {   S 7 wr+   )r,   reply)r0   contentr!   s      r1   r   zContext.reply  s(     'T\\'':6::::s   !*(*)r,   r	   r-   r   r.   r   r    z	list[Any]r!   zdict[str, Any]r"   
str | Noner#   Command | Noner$   r   r%   z	list[str]r&   r   r'   r   r(   boolr)   zinspect.Parameter | None)r#   zCommand[CogT, P, T]r    zP.argsr!   zP.kwargsreturnr   )r7   r   r8   r   r   None)r   r   )r   zdiscord.abc.Messageable)r   rp   )r   z
Cog | None)r   zGuild | None)r   r   )r   zUser | Member)r   zMember | ClientUser)r   zVoiceProtocol | None)r    r   r   r   r+   )r   r   r!   r   r   r	   )__name__
__module____qualname____doc__r   r2   r6   rA   propertyrF   rI   rU   rW   discordutilscached_propertyrY   rH   r\   rL   r_   r}   copy_docr	   r   r5   r3   r1   r   r   B   s   5z "!(!"&#'%,-1(,$6:; ; 	;
 ; ; ; ;  ; !; #; +; &; ; 4;@!4*!46<!4HP!4	
!4F 49$ <7| D D X X      ]]""" #" ]]""$ #$ ]]""# ## ]]""h #h - -
O5b ]]GMM*; +;r3   r   )2r   
__future__r   inspectrM   typingr   r   r   r   r   discord.abcr   discord.utilsdiscord.messager	   typing_extensionsr
   r   discord.guildr   discord.memberr   discord.stater   discord.userr   r   discord.voice_clientr   r-   r   r   rW   r   rf   r   r.   r   __all__r   r   __annotations__r   r   r   r   abcMessageabler   r5   r3   r1   <module>r      s   2 #  	 > >   #+.#%--2( 
}}$$ $ CLv9:vU##AAS;gkk%%wt} S;r3   