
    cjh8K                       d 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 ddlmZ dd	lmZ dd
lmZmZmZ dZerVd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. ddl/m0Z0 eedef   Z1eedef   Z2ddl3Z3 G d d      Z4 G d d      Z5 edd      Z6 G d d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)TYPE_CHECKINGTypeVarUnion   )PartialAppInfo)Asset)ChannelTypeInviteTargetVerificationLeveltry_enum)Hashable)Object)_get_as_snowflake
parse_timesnowflake_time)PartialInviteChannelPartialInviteGuildInvite)GuildChannel)GuildScheduledEvent)ConnectionState)PartialChannel)GatewayInvite)r   )InviteGuild)VanityInvite)Userr   r   Nc                  P    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
y)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typec                n    t        |d         | _        |d   | _        t        t        |d         | _        y )Nr"   r#   r$   )intr"   r#   r   r
   r$   )selfdatas     A/var/www/html/venv/lib/python3.12/site-packages/discord/invite.py__init__zPartialInviteChannel.__init__b   s.    4:f	!)+tF|!D	    c                    | j                   S Nr#   r'   s    r)   __str__zPartialInviteChannel.__str__g       yyr+   c                V    d| j                    d| j                   d| j                  dS )Nz<PartialInviteChannel id= name=z type=>r!   r/   s    r)   __repr__zPartialInviteChannel.__repr__j   s,    'ytyyk		}TUV	
r+   c                "    d| j                    dS )z2The string that allows you to mention the channel.z<#r4   r"   r/   s    r)   mentionzPartialInviteChannel.mentiono   s     DGG9Ar+   c                ,    t        | j                        S )z+Returns the channel's creation time in UTC.r   r"   r/   s    r)   
created_atzPartialInviteChannel.created_att        dgg&&r+   N)r(   InviteChannelPayloadreturnstrr?   zdatetime.datetime)__name__
__module____qualname____doc__	__slots__r*   r0   r5   propertyr8   r;    r+   r)   r   r   >   sG    B 'IE


   ' 'r+   c                  t    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y
)r   a  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.
    )	_statefeatures_icon_bannerr"   r#   _splashverification_leveldescriptionc                Z   || _         || _        |d   | _        |j                  dg       | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        t        t        |j                  d            | _
        |j                  d      | _        y )Nr#   rK   iconbannersplashrO   rP   )rJ   r"   r#   getrK   rL   rM   rN   r   r   rO   rP   )r'   stater(   r"   s       r)   r*   zPartialInviteGuild.__init__   s    ',f	#'88J#;!%&!1
#'88H#5#'88H#55=txx(<=6
 (,xx'>r+   c                    | j                   S r-   r.   r/   s    r)   r0   zPartialInviteGuild.__str__   r1   r+   c                    d| j                   j                   d| j                   d| j                  d| j                   d| j
                  dS )N<z id=r3   z
 features=z description=r4   )	__class__rB   r"   r#   rK   rP   r/   s    r)   r5   zPartialInviteGuild.__repr__   sT    ''(TWWIVDII=
SWS`S`Ra b++.a1	
r+   c                ,    t        | j                        S )z)Returns the guild's creation time in UTC.r:   r/   s    r)   r;   zPartialInviteGuild.created_at   r<   r+   c                    | j                   yt        j                  | j                  | j                  | j                         S )z-Returns the guild's icon asset, if available.N)rL   r	   _from_guild_iconrJ   r"   r/   s    r)   rR   zPartialInviteGuild.icon   s2     ::%%dkk477DJJGGr+   c                    | j                   yt        j                  | j                  | j                  | j                   d      S )z/Returns the guild's banner asset, if available.Nbannerspath)rM   r	   _from_guild_imagerJ   r"   r/   s    r)   rS   zPartialInviteGuild.banner   s9     <<&&KK$,,Y
 	
r+   c                    | j                   yt        j                  | j                  | j                  | j                   d      S )z6Returns the guild's invite splash asset, if available.Nsplashesr`   )rN   r	   rb   rJ   r"   r/   s    r)   rT   zPartialInviteGuild.splash   s9     <<&&KK$,,Z
 	
