
    cjh.                    @   d Z ddlmZ ddlZddlmZmZ ddl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r0d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"  G d d      Z G d d      Z G d de      Z! G d d      Z G d de      Zdd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.
    )annotationsN)TYPE_CHECKINGAny   )ExpireBehaviourtry_enum)InvalidArgument)User)MISSING_get_as_snowflake
parse_time)IntegrationAccountIntegrationApplicationIntegrationStreamIntegrationBotIntegration)Guild)Role)r   )r   )r   )r   )IntegrationType)r   c                  $    e Zd ZdZdZddZddZy)r   zRepresents an integration account.

    .. versionadded:: 1.4

    Attributes
    ----------
    id: :class:`str`
        The account ID.
    name: :class:`str`
        The account name.
    idnamec                ,    |d   | _         |d   | _        y )Nr   r   r   )selfdatas     G/var/www/html/venv/lib/python3.12/site-packages/discord/integrations.py__init__zIntegrationAccount.__init__H   s    Dzf	    c                <    d| j                    d| j                  dS )Nz<IntegrationAccount id= name=>r   r   s    r   __repr__zIntegrationAccount.__repr__L   s    (			}AFFr   N)r   IntegrationAccountPayloadreturnNone)r&   str)__name__
__module____qualname____doc__	__slots__r   r$    r   r   r   r   9   s    
 I&Gr   r   c                  8    e Zd ZdZdZd	dZd Zd
dZddddZy)r   a7  Represents a guild integration.

    .. versionadded:: 1.4

    Attributes
    ----------
    id: :class:`int`
        The integration ID.
    name: :class:`str`
        The integration name.
    guild: :class:`Guild`
        The guild of the integration.
    type: :class:`str`
        The integration type (i.e. Twitch).
    enabled: :class:`bool`
        Whether the integration is currently enabled.
    account: :class:`IntegrationAccount`
        The account linked to this integration.
    user: :class:`User`
        The user that added this integration.
    )guildr   _statetyper   accountuserenabledc               V    || _         |j                  | _        | j                  |       y )N)r0   r1   
_from_data)r   r   r0   s      r   r   zIntegration.__init__r   s     
llr   c                j    d| j                   j                   d| j                   d| j                  dS )N<z id=r!   r"   )	__class__r)   r   r   r#   s    r   r$   zIntegration.__repr__w   s0    4>>**+4ytyym1MMr   c                    t        |d         | _        |d   | _        |d   | _        t	        |d         | _        |j                  d      }|rt        | j                  |      nd | _	        |d   | _
        y )Nr   r2   r   r3   r4   stater   r5   )intr   r2   r   r   r3   getr
   r1   r4   r5   )r   r   r4   s      r   r7   zIntegration._from_dataz   sf    4:%)&\	f	+=d9o+Nxx:>Dt{{6D	!)_r   Nreasonc                  K   | j                   j                  j                  | j                  j                  | j                  |       d{    y7 w)a  |coro|

        Deletes the integration.

        You must have the :attr:`~Permissions.manage_guild` permission to
        do this.

        Parameters
        ----------
        reason: :class:`str`
            The reason the integration was deleted. Shows up on the audit log.

            .. versionadded:: 2.0

        Raises
        ------
        Forbidden
            You do not have permission to delete the integration.
        HTTPException
            Deleting the integration failed.
        r@   N)r1   httpdelete_integrationr0   r   )r   rA   s     r   deletezIntegration.delete   s:     , kk11$**--QW1XXXs   A
AAA)r   IntegrationPayloadr0   r   r&   r'   )r   rF   r&   r'   )rA   z
str | Noner&   r'   )	r)   r*   r+   r,   r-   r   r$   r7   rE   r.   r   r   r   r   P   s)    ,	I
N- 48 Yr   r   c                  t     e Zd ZdZdZd	 fdZed
d       Zedd       Ze	e	e	d	 	 	 	 	 	 	 ddZ
ddZ xZS )r   a}  Represents a stream integration for Twitch or YouTube.

    .. versionadded:: 2.0

    Attributes
    ----------
    id: :class:`int`
        The integration ID.
    name: :class:`str`
        The integration name.
    guild: :class:`Guild`
        The guild of the integration.
    type: :class:`str`
        The integration type (i.e. Twitch).
    enabled: :class:`bool`
        Whether the integration is currently enabled.
    syncing: :class:`bool`
        Where the integration is currently syncing.
    enable_emoticons: Optional[:class:`bool`]
        Whether emoticons should be synced for this integration (currently twitch only).
    expire_behaviour: :class:`ExpireBehaviour`
        The behaviour of expiring subscribers. Aliased to ``expire_behavior`` as well.
    expire_grace_period: :class:`int`
        The grace period (in days) for expiring subscribers.
    user: :class:`User`
        The user for the integration.
    account: :class:`IntegrationAccount`
        The integration account information.
    synced_at: :class:`datetime.datetime`
        An aware UTC datetime representing when the integration was last synced.
    )revokedexpire_behaviourexpire_grace_period	synced_at_role_idsyncingenable_emoticonssubscriber_countc                    t         |   |       |d   | _        t        t        |d         | _        |d   | _        t        |d         | _        t        |d      | _
        |d   | _        |d   | _        |d   | _        y )	NrH   expire_behaviorrJ   rK   role_idrM   rN   rO   )superr7   rH   r   r   rI   rJ   r   rK   r   rL   rM   rN   rO   r   r   r:   s     r   r7   zStreamIntegration._from_data   s    4 !)_19T"342
 )--B(C ,6tK7H,I$5dI$F!)_&*+=&>%)*<%=r   c                    | j                   S )z&An alias for :attr:`expire_behaviour`.)rI   r#   s    r   rQ   z!StreamIntegration.expire_behavior   s     $$$r   c                L    | j                   j                  | j                        S )z4The role which the integration uses for subscribers.)r0   get_rolerL   r#   s    r   rolezStreamIntegration.role   s     zz""4==11r   )rI   rJ   rN   c               H  K   i }|t         ur*t        |t              st        d      |j                  |d<   |t         ur||d<   |t         ur||d<    | j
                  j                  j                  | j                  j                  | j                  fi | d{    y7 w)ah  |coro|

        Edits the integration.

        You must have the :attr:`~Permissions.manage_guild` permission to
        do this.

        Parameters
        ----------
        expire_behaviour: :class:`ExpireBehaviour`
            The behaviour when an integration subscription lapses. Aliased to ``expire_behavior`` as well.
        expire_grace_period: :class:`int`
            The period (in days) where the integration will ignore lapsed subscriptions.
        enable_emoticons: :class:`bool`
            Where emoticons should be synced for this integration (currently twitch only).

        Raises
        ------
        Forbidden
            You do not have permission to edit the integration.
        HTTPException
            Editing the guild failed.
        InvalidArgument
            ``expire_behaviour`` did not receive a :class:`ExpireBehaviour`.
        z6expire_behaviour field must be of type ExpireBehaviourrQ   rJ   rN   N)
