
    iR                       d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddl
mZmZm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 dd
lmZ ddlmZ ddlmZ dZerTddl m!Z! ddl"m#Z$m%Z&m'Z( ddl)m*Z* ddl+m,Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl2m6Z6 ee1def         Z7ee3def         Z8ddl9Z9 G d d          Z: G d d          Z; G d de          Z#d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.
    )annotations)ListOptionalUnionTYPE_CHECKING   )Asset)
parse_timesnowflake_time_get_as_snowflake)Object)Hashable)ChannelType	NSFWLevelVerificationLevelInviteTarget
InviteTypetry_enum)PartialAppInfo)ScheduledEvent)InviteFlags)PartialInviteChannelPartialInviteGuildInvite)Self)r   InviteGuildGatewayInvite)GuildFeature)PartialChannel)ConnectionState)Guild)GuildChannel)User)	Snowflaker   r   Nc                  ^    e Zd ZdZdZddZddZdd	Zedd
            Z	edd            Z
dS )r   a  Represents a "partial" invite channel.

    This model will be given when the user is not part of the
    guild the :class:`Invite` resolves to.

    .. container:: operations

        .. describe:: x == y

            Checks if two partial channels are the same.

        .. describe:: x != y

            Checks if two partial channels are not the same.

        .. describe:: hash(x)

            Return the partial channel's hash.

        .. describe:: str(x)

            Returns the partial channel's name.

    Attributes
    -----------
    name: :class:`str`
        The partial channel's name.
    id: :class:`int`
        The partial channel's ID.
    type: :class:`ChannelType`
        The partial channel's type.
    idnametypedataInviteChannelPayloadc                    t          |d                   | _        |d         | _        t          t          |d                   | _        d S )Nr'   r(   r)   )intr'   r(   r   r   r)   )selfr*   s     U/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/invite.py__init__zPartialInviteChannel.__init__g   s7    4:f	!)+tF|!D!D			    returnstrc                    | j         S Nr(   r.   s    r/   __str__zPartialInviteChannel.__str__l   
    yr1   c                8    d| j          d| j         d| j        dS )Nz<PartialInviteChannel id= name=z type=>r&   r7   s    r/   __repr__zPartialInviteChannel.__repr__o   s)    Y47YY$)YY49YYYYr1   c                    d| j          dS )z@:class:`str`: The string that allows you to mention the channel.z<#r<   r'   r7   s    r/   mentionzPartialInviteChannel.mentionr   s     DGr1   datetime.datetimec                *    t          | j                  S )zG:class:`datetime.datetime`: Returns the channel's creation time in UTC.r   r'   r7   s    r/   
created_atzPartialInviteChannel.created_atw        dg&&&r1   N)r*   r+   r2   r3   r2   rA   )__name__
__module____qualname____doc__	__slots__r0   r8   r=   propertyr@   rD    r1   r/   r   r   C   s         B 'IE E E E
   Z Z Z Z    X ' ' ' X' ' 'r1   c                      e Zd ZdZ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dS )r   a6  Represents a "partial" invite guild.

    This model will be given when the user is not part of the
    guild the :class:`Invite` resolves to.

    .. container:: operations

        .. describe:: x == y

            Checks if two partial guilds are the same.

        .. describe:: x != y

            Checks if two partial guilds are not the same.

        .. describe:: hash(x)

            Return the partial guild's hash.

        .. describe:: str(x)

            Returns the partial guild's name.

    Attributes
    -----------
    name: :class:`str`
        The partial guild's name.
    id: :class:`int`
        The partial guild's ID.
    verification_level: :class:`VerificationLevel`
        The partial guild's verification level.
    features: List[:class:`str`]
        A list of features the guild has. See :attr:`Guild.features` for more information.
    description: Optional[:class:`str`]
        The partial guild's description.
    nsfw_level: :class:`NSFWLevel`
        The partial guild's NSFW level.

        .. versionadded:: 2.0
    vanity_url_code: Optional[:class:`str`]
        The partial guild's vanity URL code, if available.

        .. versionadded:: 2.0
    premium_subscription_count: :class:`int`
        The number of "boosts" the partial guild currently has.

        .. versionadded:: 2.0
    )_state_icon_banner_splashfeaturesr'   r(   verification_leveldescriptionvanity_url_code
