
    cjh                    
   d 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 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mZmZmZm Z m!Z! dZ" G d de      Z# G d de#e      Z G d de#e      Zy)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)ABC)Iterator)ApplicationContext)CheckFailureDiscordException)Interaction)Message   )AutoShardedBot)Bot)Context)errors   )BridgeApplicationContextBridgeExtContext)BridgeCommandBridgeCommandGroupBridgeExtCommandBridgeSlashCommandbridge_commandbridge_group)r   r   c                       e Zd ZU ded<   edd       Z	 	 ddZ	 d	 	 	 d fdZdd fdZddZ	d Z
d	 Zdd
Z	 	 	 	 ddZ xZS )BotBase(list[BridgeCommand | BridgeCommandGroup]_bridge_commandsc                6    t        | dd      x}s	g x| _        }|S )z)Returns all of the bot's bridge commands.r   N)getattrr   )selfcmdss     I/var/www/html/venv/lib/python3.12/site-packages/discord/ext/bridge/bot.pybridge_commandszBotBase.bridge_commands8   s+      &8$???+--D!D    c              #     K   | j                   D ]/  }| t        |t              s|j                         E d{    1 y7 w)zAn iterator that recursively walks through all the bot's bridge commands.

        Yields
        ------
        Union[:class:`.BridgeCommand`, :class:`.BridgeCommandGroup`]
            A bridge command or bridge group of the bot.
        N)r   
isinstancer   walk_commands)r   cmds     r!   walk_bridge_commandszBotBase.walk_bridge_commandsA   sD      (( 	/CI#12,,...	/ /s   $AAAAc                V   K   ||nt         }t        | 	  ||       d {   S 7 wN)cls)r   superget_application_context)r   interactionr+   	__class__s      r!   r-   zBotBase.get_application_contextP   s2      _c*B W4[c4JJJJ   )')c                V   K   ||nt         }t        | 	  ||       d {   S 7 wr*   )r   r,   get_context)r   messager+   r/   s      r!   r2   zBotBase.get_contextX   s0     _c*: W(c(::::r0   c                \    |j                  |        | j                  j                  |       y)zTakes a :class:`.BridgeCommand` and adds both a slash and traditional (prefix-based) version of the command
        to the bot.
        N)add_tor"   append)r   commands     r!   add_bridge_commandzBotBase.add_bridge_command^   s$    
 	t##G,r#   c                     d fd}|S )a  A shortcut decorator that invokes :func:`bridge_command` and adds it to
        the internal command list via :meth:`~.Bot.add_bridge_command`.

        Returns
        -------
        Callable[..., :class:`BridgeCommand`]
            A decorator that converts the provided method into an :class:`.BridgeCommand`, adds both a slash and
            traditional (prefix-based) version of the command to the bot, and returns the :class:`.BridgeCommand`.
        c                L     t        di |       }j                  |       |S N )r   r8   funcresultkwargsr   s     r!   	decoratorz)BotBase.bridge_command.<locals>.decoratorr   s*    -^-f-d3F##F+Mr#   )returnr   r<   r   r@   rA   s   `` r!   r   zBotBase.bridge_commandg   s    	
 r#   c                     d fd}|S )aF  A decorator that is used to wrap a function as a bridge command group.

        Parameters
        ----------
        kwargs: Optional[Dict[:class:`str`, Any]]
            Keyword arguments that are directly passed to the respective command constructors. (:class:`.SlashCommandGroup` and :class:`.ext.commands.Group`)
        c                L     t        di |       }j                  |       |S r;   )r   r8   r=   s     r!   rA   z'BotBase.bridge_group.<locals>.decorator   s*    +\+F+D1F##F+Mr#   )rB   r   r<   rC   s   `` r!   r   zBotBase.bridge_groupy   s    	
 r#   c                @  K   |j                   | j                  d|       t        |j                   t              r| j                  d|       	 | j	                  |d       d {   r$|j                   j                  |       d {    nt        j                  d      	 | j                  d|       t        |j                   t              r| j                  d|       y y |j                  ret        j                  d|j                   d	      }| j                  d
||       t        |j                   t              r| j                  d||       y y y 7 7 # t        j                  $ r/}|j                   j                  ||       d {  7   Y d }~y d }~ww xY ww)Nr7   r   T	call_once'The global check once functions failed.command_completionbridge_command_completionz	Command "z" is not foundcommand_errorbridge_command_error)r7   dispatchr%   r   can_runinvoker   r   CommandErrordispatch_errorinvoked_withCommandNotFound)r   ctxexcs      r!   rP   zBotBase.invoke   sX    ;;"MM)S)#++'78.4
DcT:::++,,S111 --.WXX 2 2C8ckk+;<MM"=sC =((9S5E5E4Fn)UVCMM/34#++'784c3? 9  ;1 && ;kk00c:::;sa   AFE $E%"E EE #B2FE E F,FFFFFFc                T  K   | j                   j                  d|       t        |j                  t              x}r| j                   j                  d|       	 | j                   j                  |d       d{   r$|j                  j                  |       d{    nt        d      	 | j                   j                  d|       |r| j                   j                  d|       yy7 p7 O# t        $ r/}|j                  j                  ||       d{  7   Y d}~yd}~ww xY ww)	a  |coro|

        Invokes the application command given under the invocation
        context and handles all the internal event dispatch mechanisms.

        Parameters
        ----------
        ctx: :class:`.ApplicationCommand`
            The invocation context to invoke.
        application_commandr   TrG   NrI   application_command_completionrK   )
_botrN   r%   r7   r   rO   rP   r   r   rR   )r   rU   br_cmdrV   s       r!   invoke_application_commandz"BotBase.invoke_application_command   s      			0#6-?@@6@II/5
	EYY&&sd&;;;kk((---"#LMM . II?E		""#>D  <-   	7++,,S#666	7s`   AD( C- 8C)9"C- C+C- -<D()C- +C- -	D%6D DD D( D%%D()rB   r   )rB   z,Iterator[BridgeCommand | BridgeCommandGroup])N)r.   r	   rB   r   )r3   r
   rB   r   )r7   r   )rU   zExtContext | BridgeExtContext)rU   z-ApplicationContext | BridgeApplicationContextrB   None)__name__
__module____qualname____annotations__propertyr"   r(   r-   r2   r8   r   r   rP   r\   __classcell__)r/   s   @r!   r   r   5   sw    >> /	5/  -1K&K	!K;-$ @,E@E	Er#   r   c                      e Zd ZdZy)r   a  Represents a discord bot, with support for cross-compatibility between command types.

    This class is a subclass of :class:`.ext.commands.Bot` and as a result
    anything that you can do with a :class:`.ext.commands.Bot` you can do with
    this bot.

    .. versionadded:: 2.0
    Nr^   r_   r`   __doc__r<   r#   r!   r   r      s    r#   r   c                      e Zd ZdZy)r   zThis is similar to :class:`.Bot` except that it is inherited from
    :class:`.ext.commands.AutoShardedBot` instead.

    .. versionadded:: 2.0
    Nre   r<   r#   r!   r   r      s    r#   r   N)$rf   
__future__r   abcr   collections.abcr   discord.commandsr   discord.errorsr   r   discord.interactionsr	   discord.messager
   commandsr   ExtAutoShardedBotr   ExtBotr   
ExtContextr   contextr   r   corer   r   r   r   r   r   __all__r   r<   r#   r!   <module>rv      so   2 #  $ / 9 , # : $ ,  ?  $DEc DEN'6 W/ r#   