r   
isinstancer   r	   valuer1   rC   edit_integrationr0   r   )r   rI   rJ   rN   payloads        r   editzStreamIntegration.edit   s     @ #%7*.@%L  *:)?)?G%&g--@G)*7**:G&' 0dkk//

twwR'RRRs   BB"B B"c                   K   | j                   j                  j                  | j                  j                  | j                         d{    t
        j
                  j                  t
        j                  j                        | _	        y7 Aw)a>  |coro|

        Syncs the integration.

        You must have the :attr:`~Permissions.manage_guild` permission to
        do this.

        Raises
        ------
        Forbidden
            You do not have permission to sync the integration.
        HTTPException
            Syncing the integration failed.
        N)
r1   rC   sync_integrationr0   r   datetimenowtimezoneutcrK   r#   s    r   synczStreamIntegration.sync  s^      kk//

twwGGG!**..x/@/@/D/DE 	Hs   AB
BAB)r   StreamIntegrationPayloadr&   r'   )r&   r   )r&   zRole | None)rI   r   rJ   r>   rN   boolr&   r'   )r&   r'   )r)   r*   r+   r,   r-   r7   propertyrQ   rX   r   r^   re   __classcell__r:   s   @r   r   r      s    @	I> % % 2 2 -4#*!(1S *1S !	1S
 1S 
1SfFr   r   c                      e Zd ZdZdZddZy)r   a)  Represents an application for a bot integration.

    .. versionadded:: 2.0

    Attributes
    ----------
    id: :class:`int`
        The ID for this application.
    name: :class:`str`
        The application's name.
    icon: Optional[:class:`str`]
        The application's icon hash.
    description: :class:`str`
        The application's description. Can be an empty string.
    summary: :class:`str`
        The summary of the application. Can be an empty string.
    user: Optional[:class:`User`]
        The bot user on this application.
    )r   r   icondescriptionsummaryr4   c                   t        |d         | _        |d   | _        |d   | _        |d   | _        |d   | _        |j                  d      }|rt        ||      | _        y d | _        y )Nr   r   rl   rm   rn   botr<   )	r>   r   r   rl   rm   rn   r?   r
   r4   )r   r   r=   r4   s       r   r   zIntegrationApplication.__init__D  sb    4:f	 $V	 $] 3 OxxAEE!=	4	r   N)r   IntegrationApplicationPayload)r)   r*   r+   r,   r-   r   r.   r   r   r   r   &  s    (IPr   r   c                  (     e Zd ZdZdZd fdZ xZS )r   a  Represents a bot integration on discord.

    .. versionadded:: 2.0

    Attributes
    ----------
    id: :class:`int`
        The integration ID.
    name: :class:`str`
        The integration name.
    guild: :class:`Guild`
        The guild of the integration.
    type: :class:`str`
        The integration type (i.e. Twitch).
    enabled: :class:`bool`
        Whether the integration is currently enabled.
    user: :class:`User`
        The user that added this integration.
    account: :class:`IntegrationAccount`
        The integration account information.
    application: :class:`IntegrationApplication`
        The application tied to this integration.
    )applicationc                b    t         |   |       t        |d   | j                        | _        y )Nrs   )r   r=   )rS   r7   r   r1   rs   rT   s     r   r7   zBotIntegration._from_datai  s+    4 1m$DKK
r   )r   BotIntegrationPayloadr&   r'   )r)   r*   r+   r,   r-   r7   ri   rj   s   @r   r   r   N  s    0 !I
 
r   r   c                D    | dk(  rt         | fS | dv rt        | fS t        | fS )Ndiscord>   twitchyoutube)r   r   r   )r[   s    r   _integration_factoryrz   p  s4    	u$$	'	' %''E!!r   )r[   r(   r&   ztuple[type[Integration], str])$r,   
__future__r   ra   typingr   r   enumsr   r   errorsr	   r4   r
   utilsr   r   r   __all__r0   r   rX   r   types.integrationr   ru   r   rF   r   r%   r   rq   r   r   rf   rz   r.   r   r   <module>r      s   2 #  % , #  9 9 JDR 3PG G.JY JYZFF FFR%P %PP
[ 
D"r   