r+   N)rV   r   r(   InviteGuildPayloadr"   r&   r>   rA   )r?   zAsset | None)rB   rC   rD   rE   rF   r*   r0   r5   rG   r;   rR   rS   rT   rH   r+   r)   r   r   z   sp    #J
I?
 ' ' H H 
 
 
 
r+   Ir   )boundc                      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	 	 	 	 	 dd
ZddZddZddZedd       Zedd       ZddddZddZy)r   aq  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     |
    +------------------------------------+------------------------------------------------------------+
    | :attr:`expires_at`                 | :meth:`Client.fetch_invite` with `with_expiration` enabled |
    +------------------------------------+------------------------------------------------------------+

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

    Attributes
    -----------
    max_age: :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: :class:`bool`
        Indicates if the invite has been revoked.
    created_at: :class:`datetime.datetime`
        An aware UTC datetime object denoting the time the invite was created.
    temporary: :class:`bool`
        Indicates that the invite grants temporary membership.
        If ``True``, members who joined via this invite will be kicked upon disconnect.
    uses: :class:`int`
        How many times the invite has been used.
    max_uses: :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
        `Client.fetch_invite` with `with_expiration` enabled, the invite will never expire.

        .. versionadded:: 2.0

    channel: 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 linked with the invite.
    )max_agecodeguildrevokedr;   uses	temporarymax_usesinviterchanneltarget_usertarget_typerJ   approximate_member_countapproximate_presence_countscheduled_eventtarget_application
expires_atzhttps://discord.ggN)rk   rq   c               H   || _         |j                  d      | _        |d   | _        | j	                  |j                  d      |      | _        |j                  d      | _        t        |j                  d            | _        |j                  d      | _	        |j                  d      | _
        |j                  d      | _        |j                  d	      | _        |j                  d
      | _        |j                  dd       }|rt        |      nd | _        |j                  d      }|d n| j                   j                  |      | _        | j#                  |j                  d      |      | _        |j                  d      }|d n| j                   j                  |      | _        t)        t*        |j                  dd            | _        ddlm} |j                  d      }	|	r
 |||	      nd | _        |j                  d      }
|
rt5        |
|      | _        y d | _        y )Nri   rj   rk   rl   r;   rn   rm   ro   ru   rt   rx   rp   rq   rr   rs   r   r   r   guild_scheduled_event)rV   r(   rw   )r(   rV   )rJ   rU   ri   rj   _resolve_guildrk   rl   r   r;   rn   rm   ro   ru   rt   rx   create_userrp   _resolve_channelrq   rr   r   r   rs   scheduled_eventsr   rv   r   rw   )r'   rV   r(   rk   rq   rx   inviter_datatarget_user_datar   rv   applications              r)   r*   zInvite.__init__a  s    (-#'88I#6f	-1-@-@HHWu.

 %)HHY$74>txx?U4V&*hh{&; $ 0	$(HHZ$86:hh(7
' 59HH=W4X%XXlD1
&0Jz"d 	 xx	* (Ddkk.E.El.S 	 261F1FHHY2
  88M2  ' (()9: 	 *2$((=!4*
 	515:Q1R  _= 	 hh34=HN59 	NR 	r+   c               $   	 |d   }t        |d         }|j                  |      }|t        |||      }	 t	        |d         }|/t        |t              s|j                  |j                        xs |} | ||||      S # t        $ r d }Y Xw xY w)Nrk   r"   rq   rV   r(   rk   rq   )r&   
_get_guildr   KeyErrorr   
isinstanceget_channelr"   )clsrV   r(   
guild_dataguild_idrk   rq   s          r)   from_incompletezInvite.from_incomplete  s    

	HgJ
 :d+,H$$X.E}*5*hG 8LO8
 Z7I%J''

