
    iY|                       U d Z ddlmZ ddlZddlZddlZddlmZ ddlmZm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZ er$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Z) ededef                   Z*ej+        j,        Z,de-d<    ej.        e/          Z0 G d de1          Z2ddZ3 G d de2          Z4 G d de4          Z5dS ) a:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotationsN)app_commands)maybe_coroutine_to_kebab_case)AnyCallableClassVar	CoroutineDict	GeneratorIterableListOptionalTYPE_CHECKINGSequenceTupleTypeVarUnion   )_BaseCommandBotT	MaybeCoro)Self)	Snowflake)ClientT)BotBase)Context)Command)CogMetaCogGroupCogFuncT.)boundr   MISSINGc                       e Zd ZU dZded<   ded<   ded<   ded<   ded	<   ded
<   ded<   ded<   ded<   ded<   ded<   d fdZd fdZedd            Z xZ	S ) r   a  A metaclass for defining a cog.

    Note that you should probably not use this directly. It is exposed
    purely for documentation purposes along with making custom metaclasses to intermix
    with other metaclasses such as the :class:`abc.ABCMeta` metaclass.

    For example, to create an abstract cog mixin class, the following would be done.

    .. code-block:: python3

        import abc

        class CogABCMeta(commands.CogMeta, abc.ABCMeta):
            pass

        class SomeMixin(metaclass=abc.ABCMeta):
            pass

        class SomeCogMixin(SomeMixin, commands.Cog, metaclass=CogABCMeta):
            pass

    .. note::

        When passing an attribute of a metaclass that is documented below, note
        that you must pass it as a keyword-only argument to the class creation
        like the following example:

        .. code-block:: python3

            class MyCog(commands.Cog, name='My Cog'):
                pass

    Attributes
    -----------
    name: :class:`str`
        The cog name. By default, it is the name of the class with no modification.
    description: :class:`str`
        The cog description. By default, it is the cleaned docstring of the class.

        .. versionadded:: 1.6

    command_attrs: :class:`dict`
        A list of attributes to apply to every command inside this cog. The dictionary
        is passed into the :class:`Command` options at ``__init__``.
        If you specify attributes inside the command attribute in the class, it will
        override the one specified inside this attribute. For example:

        .. code-block:: python3

            class MyCog(commands.Cog, command_attrs=dict(hidden=True)):
                @commands.command()
                async def foo(self, ctx):
                    pass # hidden -> True

                @commands.command(hidden=False)
                async def bar(self, ctx):
                    pass # hidden -> False

    group_name: Union[:class:`str`, :class:`~discord.app_commands.locale_str`]
        The group name of a cog. This is only applicable for :class:`GroupCog` instances.
        By default, it's the same value as :attr:`name`.

        .. versionadded:: 2.0
    group_description: Union[:class:`str`, :class:`~discord.app_commands.locale_str`]
        The group description of a cog. This is only applicable for :class:`GroupCog` instances.
        By default, it's the same value as :attr:`description`.

        .. versionadded:: 2.0
    group_nsfw: :class:`bool`
        Whether the application command group is NSFW. This is only applicable for :class:`GroupCog` instances.
        By default, it's ``False``.

        .. versionadded:: 2.0
    group_auto_locale_strings: :class:`bool`
        If this is set to ``True``, then all translatable strings will implicitly
        be wrapped into :class:`~discord.app_commands.locale_str` rather
        than :class:`str`. Defaults to ``True``.

        .. versionadded:: 2.0
    group_extras: :class:`dict`
        A dictionary that can be used to store extraneous data.
        This is only applicable for :class:`GroupCog` instances.
        The library will not touch any values or keys within this dictionary.

        .. versionadded:: 2.1
    str__cog_name____cog_description__#Union[str, app_commands.locale_str]__cog_group_name____cog_group_description__bool__cog_group_nsfw__!__cog_group_auto_locale_strings__zDict[Any, Any]__cog_group_extras__Dict[str, Any]__cog_settings__zList[Command[Any, ..., Any]]__cog_commands__zDList[Union[app_commands.Group, app_commands.Command[Any, ..., Any]]]__cog_app_commands__List[Tuple[str, str]]__cog_listeners__argsr   kwargsreturnc           	        |\  }}}t          d |D                       rt          d          	 |                    d          }|                    d|          }nH# t          $ r; |}	 |                    d          }n# t          $ r t	          |          }Y nw xY wY nw xY w|                    di           |d<   ||d<   ||d<   |                    d	d
          |d<   |                    dd          |d<   |                    di           |d<   |                    dd           }|(t          j        |                    dd                    }||d<   |                    d|pd          |d<   i }	i }