nsfw_levelpremium_subscription_countstater    r*   InviteGuildPayloadr'   r-   c                d   || _         || _        |d         | _        |                    dg           | _        |                    d          | _        |                    d          | _        |                    d          | _        t          t          |                    d                    | _
        |                    d          | _        |                    d          | _        t          t          |                    d	d
                    | _        |                    d          pd
| _        d S )Nr(   rT   iconbannersplashrU   rV   rW   rX   r   rY   )rP   r'   r(   getrT   rQ   rR   rS   r   r   rU   rV   rW   r   rX   rY   )r.   rZ   r*   r'   s       r/   r0   zPartialInviteGuild.__init__   s    ',f	,0HHZ,D,D$(HHV$4$4
&*hhx&8&8&*hhx&8&85=>OQUQYQYZnQoQo5p5p*.((=*A*A.2hh7H.I.I%-i,PQ9R9R%S%S/3xx8T/U/U/ZYZ'''r1   r2   r3   c                    | j         S r5   r6   r7   s    r/   r8   zPartialInviteGuild.__str__   r9   r1   c                b    d| j         j         d| j         d| j        d| j         d| j        dS )N<z id=r;   z
 features=z description=r<   )	__class__rH   r'   r(   rT   rV   r7   s    r/   r=   zPartialInviteGuild.__repr__   s^    1' 1 1TW 1 1DI 1 1SWS` 1 1+1 1 1	
r1   rA   c                *    t          | j                  S )zE:class:`datetime.datetime`: Returns the guild's creation time in UTC.rC   r7   s    r/   rD   zPartialInviteGuild.created_at   rE   r1   Optional[str]c                @    | j         dS t          j         d| j          S )zOptional[:class:`str`]: The Discord vanity invite URL for this partial guild, if available.

        .. versionadded:: 2.0
        N/)rW   r   BASEr7   s    r/   
vanity_urlzPartialInviteGuild.vanity_url   s+     '4+66 4666r1   Optional[Asset]c                ^    | j         dS t          j        | j        | j        | j                   S )zGOptional[:class:`Asset`]: Returns the guild's icon asset, if available.N)rQ   r	   _from_guild_iconrP   r'   r7   s    r/   r]   zPartialInviteGuild.icon   s,     :4%dk47DJGGGr1   c                b    | j         dS t          j        | j        | j        | j         d          S )zIOptional[:class:`Asset`]: Returns the guild's banner asset, if available.Nbannerspath)rR   r	   _from_guild_imagerP   r'   r7   s    r/   r^   zPartialInviteGuild.banner   s2     <4&t{DGT\PYZZZZr1   c                b    | j         dS t          j        | j        | j        | j         d          S )zPOptional[:class:`Asset`]: Returns the guild's invite splash asset, if available.Nsplashesrp   )rS   r	   rr   rP   r'   r7   s    r/   r_   zPartialInviteGuild.splash   s2     <4&t{DGT\PZ[[[[r1   N)rZ   r    r*   r[   r'   r-   rF   rG   )r2   rf   )r2   rk   )rH   rI   rJ   rK   rL   r0   r8   r=   rM   rD   rj   r]   r^   r_   rN   r1   r/   r   r   }   s       / /bI[ [ [ [   
 
 
 
 ' ' ' X' 7 7 7 X7 H H H XH [ [ [ X[ \ \ \ X\ \ \r1   c                      e Zd ZdZdZdZdddd+dZed,d            Zed-d            Z		 d.d/dZ
	 d.d0dZd1dZd1dZd2dZed1d             Zed1d!            Zed3d#            Zd4d&Zdd'd5d*ZdS )6r   a  Represents a Discord :class:`Guild` or :class:`abc.GuildChannel` invite.

    Depending on the way this object was created, some of the attributes can
    have a value of ``None``.

    .. container:: operations

        .. describe:: x == y

            Checks if two invites are equal.

        .. describe:: x != y

            Checks if two invites are not equal.

        .. describe:: hash(x)

            Returns the invite hash.

        .. describe:: str(x)

            Returns the invite URL.

    The following table illustrates what methods will obtain the attributes:

    +------------------------------------+--------------------------------------------------------------+
    |             Attribute              |                          Method                              |
    +====================================+==============================================================+
    | :attr:`max_age`                    | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites`     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`max_uses`                   | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites`     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`created_at`                 | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites`     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`temporary`                  | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites`     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`uses`                       | :meth:`abc.GuildChannel.invites`\, :meth:`Guild.invites`     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`approximate_member_count`   | :meth:`Client.fetch_invite` with ``with_counts`` enabled     |
    +------------------------------------+--------------------------------------------------------------+
    | :attr:`approximate_presence_count` | :meth:`Client.fetch_invite` with ``with_counts`` enabled     |
    +------------------------------------+--------------------------------------------------------------+

    If it's not in the table above then it is available by all methods.

    Attributes
    -----------
    type: :class:`InviteType`
        The type of the invite.

        .. versionadded: 2.4
    max_age: Optional[:class:`int`]
        How long before the invite expires in seconds.
        A value of ``0`` indicates that it doesn't expire.
    code: :class:`str`
        The URL fragment used for the invite.
    guild: Optional[Union[:class:`Guild`, :class:`Object`, :class:`PartialInviteGuild`]]
        The guild the invite is for. Can be ``None`` if it's from a group direct message.
    revoked: Optional[:class:`bool`]
        Indicates if the invite has been revoked.
    created_at: Optional[:class:`datetime.datetime`]
        An aware UTC datetime object denoting the time the invite was created.
    temporary: Optional[:class:`bool`]
        Indicates that the invite grants temporary membership.
        If ``True``, members who joined via this invite will be kicked upon disconnect.
    uses: Optional[:class:`int`]
        How many times the invite has been used.
    max_uses: Optional[:class:`int`]
        How many times the invite can be used.
        A value of ``0`` indicates that it has unlimited uses.
    inviter: Optional[:class:`User`]
        The user who created the invite.
    approximate_member_count: Optional[:class:`int`]
        The approximate number of members in the guild.
    approximate_presence_count: Optional[:class:`int`]
        The approximate number of members currently active in the guild.
        This includes idle, dnd, online, and invisible members. Offline members are excluded.
    expires_at: Optional[:class:`datetime.datetime`]
        The expiration date of the invite. If the value is ``None`` when received through
        :meth:`Client.fetch_invite` with ``with_expiration`` enabled, the invite will never expire.

        .. versionadded:: 2.0
        .. versionchanged:: 2.6
            This will always be returned from all methods. ``None`` if the invite will
            never expire.

    channel: Optional[Union[:class:`abc.GuildChannel`, :class:`Object`, :class:`PartialInviteChannel`]]
        The channel the invite is for.
    target_type: :class:`InviteTarget`
        The type of target for the voice channel invite.

        .. versionadded:: 2.0

    target_user: Optional[:class:`User`]
        The user whose stream to display for this invite, if any.

        .. versionadded:: 2.0

    target_application: Optional[:class:`PartialAppInfo`]
        The embedded application the invite targets, if any.

        .. versionadded:: 2.0
    scheduled_event: Optional[:class:`ScheduledEvent`]
        The scheduled event associated with this invite, if any.

        .. versionadded:: 2.0
    scheduled_event_id: Optional[:class:`int`]
        The ID of the scheduled event associated with this invite, if any.

        .. versionadded:: 2.0
    )max_agecodeguildrevokedrD   uses	temporarymax_usesinviterchanneltarget_usertarget_typerP   approximate_member_countapproximate_presence_counttarget_application
expires_atscheduled_eventscheduled_event_idr)   _flagszhttps://discord.ggN)rx   r~   rZ   r    r*   InvitePayloadrx   *Optional[Union[PartialInviteGuild, Guild]]r~   3Optional[Union[PartialInviteChannel, GuildChannel]]c                  || _         t          t          |                    dd                    | _        |                    d          | _        |d         | _        |                     |                    d          |          | _        |                    d          | _	        t          |                    d                    | _        |                    d          | _        |                    d	          | _        |                    d
          | _        |                    d          | _        |                    d          | _        |                    dd           }|rt          |          nd | _        |                    d          }|d n| j                             |          | _        |                     |                    d          |          | _        |                    d          }|d n| j                             |          | _        t          t.          |                    dd                    | _        |                    d          }|rt3          ||          nd | _        |                    d          }	|	rt7          | j         |	          nd | _        | j        r| j        j        nd | _        |                    dd          | _        d S )Nr)   r   rv   rw   rx   ry   rD   r{   rz   r|   r   r   r   r}   r~   r   r   r   )r*   rZ   guild_scheduled_eventrZ   r*   flags) rP   r   r   r`   r)   rv   rw   _resolve_guildrx   ry   r
   rD   r{   rz   r|   r   r   r   create_userr}   _resolve_channelr~   r   r   r   r   r   r   r   r'   r   r   )
r.   rZ   r*   rx   r~   r   inviter_datatarget_user_dataapplicationr   s
             r/   r0   zInvite.__init__  s    (- (TXXfa5H5H I I	&*hhy&9&9f	040C0CDHHWDUDUW\0]0]
'+xx	':':7A$((<BXBX7Y7Y)-+)>)>#'88F#3#3	'+xx
';';9=B^9_9_'7;xx@Z7[7[%XXlD11
Q[7ez*7M7M7Maexx	**/;/CttI`I`amInIn484I4I$((S\J]J]_f4g4g88M223C3K44QUQ\QhQhiyQzQz)1,XY@Z@Z)[)[hh344=HRN59999d 	 ((#:;; 	Nk$   
  	 MQL`1j1E1H1Hfj88GQ//r1   r2   r   c               b   	 |d         }t          |d                   }|                    |          }|t          |||          }n# t          $ r d }Y nw xY wt	          |d                   }|1t          |t                    s|                    |j                  p|} | ||||          S )Nrx   r'   r~   rZ   r*   rx   r~   )r-   
_get_guildr   KeyErrorr   
isinstanceget_channelr'   )clsrZ   r*   
guild_dataguild_idrx   r~   s          r/   from_incompletezInvite.from_incomplete  s    
	HgJ
 :d+,,H$$X..E}*5*hGG  	 	 	EEE	 >RRVW`Ra=b=bZ7I%J%J''
33>wGsTHHHHs   A AAGatewayInvitePayloadc               6   t          |d          }|                    |          }t          |d                   }|&|                    |          pt	          |          }n)||                    |          nd }t	          |          } | ||||          S )Nr   
channel_idr?   r   )r   r   r-   r   r    _get_or_create_unavailable_guild)r   rZ   r*   r   rx   r   r~   s          r/   from_gatewayzInvite.from_gateway  s    "3D*"E"E050@0@0J0Jl+,,
''
33Lv7L7L7LGGHPH\E::8DDDbfE
+++GsTHHHHr1   Optional[InviteGuildPayload]*Optional[Union[Guild, PartialInviteGuild]]Optional[InviteGuildType]c                h    ||S |d S t          |d                   }t          | j        ||          S )Nr'   )r-   r   rP   )r.   r*   rx   r   s       r/   r   zInvite._resolve_guild  s<    
 L<4tDz??!$+tX>>>r1   Optional[InviteChannelPayload]Optional[InviteChannelType]c                0    ||S |d S t          |          S r5   )r   )r.   r*   r~   s      r/   r   zInvite._resolve_channel  s'    
 N<4#D)))r1   r3   c                    | j         S r5   )urlr7   s    r/   r8   zInvite.__str__  s	    xr1   c                X    d| j          d| j        d| j        d| j         d| j         dS )Nz<Invite type=z code=z guild=z online=z	 members=r<   )r)   rw   rx   r   r   r7   s    r/   r=   zInvite.__repr__  s[    8DI 8 8TY 8 8 8 858 848 8 8	
r1   r-   c                *    t          | j                  S r5   )hashrw   r7   s    r/   __hash__zInvite.__hash__  s    DIr1   c                    | j         S )z<:class:`str`: Returns the proper code portion of the invite.)rw   r7   s    r/   r'   z	Invite.id  s     yr1   c                l    | j         dz   | j        z   }| j        |dt          | j                  z   z  }|S )z7:class:`str`: A property that retrieves the invite URL.rh   Nz?event=)ri   rw   r   r3   )r.   r   s     r/   r   z
Invite.url
  s>     i#o	)".9s4#:;;;;C
r1   r   c                4    t          j        | j                  S )z`:class:`InviteFlags`: Returns the flags for this invite.

        .. versionadded:: 2.6
        )r   _from_valuer   r7   s    r/   r   zInvite.flags  s     &t{333r1   r   r$   c                   |j         | _        	 | j                            |j                   | _        n# t
          $ r
 d| _        Y nw xY w| S )aK  Sets the scheduled event for this invite.

        .. versionadded:: 2.0

        Parameters
        ----------
        scheduled_event: :class:`~discord.abc.Snowflake`
            The ID of the scheduled event.

        Returns
        --------
        :class:`Invite`
            The invite with the new scheduled event.
        N)r'   r   rx   get_scheduled_eventr   AttributeError)r.   r   s     r/   set_scheduled_eventzInvite.set_scheduled_event  sb     #2"4	(#':#A#A/BT#U#UD   	( 	( 	(#'D   	( s   $3 AAreasonr   rf   c                  K   | j         j                            | j        |           d{V }|                     | j         |          S )a  |coro|

        Revokes the instant invite.

        You must have :attr:`~Permissions.manage_channels` to do this.

        Parameters
        -----------
        reason: Optional[:class:`str`]
            The reason for deleting this invite. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have permissions to revoke invites.
        NotFound
            The invite is invalid or expired.
        HTTPException
            Revoking the invite failed.
        r   Nr   )rP   httpdelete_inviterw   r   )r.   r   r*   s      r/   deletezInvite.delete1  sT      , [%33DIf3MMMMMMMM##$+D#AAAr1   )rZ   r    r*   r   rx   r   r~   r   )rZ   r    r*   r   r2   r   )rZ   r    r*   r   r2   r   r5   )r*   r   rx   r   r2   r   )r*   r   r~   r   r2   r   rF   )r2   r-   )r2   r   )r   r$   r2   r   )r   rf   r2   r   )rH   rI   rJ   rK   rL   ri   r0   classmethodr   r   r   r   r8   r=   r   rM   r'   r   r   r   r   rN   r1   r/   r   r      s       n n`I0  D =AGK10 10 10 10 10 10f I I I [I. 
I 
I 
I [
I =A? ? ? ? ?" HL* * * * *   
 
 
 
       X    X 4 4 4 X4   . 7; B B B B B B B Br1   r   )<rK   
__future__r   typingr   r   r   r   assetr	   utilsr
   r   r   objectr   mixinsr   enumsr   r   r   r   r   r   appinfor   r   r   r   r   __all__typing_extensionsr   types.inviter   r   r   r[   r   r   types.guildr   types.channelr   r+   rZ   r    rx   r!   abcr"   userr#   r$   InviteGuildTypeInviteChannelTypedatetimer   r   rN   r1   r/   <module>r      s   0 # " " " " " 7 7 7 7 7 7 7 7 7 7 7 7       @ @ @ @ @ @ @ @ @ @             ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` # # # # # # + + + + + +        &&&&&&         
 *)))))      '&&&&&!!!!!!E#7?@Ol,BFJKOOO7' 7' 7' 7' 7' 7' 7' 7'tz\ z\ z\ z\ z\ z\ z\ z\zNB NB NB NB NBX NB NB NB NB NBr1   