3>wGTHH'  	E	s   B BBc                   t        |d      }|j                  |      }t        |d         }| |j                  |      xs t	        |      }n|t	        |      nd }t	        |      } | ||||      S )Nr   
channel_idr7   r   )r   r   r&   r   r   )r   rV   r(   r   rk   r   rq   s          r)   from_gatewayzInvite.from_gateway  s{      1zB','7'7'Al+,
''
3Lv7LG+3+?Fh'TE
+GTHHr+   c                Z    ||S |y t        |d         }t        | j                  ||      S )Nr"   )r&   r   rJ   )r'   r(   rk   r   s       r)   r{   zInvite._resolve_guild  s7    
 L<tDz?!$++tX>>r+   c                &    ||S |y t        |      S r-   )r   )r'   r(   rq   s      r)   r}   zInvite._resolve_channel  s"    
 N<#D))r+   c                    | j                   S r-   )urlr/   s    r)   r0   zInvite.__str__  s    xxr+   c                    d| j                   d| j                  d| j                   d| j                   d| j                   dS )Nz<Invite code=z guild=z online=z	 members=z scheduled_event=r4   )rj   rk   ru   rt   rv   r/   s    r)   r5   zInvite.__repr__  sV    DII=

~ >556 7445 6#334A7	
r+   c                ,    t        | j                        S r-   )hashrj   r/   s    r)   __hash__zInvite.__hash__  s    DIIr+   c                    | j                   S )z.Returns the proper code portion of the invite.)rj   r/   s    r)   r"   z	Invite.id  s     yyr+   c                    | j                    d| j                   | j                  rd| j                  j                    S d S )z)A property that retrieves the invite URL./z?event= )BASErj   rv   r"   r/   s    r)   r   z
Invite.url  sK     ))Adii[PTPdPd743G3G3J3J2K)L(mnnjl(mnnr+   reasonc                  K   | j                   j                  j                  | j                  |       d{    y7 w)a  |coro|

        Revokes the instant invite.

        You must have the :attr:`~Permissions.manage_channels` permission 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   N)rJ   httpdelete_inviterj   )r'   r   s     r)   deletezInvite.delete  s/     , kk,,TYYv,FFFs   5?=?c                    || _         y)a  Links the given scheduled event to this invite.

        .. note::

            Scheduled events aren't actually associated with invites on the API.
            Any guild channel invite can have an event attached to it. Using
            :meth:`abc.GuildChannel.create_invite`, :meth:`Client.fetch_invite`,
            or this method, you can link scheduled events.

        .. versionadded:: 2.0

        Parameters
        ----------
        event: :class:`ScheduledEvent`
            The scheduled event object to link.
        N)rv   )r'   events     r)   set_scheduled_eventzInvite.set_scheduled_event  s    "  %r+   )rV   r   r(   z#InvitePayload | VanityInvitePayloadrk   z!PartialInviteGuild | Guild | Nonerq   *PartialInviteChannel | GuildChannel | None)r   type[I]rV   r   r(   InvitePayloadr?   rf   )r   r   rV   r   r(   GatewayInvitePayloadr?   rf   r-   )r(   zInviteGuildPayload | Nonerk   z!Guild | PartialInviteGuild | Noner?   zInviteGuildType | None)r(   zInviteChannelPayload | Nonerq   r   r?   zInviteChannelType | Noner>   )r?   r&   )r   z
str | None)r   r   r?   None)rB   rC   rD   rE   rF   r   r*   classmethodr   r   r{   r}   r0   r5   r   rG   r"   r   r   r   rH   r+   r)   r   r      sW   cJI*  D 48>B=
 =
 2	=

 1=
 <=
~ II /I7DI	
I I6 II /I7KI	
I I" 48?'? 1? 
 	?" ?C*)* <* 
"	*
   o o 48 G0%r+   )7rE   
__future__r   typingr   r   r   appinfor   assetr	   enumsr
   r   r   r   mixinsr   objectr   utilsr   r   r   __all__abcr   rk   r   r~   r   rV   r   types.channelr   r=   types.inviter   r   r   r   r   re   r   VanityInvitePayloadtypes.scheduled_eventsScheduledEventPayloaduserr   InviteGuildTypeInviteChannelTypedatetimer   r   rf   rH   r+   r)   <module>r      s   2 # 0 0 #  I I   @ @ !0&EC5?AOE#7?@Ol,BFJK9' 9'xd
 d
N Cx C%X C%r+   