i }d} t                      j	        | |||fi |}t          |j                  D ]}|j                                        D ]\  }}||	v r|	|= ||v r||= t          |t                    }|r|j        }t          |t"                    rV|rt          d| d|d          |                    d          r#t          |                    ||                    ||	|<   t          |t(          j        t(          j        f          r^|j        W|rt          d| d|d          |                    d          r#t          |                    ||                    ||
|<   !t          j        |          ra	 t3          |d           |                    d          r#t          |                    ||                    |||<   # t4          $ r Y w xY wt7          |	                                          |_        t7          |
                                          |_        g }|                                D ](}|j        D ]}|                     ||j!        f           )||_"        |S )Nc              3  J   K   | ]}t          |t          j                  V  d S N)
issubclassr   Group).0bases     Y/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/ext/commands/cog.py	<genexpr>z"CogMeta.__new__.<locals>.<genexpr>   s/      FFz$ 233FFFFFF    zbCannot inherit from app_commands.Group with commands.Cog, consider using commands.GroupCog insteadname
group_namecommand_attrsr1   r'   r*   
group_nsfwFr-   group_auto_locale_stringsTr.   group_extrasr/   description__doc__ r(   group_descriptionu   …r+   zSCommands or listeners must not start with cog_ or bot_ (in method {0.__name__}.{1})zCommand in method .z must not be staticmethod.)cog_bot___cog_listener__)#any	TypeErrorpopKeyErrorr   inspectcleandocgetsuper__new__reversed__mro____dict__items
isinstancestaticmethod__func__r   
startswithformatr   r=   r   parentiscoroutinefunctiongetattrAttributeErrorlistvaluesr2   r3   __cog_listener_names__append__name__r5   )clsr6   r7   rC   basesattrscog_namerD   rI   commandscog_app_commands	listeners
no_bot_cognew_clsr?   elemvalueis_static_methodlisteners_as_listlistenerlistener_name	__class__s                        r@   rY   zCogMeta.__new__   s   !eUFFFFFFF 	t  		<zz&))H  L(;;JJ  	2 	2 	2H2#ZZ55

 2 2 2+D11


2		2 %+JJ$C$C ! (n&0"#&,jju&E&E"#5;ZZ@[]a5b5b12(.

>2(F(F$%jj55!*599Y+C+CDDK'2#$-3ZZ8K[Md\d-e-e)*	j
!%''/#tUEDDVDDW_-- 	0 	0D#}2244 0 0e8## 9$$!$#-e\#B#B # +!NEe\22 0' h'(fT(f(fD(f(f(fggg'788 G'
(9(9$(E(EFFF%*HTNN(:L<P'QRR 0W\WcWk' h'(fT(f(fD(f(f(fggg'788 G'
(9(9$(E(EFFF-2$T**077 00'9:::  ??+;<< K"+J,=,=dD,I,I"J"JJ*/	$ * ! ! ! !0+0> $((9(9#:#: '+,<,C,C,E,E'F'F$!((** 	M 	MH!)!@ M M "((-9J)KLLLLM
 %6!sG   A B"*B ?B" BB"BB"!B">M
MMNonec                4     t                      j        |  d S r;   )rX   __init__)selfr6   r7   r{   s      r@   r~   zCogMeta.__init__  s    $rB   c                    | j         S r;   r'   )rl   s    r@   qualified_namezCogMeta.qualified_name  s    rB   )r6   r   r7   r   r8   r   )r6   r   r7   r   r8   r|   r8   r&   )
rk   
__module____qualname__rJ   __annotations__rY   r~   classmethodr   __classcell__r{   s   @r@   r   r   J   s        U Un ;;;;BBBB++++(((($$$$2222^^^^,,,,S S S S S Sj                  [         rB   r   funcr8   c                    d | _         | S r;   )__cog_special_method__)r   s    r@   _cog_special_methodr     s    "&DKrB   c                  n    e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   ded<   ded<   dZded<   ded<   ded<   dS fdZdTdZdUdZe	dVd             Z
e	dVd!            Zej        dWd$            ZdXd&ZdYd(Ze	dZd)            Zd[d+Zed\d/            Zeefd]d2            Zd^d4Zd^d5Zed_d6            Zed_d7            Zed`d;            Zed`d<            Zed`d=            Zedad@            ZedbdC            ZedcdE            ZedddF            Z edddG            Z!dedOZ"dfdRZ# xZ$S )gr    aW  The base class that all cogs must inherit from.

    A cog is a collection of commands, listeners, and optional state to
    help group commands together. More information on them can be found on
    the :ref:`ext_commands_cogs` page.

    When inheriting from this class, the options shown in :class:`CogMeta`
    are equally valid here.
    r&   r'   r(   r)   r*   r+   r0   r1   List[Command[Self, ..., Any]]r2   zEList[Union[app_commands.Group, app_commands.Command[Self, ..., Any]]]r3   r4   r5   FClassVar[bool]__cog_is_app_commands_group__Optional[app_commands.Group]__cog_app_commands_group__zbOptional[Callable[[discord.Interaction, app_commands.AppCommandError], Coroutine[Any, Any, None]]]&__discord_app_commands_error_handler__r6   r   r7   r8   r   c                   t                                          |           }| j        t          fd| j        D                       |_        d |j        D             }g }i }| j        rt          j        | j        | j	        | j
        | j        d t          | dd           t          | dd          t          | dd           t          | dd           t          | dd           | j        	          }nd }||_        |j        D ]}t          ||j        j        |           |j        }	|	||	j                 }	t)          |	d
          rFt)          |d
          r6t          |dd           }
|                    |j                  }|
r	|r||_        |	                    |j                   |	                    |           t)          |d
          r|	t          |dd           }|r|j        }|                    ||          }||_        t7          |t          j                  rL|                                D ]7}|||j        <   t)          |d          r|j        |v r||j                 |_        8|j        r|                    |           t>                               |j!                  |j!        }nd }||_"        | j#        D ]}|                    |j        |          }|j$        rt          ||j$        |           t7          |t          j                  rD||_"        |j%        &                                D ]#}t7          |t          j                  r||_"        $|                    |           ||_#        |j        rK| j'        |j        _(        d |D             }tS          |          dk    rtU          d          ||j        _%        |S )Nc              3  B   K   | ]}|                               V  d S r;   )_update_copy)r>   c	cmd_attrss     r@   rA   zCog.__new__.<locals>.<genexpr>2  s/      %^%^AannY&?&?%^%^%^%^%^%^rB   c                    i | ]
}|j         |S  )r   r>   cmds     r@   
<dictcomp>zCog.__new__.<locals>.<dictcomp>4  s    KKKc#$cKKKrB   '__discord_app_commands_default_guilds__#__discord_app_commands_guild_only__F!__discord_app_commands_contexts__+__discord_app_commands_installation_types__,__discord_app_commands_default_permissions__)rC   rI   nsfwauto_locale_stringsrc   	guild_ids
guild_onlyallowed_contextsallowed_installsdefault_permissionsextras__commands_is_hybrid__app_command)rc   binding"__commands_is_hybrid_app_command__c                    i | ]
}|j         |S r   )rC   r   s     r@   r   zCog.__new__.<locals>.<dictcomp>  s    999sx999rB      z7maximum number of application command children exceeded)+rX   rY   r1   tupler2   r   r   r=   r*   r+   r-   r.   re   r/   r   setattrcallbackrk   rc   r   hasattrrW   r   remove_commandrC   add_command
_copy_withr^   walk_commandswrappedrj   r    _get_overridden_methodcog_app_command_errorr   r3   _attr	_childrenrh   r   modulelenrR   )rl   r6   r7   r   lookupchildrenapp_command_refsgroupcommandrc   currentupdatedr   group_parentchilderror_handlercopymappingr   r{   s                     @r@   rY   zCog.__new__)  sA    wws##(	 !&%^%^%^%^I]%^%^%^ ^ ^KKT5JKKK []gi, 	 &+9+$'$I!#'PRVWW"3(MuUU!(.QSW!X!X!(.[]a!b!b$+C1_ae$f$f/  EE E*/' , '	5 '	5GD'*3W===^F! 56 6#;<< 6RjAkAk 6ipj jG /2273IJJG 67 6.5+ %%gl333""7+++w 899 5fnip]Dj j  5#'#BL"-"8"8VZ"8"["[K*5G' "+|/ABB M%0%>%>%@%@ M MEEJ,U-AB&u.RSS MX]XlpvXvXv06u7K0L6 5 444%%d&@AAM 6MM M6C3/ 	" 	"G%%T-LVZ%[[D z 0dj$///$ 233 W>K;#~4466 W WG!'<+=>> WIVFOOD!!!!$,!* 	@58^D+299999G7||b   YZZZ8?D+5rB   c                $    d | j         D             S )a~  Returns the commands that are defined inside this cog.

        This does *not* include :class:`discord.app_commands.Command` or :class:`discord.app_commands.Group`
        instances.

        Returns
        --------
        List[:class:`.Command`]
            A :class:`list` of :class:`.Command`\s that are
            defined inside this cog, not including subcommands.
        c                     g | ]}|j         	|S r;   rc   r>   r   s     r@   
<listcomp>z$Cog.get_commands.<locals>.<listcomp>  s    EEEaAH4D4D4D4DrB   )r2   r   s    r@   get_commandszCog.get_commands  s     FE40EEEErB   EList[Union[app_commands.Command[Self, ..., Any], app_commands.Group]]c                $    d | j         D             S )a  Returns the app commands that are defined inside this cog.

        Returns
        --------
        List[Union[:class:`discord.app_commands.Command`, :class:`discord.app_commands.Group`]]
            A :class:`list` of :class:`discord.app_commands.Command`\s and :class:`discord.app_commands.Group`\s that are
            defined inside this cog, not including subcommands.
        c                     g | ]}|j         	|S r;   r   r   s     r@   r   z(Cog.get_app_commands.<locals>.<listcomp>  s    IIIa8H8H8H8HrB   )r3   r   s    r@   get_app_commandszCog.get_app_commands  s     JI44IIIIrB   c                    | j         S )zC:class:`str`: Returns the cog's specified name, not the class name.r   r   s    r@   r   zCog.qualified_name  s       rB   c                    | j         S )zM:class:`str`: Returns the cog's description, typically the cleaned docstring.r(   r   s    r@   rI   zCog.description  s     ''rB   rI   r|   c                    || _         d S r;   r   )r   rI   s     r@   rI   zCog.description  s    #.   rB   .Generator[Command[Self, ..., Any], None, None]c              #     K   ddl m} | j        D ]7}|j        .|V  t	          ||          r|                                E d{V  8dS )zAn iterator that recursively walks through this cog's commands and subcommands.

        Yields
        ------
        Union[:class:`.Command`, :class:`.Group`]
            A command or group from the cog.
        r   )
GroupMixinN)corer   r2   rc   r^   r   )r   r   r   s      r@   r   zCog.walk_commands  s~       	%$$$$$, 	7 	7G~%gz22 7&44666666666		7 	7rB   VGenerator[Union[app_commands.Command[Self, ..., Any], app_commands.Group], None, None]c              #     K   | j         D ]:}|V  t          |t          j                  r|                                E d{V  ;dS )a  An iterator that recursively walks through this cog's app commands and subcommands.

        Yields
        ------
        Union[:class:`discord.app_commands.Command`, :class:`discord.app_commands.Group`]
            An app command or group from the cog.
        N)r3   r^   r   r=   r   )r   r   s     r@   walk_app_commandszCog.walk_app_commands  sg       0 	3 	3GMMM'<#566 3"00222222222	3 	3rB   c                    | j         S )zOptional[:class:`discord.app_commands.Group`]: Returns the associated group with this cog.

        This is only available if inheriting from :class:`GroupCog`.
        )r   r   s    r@   r   zCog.app_command  s     ..rB   $List[Tuple[str, Callable[..., Any]]]c                *      fd j         D             S )zReturns a :class:`list` of (name, function) listener pairs that are defined in this cog.

        Returns
        --------
        List[Tuple[:class:`str`, :ref:`coroutine <coroutine>`]]
            The listeners defined in this cog.
        c                :    g | ]\  }}|t          |          fS r   )re   )r>   rC   method_namer   s      r@   r   z%Cog.get_listeners.<locals>.<listcomp>  s-    ccc7Ht[wt[112cccrB   )r5   r   s   `r@   get_listenerszCog.get_listeners  s#     dcccDLbccccrB   methodr"   Optional[FuncT]c                .    t          |j        d|          S )zUReturn None if the method is not overridden. Otherwise returns the overridden method.r   )re   r`   )rl   r   s     r@   r   zCog._get_overridden_method  s     v(@&IIIrB   rC   Callable[[FuncT], FuncT]c                    t           ur2t          t                    st          dj        j         d          dfd}|S )a  A decorator that marks a function as a listener.

        This is the cog equivalent of :meth:`.Bot.listen`.

        Parameters
        ------------
        name: :class:`str`
            The name of the event being listened to. If not provided, it
            defaults to the function's name.

        Raises
        --------
        TypeError
            The function is not a coroutine function or a string was not passed as
            the name.
        z'Cog.listener expected str but received z	 instead.r   r"   r8   c                   | }t          |t                    r|j        }t          j        |          st          d          d|_        p|j        }	 |j        	                    |           n# t          $ r |g|_        Y nw xY w| S )Nz/Listener function must be a coroutine function.T)r^   r_   r`   rU   rd   rR   rP   rk   ri   rj   rf   )r   actual	to_assignrC   s      r@   	decoratorzCog.listener.<locals>.decorator	  s    F&,// ).v66 S QRRR&*F#/I<-44Y????! < < <1:---< Ks   A/ /BBr   r"   r8   r"   )r$   r^   r&   rR   r{   rk   )rl   rC   r   s    ` r@   ry   zCog.listener  sd    & wz$'<'<hdnF]hhhiii	 	 	 	 	 	$ rB   r,   c                8    t          | j        j        d           S )zc:class:`bool`: Checks whether the cog has an error handler.

        .. versionadded:: 1.7
        r   )r   cog_command_errorr`   r   s    r@   has_error_handlerzCog.has_error_handler  s    
 41:<TUUUUrB   c                8    t          | j        j        d           S )zg:class:`bool`: Checks whether the cog has an app error handler.

        .. versionadded:: 2.1
        r   )r   r   r`   r   s    r@   has_app_command_error_handlerz!Cog.has_app_command_error_handler$  s    
 45>@XYYYYrB   c                
   K   dS )a  |maybecoro|

        A special method that is called when the cog gets loaded.

        Subclasses must replace this if they want special asynchronous loading behaviour.
        Note that the ``__init__`` special method does not allow asynchronous code to run
        inside it, thus this is helpful for setting up code that needs to be asynchronous.

        .. versionadded:: 2.0
        Nr   r   s    r@   cog_loadzCog.cog_load+  s       	rB   c                
   K   dS )aT  |maybecoro|

        A special method that is called when the cog gets removed.

        Subclasses must replace this if they want special unloading behaviour.

        Exceptions raised in this method are ignored during extension unloading.

        .. versionchanged:: 2.0

            This method can now be a :term:`coroutine`.
        Nr   r   s    r@   
cog_unloadzCog.cog_unload9  s       	rB   ctxContext[BotT]MaybeCoro[bool]c                    dS )zA special method that registers as a :meth:`.Bot.check_once`
        check.

        This function **can** be a coroutine and must take a sole parameter,
        ``ctx``, to represent the :class:`.Context`.
        Tr   r   r   s     r@   bot_check_oncezCog.bot_check_onceI  	     trB   c                    dS )zA special method that registers as a :meth:`.Bot.check`
        check.

        This function **can** be a coroutine and must take a sole parameter,
        ``ctx``, to represent the :class:`.Context`.
        Tr   r   s     r@   	bot_checkzCog.bot_checkS  r  rB   c                    dS )a
  A special method that registers as a :func:`~discord.ext.commands.check`
        for every command and subcommand in this cog.

        This function **can** be a coroutine and must take a sole parameter,
        ``ctx``, to represent the :class:`.Context`.
        Tr   r   s     r@   	cog_checkzCog.cog_check]  r  rB   interactiondiscord.Interaction[ClientT]c                   dS )a@  A special method that registers as a :func:`discord.app_commands.check`
        for every app command and subcommand in this cog.

        This function **can** be a coroutine and must take a sole parameter,
        ``interaction``, to represent the :class:`~discord.Interaction`.

        .. versionadded:: 2.0
        Tr   )r   r  s     r@   interaction_checkzCog.interaction_checkg  s	     trB   error	Exceptionc                
   K   dS )a  |coro|

        A special method that is called whenever an error
        is dispatched inside this cog.

        This is similar to :func:`.on_command_error` except only applying
        to the commands inside this cog.

        This **must** be a coroutine.

        Parameters
        -----------
        ctx: :class:`.Context`
            The invocation context where the error happened.
        error: :class:`CommandError`
            The error that happened.
        Nr   )r   r   r  s      r@   r   zCog.cog_command_errors  s      & 	rB   app_commands.AppCommandErrorc                
   K   dS )aC  |coro|

        A special method that is called whenever an error within
        an application command is dispatched inside this cog.

        This is similar to :func:`discord.app_commands.CommandTree.on_error` except
        only applying to the application commands inside this cog.

        This **must** be a coroutine.

        Parameters
        -----------
        interaction: :class:`~discord.Interaction`
            The interaction that is being handled.
        error: :exc:`~discord.app_commands.AppCommandError`
            The exception that was raised.
        Nr   )r   r  r  s      r@   r   zCog.cog_app_command_error  s      * 	rB   c                
   K   dS )a!  |coro|

        A special method that acts as a cog local pre-invoke hook.

        This is similar to :meth:`.Command.before_invoke`.

        This **must** be a coroutine.

        Parameters
        -----------
        ctx: :class:`.Context`
            The invocation context.
        Nr   r   s     r@   cog_before_invokezCog.cog_before_invoke         	rB   c                
   K   dS )a!  |coro|

        A special method that acts as a cog local post-invoke hook.

        This is similar to :meth:`.Command.after_invoke`.

        This **must** be a coroutine.

        Parameters
        -----------
        ctx: :class:`.Context`
            The invocation context.
        Nr   r   s     r@   cog_after_invokezCog.cog_after_invoke  r  rB   botr   overrideguildOptional[Snowflake]guildsSequence[Snowflake]c                  K   | j         }t          | j                   d {V  t          | j                  D ]\  }}| |_        |j        	 |                    |           *# t          $ r[}| j        d |         D ]#}	|	j        |	                    |	j
                   $	 t          | j                   d {V  |# |xY wd }~ww xY w|j        t          j        ur|                    | j                   |j        t          j        ur|                    | j        d           | j        D ])\  }
}|                    t%          | |          |
           *| j        s(| j        D ] }|j                            ||||           !| S )NT	call_once)r  r  r  )r{   r   r   	enumerater2   cogrc   r   r  r   rC   r   r  r    	add_checkr  r5   add_listenerre   r   r3   tree)r   r  r  r  r  rl   indexr   eto_undorC   r   s               r@   _injectzCog._inject  s     n dm,,,,,,,,, ((=>> 	  	 NE7GK~%
 OOG,,,,       #'#8%#@ = =">1..w|<<< -do>>>>>>>>>a  & =--MM$.)))S%777MM$-M>>> "&!7 	? 	?D+WT;77>>>> . 	]4 ] ]$$WxuU[$\\\\s0   A""
C,3C B<:C<B??CCr   Optional[Iterable[int]]c                  K   | j         }	 | j        D ]#}|j        |                    |j                   $| j        sn| j        D ]f}|p|j        }| |j                            |j                   -|D ]6}|j                            |j        t          j
        |                     7g| j        D ])\  }}|                    t          | |          |           *|j        t          j        ur|                    | j                   |j        t          j        ur|                    | j        d           	 t%          | j                   d {V  d S # t(          $ r% t*                              d|| j                   Y d S w xY w# 	 t%          | j                   d {V  w # t(          $ r$ t*                              d|| j                   Y w w xY wxY w)N)id)r  Tr  z0Ignoring exception in cog unload for Cog %r (%r))r{   r2   rc   r   rC   r   r3   
_guild_idsr"  discordObjectr5   remove_listenerre   r  r    remove_checkr  r   r   r  _log	exceptionr   )r   r  r   rl   r   guild_idrC   r   s           r@   _ejectz
Cog._eject  sI     n	m0 5 5>)&&w|4442 e#8 e eG ) ?W-?I (//====(1 e eHH33GLZbHcHcHc3dddde &*%; F F!k##GD+$>$>EEEE}CM11  000!);;;  !4 EEEm%do66666666666 m m mQSVX\Xkllllllmm%do6666666666 m m mQSVX\XklllllmsB   D-F 9E +FFG	F$#G$+GGGG)r6   r   r7   r   r8   r   )r8   r   )r8   r   r   )rI   r&   r8   r|   )r8   r   )r8   r   )r8   r   )r8   r   )r   r"   r8   r   )rC   r&   r8   r   )r8   r,   )r8   r|   )r   r   r8   r   )r  r  r8   r   )r   r   r  r  r8   r|   )r  r  r  r  r8   r|   )r   r   r8   r|   )
r  r   r  r,   r  r  r  r  r8   r   )r  r   r   r'  r8   r|   )%rk   r   r   rJ   r   r   rY   r   r   propertyr   rI   setterr   r   r   r   r   r   r$   ry   r   r   r   r   r   r  r  r  r
  r   r   r  r  r&  r2  r   r   s   @r@   r    r      s          ;;;;BBBB$$$$3333____,,,,49!9999<<<<   m m m m m m^F F F F	J 	J 	J 	J ! ! ! X! ( ( ( X( / / / /7 7 7 7 3 3 3 3 / / / X/d d d d J J J [J ") ' ' ' ' ['RV V V VZ Z Z Z                     	 	 	 	    (    ,          . . . .`m m m m m m m mrB   r    )	metaclassc                  "    e Zd ZU dZdZded<   dS )r!   a  Represents a cog that also doubles as a parent :class:`discord.app_commands.Group` for
    the application commands defined within it.

    This inherits from :class:`Cog` and the options in :class:`CogMeta` also apply to this.
    See the :class:`Cog` documentation for methods.

    Decorators such as :func:`~discord.app_commands.guild_only`, :func:`~discord.app_commands.guilds`,
    and :func:`~discord.app_commands.default_permissions` will apply to the group if used on top of the
    cog.

    Hybrid commands will also be added to the Group, giving the ability to categorize slash commands into
    groups, while keeping the prefix-style command as a root-level command.

    For example:

    .. code-block:: python3

        from discord import app_commands
        from discord.ext import commands

        @app_commands.guild_only()
        class MyCog(commands.GroupCog, group_name='my-cog'):
            pass

    .. versionadded:: 2.0
    Tr   r   N)rk   r   r   rJ   r   r   r   rB   r@   r!   r!     s0          6 59!888888rB   r!   r   )6rJ   
__future__r   rU   r+  loggingr   discord.utilsr   r   typingr   r   r	   r
   r   r   r   r   r   r   r   r   r   r   _typesr   r   r   typing_extensionsr   discord.abcr   discord._typesr   r  r   contextr   r   r   __all__r"   utilsr$   r   	getLoggerrk   r/  typer   r   r    r!   r   rB   r@   <module>rD     s    0 # " " " " "                9 9 9 9 9 9 9 9                               " 2 1 1 1 1 1 1 1 1 1 &&&&&&%%%%%%&&&&&&       	xS1222}$ $ $ $ $w""~  ~  ~  ~  ~ d ~  ~  ~ B   
~m ~m ~m ~m ~mG ~m ~m ~m ~mB9 9 9 9 9s 9 9 9 9 9rB   