
    i                       d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZmZ ddlmZ ddlZddlmZ ddlmZ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 ddlmZm Z m!Z!m"Z" dZ#erfddl$m%Z% ddl&m'Z(m)Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9m:Z: ddlm;Z;m<Z< ddl=m>Z> ddl?m@Z@ eejA        ejB        ejC        f         ZD G d dee          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)	CallableDictIterableListLiteralOptionalSequenceUnionTYPE_CHECKING)datetimeN   )Hashable)MessageableGuildChannel_purge_helper)ChannelTypetry_enum)ClientException)ChannelFlags)Permissions)MISSING
parse_time_get_as_snowflake_unique)ThreadThreadMember)Self)r   r   ThreadMetadataThreadArchiveDuration)SnowflakeList)Guild)TextChannelCategoryChannelForumChannelForumTag)Member)MessagePartialMessage)	SnowflakeSnowflakeTime)Role)ConnectionStatec            
      `   e Zd ZdZdZdmdZdndZdodZdodZdpdZ	dqdZ
drdZedsd            Zedtd            Zedud            Zedvd            Zedod            Zedod            Zedwd             Zedxd"            Zedyd$            Zedyd%            Zedzd'            Zed{d)            Zed|d+            Zd}d-Zd}d.Zd}d/Zd~d3Zd4d5dd:Zd;ed4d4d4d4d<d4d=ddIZ eeeeeeeed4dJ	ddVZ!d4d5ddYZ"d4d5ddZZ#dd[Z$dd\Z%dd^Z&dd_Z'ddbZ(dwdcZ)d4d5dddZ*ddgZ+ddiZ,ddlZ-d4S )r   a
  Represents a Discord thread.

    .. container:: operations

        .. describe:: x == y

            Checks if two threads are equal.

        .. describe:: x != y

            Checks if two threads are not equal.

        .. describe:: hash(x)

            Returns the thread's hash.

        .. describe:: str(x)

            Returns the thread's name.

    .. versionadded:: 2.0

    Attributes
    -----------
    name: :class:`str`
        The thread name.
    guild: :class:`Guild`
        The guild the thread belongs to.
    id: :class:`int`
        The thread ID. This is the same as the thread starter message ID.
    parent_id: :class:`int`
        The parent :class:`TextChannel` or :class:`ForumChannel` ID this thread belongs to.
    owner_id: :class:`int`
        The user's ID that created this thread.
    last_message_id: Optional[:class:`int`]
        The last message ID of the message sent to this thread. It may
        *not* point to an existing or valid message.
    slowmode_delay: :class:`int`
        The number of seconds a member must wait between sending messages
        in this thread. A value of ``0`` denotes that it is disabled.
        Bots and users with :attr:`~Permissions.bypass_slowmode` bypass slowmode.
    message_count: :class:`int`
        An approximate number of messages in this thread.
    member_count: :class:`int`
        An approximate number of members in this thread. This caps at 50.
    total_message_sent: :class:`int`
        The total number of messages sent, including deleted messages.

        .. versionadded:: 2.6
    me: Optional[:class:`ThreadMember`]
        A thread member representing yourself, if you've joined the thread.
        This could not be available.
    archived: :class:`bool`
        Whether the thread is archived.
    locked: :class:`bool`
        Whether the thread is locked.
    invitable: :class:`bool`
        Whether non-moderators can add other non-moderators to this thread.
        This is always ``True`` for public threads.
    archiver_id: Optional[:class:`int`]
        The user's ID that archived this thread.

        .. note::
            Due to an API change, the ``archiver_id`` will always be ``None`` and can only be obtained via the audit log.

    auto_archive_duration: :class:`int`
        The duration in minutes until the thread is automatically hidden from the channel list.
        Usually a value of 60, 1440, 4320 and 10080.
    archive_timestamp: :class:`datetime.datetime`
        An aware timestamp of when the thread's archived status was last updated in UTC.
    )nameidguild_type_state_membersowner_id	parent_idlast_message_idmessage_countmember_countslowmode_delaymelockedarchived	invitablearchiver_idauto_archive_durationarchive_timestamptotal_message_sent_created_at_flags_applied_tagsr1   r"   stater-   dataThreadPayloadreturnNonec               Z    || _         || _        i | _        |                     |           d S N)r3   r1   r4   
_from_data)selfr1   rF   rG   s       V/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/discord/threads.py__init__zThread.__init__   s/    ',!
13    r   c                
   K   | S rL    rN   s    rO   _get_channelzThread._get_channel   s      rQ   strc                h    d| j         d| j        d| j         d| j        d| j         d| j         dS )Nz<Thread id=z name=z parent=z
 owner_id=z locked=z
 archived=>)r0   r/   parentr5   r<   r=   rT   s    rO   __repr__zThread.__repr__   sv    Z$' Z Z49 Z Z Z ZZ Z26+Z ZIMZ Z Z	
rQ   c                    | j         S rL   )r/   rT   s    rO   __str__zThread.__str__   s
    yrQ   c           
     $   t          |d                   | _        t          |d                   | _        t          |d                   | _        |d         | _        t          t          |d                   | _        t          |d          | _	        |
                    dd          | _        |d	         | _        |d
         | _        |
                    dd          | _        |
                    dd          | _        t!          j        dt#          t           |
                    dg                               | _        |                     |d                    |  	 |d         }t)          | |          | _        d S # t,          $ r d | _        Y d S w xY w)Nr0   r6   r5   r/   typer7   rate_limit_per_userr   r8   r9   rB   flagsQapplied_tagsthread_metadatamember)intr0   r6   r5   r/   r   r   r2   r   r7   getr:   r8   r9   rB   rD   arraymaprE   _unroll_metadatar   r;   KeyError)rN   rG   rd   s      rO   rM   zThread._from_data   sh   4:!${"344 j!122f	(0d6l(K(K
.?FW.X.X#'88,A1#E#E"&"7!%n!5'+xx0Da'H'H88GQ///4{3CR`bdIeIe@f@f/g/gd#45666'	1(^F #400DGGG  	 	 	DGGGG	s   E: :FFr   c                R   |d         | _         t          |d          | _        |d         | _        t	          |d                   | _        |                    dd          | _        |                    dd          | _        t	          |                    d	                    | _	        d S )
Nr=   r?   r@   rA   r<   Fr>   Tcreate_timestamp)
r=   r   r?   r@   r   rA   rf   r<   r>   rC   rN   rG   s     rO   ri   zThread._unroll_metadata   s    ":.*;D-*P*P*./F*G"+5d;N6O+P+P HHXu55#xxT::/9$((CU:V:V/W/WrQ   c           
        	 |d         | _         n# t          $ r Y nw xY w|                    dd          | _        |                    dd          | _        t          j        dt          t          |                    dg                               | _        	 | 	                    |d                    d S # t          $ r Y d S w xY w)Nr/   r_   r   r`   ra   rb   rc   )
r/   rj   rf   r:   rD   rg   rh   re   rE   ri   rm   s     rO   _updatezThread._update   s    	VDII 	 	 	D	 #hh'<a@@88GQ///4{3CR`bdIeIe@f@f/g/g	!!$'8"9::::: 	 	 	DD	s    
B5 5
CCThreadChannelTypec                    | j         S )z1:class:`ChannelType`: The channel's Discord type.)r2   rT   s    rO   r^   zThread.type   s     zrQ   *Optional[Union[ForumChannel, TextChannel]]c                @    | j                             | j                  S )zhOptional[Union[:class:`ForumChannel`, :class:`TextChannel`]]: The parent channel this thread belongs to.)r1   get_channelr6   rT   s    rO   rY   zThread.parent   s     z%%dn555rQ   r   c                4    t          j        | j                  S )z=:class:`ChannelFlags`: The flags associated with this thread.)r   _from_valuerD   rT   s    rO   r`   zThread.flags   s     '444rQ   Optional[Member]c                @    | j                             | j                  S )z=Optional[:class:`Member`]: The member this thread belongs to.)r1   
get_memberr5   rT   s    rO   ownerzThread.owner   s     z$$T]333rQ   c                    d| j          dS )z?:class:`str`: The string that allows you to mention the thread.z<#rX   r0   rT   s    rO   mentionzThread.mention   s     DGrQ   c                0    d| j         j         d| j         S )zq:class:`str`: Returns a URL that allows the client to jump to the thread.

        .. versionadded:: 2.0
        zhttps://discord.com/channels//)r1   r0   rT   s    rO   jump_urlzThread.jump_url   s!     Itz}HHtwHHHrQ   List[ThreadMember]c                N    t          | j                                                  S )a  List[:class:`ThreadMember`]: A list of thread members in this thread.

        This requires :attr:`Intents.members` to be properly filled. Most of the time however,
        this data is not provided by the gateway and a call to :meth:`fetch_members` is
        needed.
        )listr4   valuesrT   s    rO   memberszThread.members  s      DM((**+++rQ   List[ForumTag]c                    g }| j         $| j         j        t          j        t          j        fvr|S | j         }| j        D ].}|                    |          }||                    |           /|S )zgList[:class:`ForumTag`]: A list of tags applied to this thread.

        .. versionadded:: 2.1
        )rY   r^   r   forummediarE   get_tagappend)rN   tagsrY   tag_idtags        rO   rb   zThread.applied_tags  sw     ;$+"2;;LkN_:`"`"`K( 	! 	!F..((CC   rQ   Optional[Message]c                @    | j                             | j                  S )ab  Returns the thread starter message from the cache.

        The message might not be cached, valid, or point to an existing message.

        Note that the thread starter message ID is the same ID as the thread.

        Returns
        --------
        Optional[:class:`Message`]
            The thread starter message or ``None`` if not found.
        )r3   _get_messager0   rT   s    rO   starter_messagezThread.starter_message#  s     {''000rQ   c                R    | j         r| j                            | j                   ndS )a=  Returns the last message from this thread from the cache.

        The message might not be valid or point to an existing message.

        .. admonition:: Reliable Fetching
            :class: helpful

            For a slightly more reliable method of fetching the
            last message, consider using either :meth:`history`
            or :meth:`fetch_message` with the :attr:`last_message_id`
            attribute.

        Returns
        ---------
        Optional[:class:`Message`]
            The last message in this channel or ``None`` if not found.
        N)r7   r3   r   rT   s    rO   last_messagezThread.last_message2  s-    & BFAU_t{''(<===[__rQ   Optional[CategoryChannel]c                @    | j         }|t          d          |j        S )a?  The category channel the parent channel belongs to, if applicable.

        Raises
        -------
        ClientException
            The parent channel was not cached and returned ``None``.

        Returns
        -------
        Optional[:class:`CategoryChannel`]
            The parent channel's category.
        NParent channel not found)rY   r   categoryrN   rY   s     rO   r   zThread.categoryG  s'     >!"<===rQ   Optional[int]c                @    | j         }|t          d          |j        S )a9  The category channel ID the parent channel belongs to, if applicable.

        Raises
        -------
        ClientException
            The parent channel was not cached and returned ``None``.

        Returns
        -------
        Optional[:class:`int`]
            The parent channel's category ID.
        Nr   )rY   r   category_idr   s     rO   r   zThread.category_id[  s(     >!"<===!!rQ   Optional[datetime]c                    | j         S )zAn aware timestamp of when the thread was created in UTC.

        .. note::

            This timestamp only exists for threads created after 9 January 2022, otherwise returns ``None``.
        )rC   rT   s    rO   
created_atzThread.created_ato  s     rQ   boolc                (    | j         t          j        u S )z:class:`bool`: Whether the thread is a private thread.

        A private thread is only viewable by those that have been explicitly
        invited or have :attr:`~.Permissions.manage_threads`.
        )r2   r   private_threadrT   s    rO   
is_privatezThread.is_privatey  s     z[777rQ   c                (    | j         t          j        u S )z:class:`bool`: Whether the thread is a news thread.

        A news thread is a thread that has a parent that is a news channel,
        i.e. :meth:`.TextChannel.is_news` is ``True``.
        )r2   r   news_threadrT   s    rO   is_newszThread.is_news  s     z[444rQ   c                @    | j         }|duo|                                S )z:class:`bool`: Whether the thread is NSFW or not.

        An NSFW thread is a thread that has a parent that is an NSFW channel,
        i.e. :meth:`.TextChannel.is_nsfw` is ``True``.
        N)rY   is_nsfwr   s     rO   r   zThread.is_nsfw  s%     T!6fnn&6&66rQ   objUnion[Member, Role]r   c                  | j         }|t          d          t          j        ||          }|j        sd|_        d|_        d|_        d|_        |j	        s)t          j                    }|xj        |j         z  c_        |S )a%  Handles permission resolution for the :class:`~discord.Member`
        or :class:`~discord.Role`.

        Since threads do not have their own permissions, they mostly
        inherit them from the parent channel with some implicit
        permissions changed.

        Parameters
        ----------
        obj: Union[:class:`~discord.Member`, :class:`~discord.Role`]
            The object to resolve permissions for. This could be either
            a member or a role. If it's a role then member overwrites
            are not computed.

        Raises
        -------
        ClientException
            The parent channel was not cached and returned ``None``

        Returns
        -------
        :class:`~discord.Permissions`
            The resolved permissions for the member or role.
        Nr   F)rY   r   r   permissions_forsend_messages_in_threadssend_tts_messagesmention_everyoneembed_linksattach_filesread_messagesr   all_channelvalue)rN   r   rY   basedenieds        rO   r   zThread.permissions_for  s    4 >!"<===+FC88 , 	&%*D"$)D!$D %D ! 	( ,..FJJ6<-'JJrQ   NreasonmessagesIterable[Snowflake]r   Optional[str]c                K   t          |t          t          f          st          |          }t          |          dk    rdS t          |          dk    r<|d         j        }| j        j                            | j        ||           d{V  dS t          |          dk    rt          d          d |D             }| j        j        	                    | j        ||           d{V  dS )a  |coro|

        Deletes a list of messages. This is similar to :meth:`Message.delete`
        except it bulk deletes multiple messages.

        As a special case, if the number of messages is 0, then nothing
        is done. If the number of messages is 1 then single message
        delete is done. If it's more than two, then bulk delete is used.

        You cannot bulk delete more than 100 messages or messages that
        are older than 14 days old.

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

        Parameters
        -----------
        messages: Iterable[:class:`abc.Snowflake`]
            An iterable of messages denoting which ones to bulk delete.
        reason: Optional[:class:`str`]
            The reason for deleting the messages. Shows up on the audit log.

        Raises
        ------
        ClientException
            The number of messages to delete was more than 100.
        Forbidden
            You do not have proper permissions to delete the messages or
            you're not using a bot account.
        NotFound
            If single delete, then the message was already deleted.
        HTTPException
            Deleting the messages failed.
        r   Nr   r   d   z0Can only bulk delete messages up to 100 messagesc                    g | ]	}|j         
S rS   r|   ).0ms     rO   
<listcomp>z*Thread.delete_messages.<locals>.<listcomp>  s    %=%=%=qad%=%=%=rQ   )

isinstancer   tuplelenr0   r3   httpdelete_messager   delete_messages)rN   r   r   
message_idmessage_idss        rO   r   zThread.delete_messages  s     D (T5M22 	&H~~Hx==AFx==A!!J+"11$':f1UUUUUUUUUFx==3!"TUUU%=%=H%=%=%=k..twF.SSSSSSSSSSSrQ   r   Tlimitcheckbeforeafteraroundoldest_firstbulkr   r   r   Callable[[Message], bool]r   Optional[SnowflakeTime]r   r   r   Optional[bool]r   List[Message]c               B   K   t          | ||||||||	  	         d{V S )a1	  |coro|

        Purges a list of messages that meet the criteria given by the predicate
        ``check``. If a ``check`` is not provided then all messages are deleted
        without discrimination.

        You must have :attr:`~Permissions.manage_messages` to
        delete messages even if they are your own.
        Having :attr:`~Permissions.read_message_history` is
        also needed to retrieve message history.

        Examples
        ---------

        Deleting bot's messages ::

            def is_me(m):
                return m.author == client.user

            deleted = await thread.purge(limit=100, check=is_me)
            await thread.send(f'Deleted {len(deleted)} message(s)')

        Parameters
        -----------
        limit: Optional[:class:`int`]
            The number of messages to search through. This is not the number
            of messages that will be deleted, though it can be.
        check: Callable[[:class:`Message`], :class:`bool`]
            The function used to check if a message should be deleted.
            It must take a :class:`Message` as its sole parameter.
        before: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
            Same as ``before`` in :meth:`history`.
        after: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
            Same as ``after`` in :meth:`history`.
        around: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]]
            Same as ``around`` in :meth:`history`.
        oldest_first: Optional[:class:`bool`]
            Same as ``oldest_first`` in :meth:`history`.
        bulk: :class:`bool`
            If ``True``, use bulk delete. Setting this to ``False`` is useful for mass-deleting
            a bot's own messages without :attr:`Permissions.manage_messages`. When ``True``, will
            fall back to single delete if messages are older than two weeks.
        reason: Optional[:class:`str`]
            The reason for purging the messages. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have proper permissions to do the actions required.
        HTTPException
            Purging the messages failed.

        Returns
        --------
        List[:class:`.Message`]
            The list of messages that were deleted.
        r   N)r   )	rN   r   r   r   r   r   r   r   r   s	            rO   purgezThread.purge  sY      L #%

 

 

 

 

 

 

 

 

 
	
rQ   )	r/   r=   r<   r>   pinnedr:   r@   rb   r   r/   r=   r<   r>   r   r:   re   r@   r    rb   Sequence[ForumTag]c       	          K   i }
|t           urt          |          |
d<   |t           ur||
d<   |t           ur||
d<   |t           ur||
d<   |t           ur||
d<   |t           ur||
d<   |t           ur| j        }||_        |j        |
d<   |t           urd |D             |
d	<    | j        j        j        | j        fi |
d
|	i d{V }t          || j        | j
                  S )a  |coro|

        Edits the thread.

        Editing the thread requires :attr:`.Permissions.manage_threads`. The thread
        creator can also edit ``name``, ``archived`` or ``auto_archive_duration``.
        Note that if the thread is locked then only those with :attr:`.Permissions.manage_threads`
        can unarchive a thread.

        The thread must be unarchived to be edited.

        Parameters
        ------------
        name: :class:`str`
            The new name of the thread.
        archived: :class:`bool`
            Whether to archive the thread or not.
        locked: :class:`bool`
            Whether to lock the thread or not.
        pinned: :class:`bool`
            Whether to pin the thread or not. This only works if the thread is part of a forum.
        invitable: :class:`bool`
            Whether non-moderators can add other non-moderators to this thread.
            Only available for private threads.
        auto_archive_duration: :class:`int`
            The new duration in minutes before a thread is automatically hidden from the channel list.
            Must be one of ``60``, ``1440``, ``4320``, or ``10080``.
        slowmode_delay: :class:`int`
            Specifies the slowmode rate limit for user in this thread, in seconds.
            A value of ``0`` disables slowmode. The maximum value possible is ``21600``.
        applied_tags: Sequence[:class:`ForumTag`]
            The new tags to apply to the thread. There can only be up to 5 tags applied to a thread.

            .. versionadded:: 2.1
        reason: Optional[:class:`str`]
            The reason for editing this thread. Shows up on the audit log.

        Raises
        -------
        Forbidden
            You do not have permissions to edit the thread.
        HTTPException
            Editing the thread failed.

        Returns
        --------
        :class:`Thread`
            The newly edited thread.
        r/   r=   r@   r<   r>   r_   r`   c                6    g | ]}t          |j                  S rS   rV   r0   r   r   s     rO   r   zThread.edit.<locals>.<listcomp>  s     &K&K&Kss36{{&K&K&KrQ   rb   r   N)rG   rF   r1   )r   rV   r`   r   r   r3   r   edit_channelr0   r   r1   )rN   r/   r=   r<   r>   r   r:   r@   rb   r   payloadr`   rG   s                rO   editzThread.editF  s2     | w!$iiGFO7"""*GJ ///DG+,   &GHG###,GK ((-;G)*  JE!EL${GGw&&&K&Kl&K&K&KGN#2T[%247UUgUUfUUUUUUUUU4t{$*EEEErQ   r   r*   c                  K   d | j         D             }|                    d |D                        | j        j                            | j        t          |          |           d{V  dS )a  |coro|

        Adds the given forum tags to a thread.

        You must have :attr:`~Permissions.manage_threads` to
        use this or the thread must be owned by you.

        Tags that have :attr:`ForumTag.moderated` set to ``True`` require
        :attr:`~Permissions.manage_threads` to be added.

        The maximum number of tags that can be added to a thread is 5.

        The parent channel must be a :class:`ForumChannel`.

        .. versionadded:: 2.1

        Parameters
        -----------
        \*tags: :class:`abc.Snowflake`
            An argument list of :class:`abc.Snowflake` representing a :class:`ForumTag`
            to add to the thread.
        reason: Optional[:class:`str`]
            The reason for adding these tags.

        Raises
        -------
        Forbidden
            You do not have permissions to add these tags.
        HTTPException
            Adding tags failed.
        c                ,    g | ]}t          |          S rS   rV   r   s     rO   r   z#Thread.add_tags.<locals>.<listcomp>  s    ???SC???rQ   c              3  >   K   | ]}t          |j                  V  d S rL   r   r   s     rO   	<genexpr>z"Thread.add_tags.<locals>.<genexpr>  s*      88CCKK888888rQ   rb   r   N)rE   extendr3   r   r   r0   r   )rN   r   r   rb   s       rO   add_tagszThread.add_tags  s      B @?D,>???884888888k++DG',BWBW`f+gggggggggggrQ   c                 K   d | j         D             }|D ]*}|                    t          |j                  d           +| j        j                            | j        t          |                                          |           d{V  dS )a  |coro|

        Remove the given forum tags to a thread.

        You must have :attr:`~Permissions.manage_threads` to
        use this or the thread must be owned by you.

        The parent channel must be a :class:`ForumChannel`.

        .. versionadded:: 2.1

        Parameters
        -----------
        \*tags: :class:`abc.Snowflake`
            An argument list of :class:`abc.Snowflake` representing a :class:`ForumTag`
            to remove to the thread.
        reason: Optional[:class:`str`]
            The reason for removing these tags.

        Raises
        -------
        Forbidden
            You do not have permissions to remove these tags.
        HTTPException
            Removing tags failed.
        c                .    i | ]}t          |          d S rL   r   r   s     rO   
<dictcomp>z&Thread.remove_tags.<locals>.<dictcomp>  s     1_1_1_S#c((D1_1_1_rQ   Nr   )	rE   poprV   r0   r3   r   r   r   keys)rN   r   r   rb   r   s        rO   remove_tagszThread.remove_tags  s      : 2`1_DL^1_1_1_ 	0 	0CS[[$////k++DG$|GXGXGZGZB[B[dj+kkkkkkkkkkkrQ   c                ^   K   | j         j                            | j                   d{V  dS )a  |coro|

        Joins this thread.

        You must have :attr:`~Permissions.send_messages_in_threads` to join a thread.
        If the thread is private, :attr:`~Permissions.manage_threads` is also needed.

        Raises
        -------
        Forbidden
            You do not have permissions to join the thread.
        HTTPException
            Joining the thread failed.
        N)r3   r   join_threadr0   rT   s    rO   joinzThread.join  s;       k**4733333333333rQ   c                ^   K   | j         j                            | j                   d{V  dS )z|coro|

        Leaves this thread.

        Raises
        -------
        HTTPException
            Leaving the thread failed.
        N)r3   r   leave_threadr0   rT   s    rO   leavezThread.leave  s;       k++DG44444444444rQ   userc               j   K   | j         j                            | j        |j                   d{V  dS )al  |coro|

        Adds a user to this thread.

        You must have :attr:`~Permissions.send_messages_in_threads` to add a user to a thread.
        If the thread is private and :attr:`invitable` is ``False`` then :attr:`~Permissions.manage_messages`
        is required to add a user to the thread.

        Parameters
        -----------
        user: :class:`abc.Snowflake`
            The user to add to the thread.

        Raises
        -------
        Forbidden
            You do not have permissions to add the user to the thread.
        HTTPException
            Adding the user to the thread failed.
        N)r3   r   add_user_to_threadr0   rN   r   s     rO   add_userzThread.add_user  s?      * k11$'47CCCCCCCCCCCrQ   c               j   K   | j         j                            | j        |j                   d{V  dS )a  |coro|

        Removes a user from this thread.

        You must have :attr:`~Permissions.manage_threads` or be the creator of the thread to remove a user.

        Parameters
        -----------
        user: :class:`abc.Snowflake`
            The user to remove from the thread.

        Raises
        -------
        Forbidden
            You do not have permissions to remove the user from the thread.
        HTTPException
            Removing the user from the thread failed.
        N)r3   r   remove_user_from_threadr0   r   s     rO   remove_userzThread.remove_user  s?      & k66twHHHHHHHHHHHrQ   user_idr   c               ~   K   | j         j                            | j        |           d{V }t	          | |          S )aq  |coro|

        Retrieves a :class:`ThreadMember` for the given user ID.

        Raises
        -------
        NotFound
            The specified user is not a member of this thread.
        HTTPException
            Retrieving the member failed.

        Returns
        --------
        :class:`ThreadMember`
            The thread member from the user ID.
        NrY   rG   )r3   r   get_thread_memberr0   r   )rN   r   rG   s      rO   fetch_memberzThread.fetch_member/  sI      $ [%77IIIIIIII4d3333rQ   c                x    K    j         j                             j                   d{V } fd|D             S )a  |coro|

        Retrieves all :class:`ThreadMember` that are in this thread.

        This requires :attr:`Intents.members` to get information about members
        other than yourself.

        Raises
        -------
        HTTPException
            Retrieving the members failed.

        Returns
        --------
        List[:class:`ThreadMember`]
            All thread members in the thread.
        Nc                2    g | ]}t          |           S )r   )r   )r   rG   rN   s     rO   r   z(Thread.fetch_members.<locals>.<listcomp>X  s&    IIIDt444IIIrQ   )r3   r   get_thread_membersr0   )rN   r   s   ` rO   fetch_memberszThread.fetch_membersD  sO      & (;;DGDDDDDDDDIIIIIIIIrQ   c               b   K   | j         j                            | j        |           d{V  dS )a  |coro|

        Deletes this thread.

        You must have :attr:`~Permissions.manage_threads` to delete threads.

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

            .. versionadded:: 2.4

        Raises
        -------
        Forbidden
            You do not have permissions to delete this thread.
        HTTPException
            Deleting the thread failed.
        r   N)r3   r   delete_channelr0   )rN   r   s     rO   deletezThread.deleteZ  s@      , k--dgf-EEEEEEEEEEErQ   r   r)   c               (    ddl m}  || |          S )a  Creates a :class:`PartialMessage` from the message ID.

        This is useful if you want to work with a message and only have its ID without
        doing an unnecessary API call.

        .. versionadded:: 2.0

        Parameters
        ------------
        message_id: :class:`int`
            The message ID to create a partial message for.

        Returns
        ---------
        :class:`PartialMessage`
            The partial message.
        r   )r)   )channelr0   )messager)   )rN   r   r)   s      rO   get_partial_messagezThread.get_partial_messager  s+    & 	,+++++~dz::::rQ   rd   c               $    || j         |j        <   d S rL   )r4   r0   )rN   rd   s     rO   _add_memberzThread._add_member  s    #)fi   rQ   	member_idOptional[ThreadMember]c               8    | j                             |d           S rL   )r4   r   )rN   r  s     rO   _pop_memberzThread._pop_member  s    }  D111rQ   )r1   r"   rF   r-   rG   rH   rI   rJ   )rI   r   rI   rV   )rG   rH   )rG   r   )rG   rH   rI   rJ   )rI   rp   )rI   rr   )rI   r   )rI   rw   )rI   r   )rI   r   )rI   r   )rI   r   )rI   r   )rI   r   )rI   r   )r   r   rI   r   )r   r   r   r   rI   rJ   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rI   r   )r/   rV   r=   r   r<   r   r>   r   r   r   r:   re   r@   r    rb   r   r   r   rI   r   )r   r*   r   r   rI   rJ   )rI   rJ   )r   r*   rI   rJ   )r   re   rI   r   )r   r   rI   rJ   )r   re   rI   r)   )rd   r   rI   rJ   )r  re   rI   r  ).__name__
__module____qualname____doc__	__slots__rP   rU   rZ   r\   rM   ri   ro   propertyr^   rY   r`   rz   r}   r   r   rb   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  rS   rQ   rO   r   r   A   s       F FPI4      
 
 
 
   1 1 1 10X X X X       X 6 6 6 X6 5 5 5 X5 4 4 4 X4    X I I I XI , , , X,    X" 1 1 1 X1 ` ` ` X`(    X& " " " X"&       X 8 8 8 85 5 5 57 7 7 7- - - -^ bf 1T 1T 1T 1T 1T 1Tl  #+2*.)-*.'+ $P
 P
 P
 P
 P
 P
j  !%7>+2 $TF TF TF TF TF TFl HL $h $h $h $h $h $hL KO "l "l "l "l "l "lH4 4 4 4"
5 
5 
5 
5D D D D.I I I I*4 4 4 4*J J J J, 7; F F F F F F0; ; ; ;.* * * *2 2 2 2 2 2rQ   r   c                  F    e Zd ZdZdZdd	ZddZddZedd            Z	dS )r   a  Represents a Discord thread member.

    .. container:: operations

        .. describe:: x == y

            Checks if two thread members are equal.

        .. describe:: x != y

            Checks if two thread members are not equal.

        .. describe:: hash(x)

            Returns the thread member's hash.

        .. describe:: str(x)

            Returns the thread member's name.

    .. versionadded:: 2.0

    Attributes
    -----------
    id: :class:`int`
        The thread member's ID.
    thread_id: :class:`int`
        The thread's ID.
    joined_at: :class:`datetime.datetime`
        The time the member joined the thread in UTC.
    )r0   	thread_id	joined_atr`   r3   rY   rY   r   rG   ThreadMemberPayloadrI   rJ   c                V    || _         |j        | _        |                     |           d S rL   )rY   r3   rM   )rN   rY   rG   s      rO   rP   zThreadMember.__init__  s*    $'-}rQ   rV   c                8    d| j          d| j         d| j        dS )Nz<ThreadMember id=z thread_id=z joined_at=rX   )r0   r  r  rT   s    rO   rZ   zThreadMember.__repr__  s+    e47eet~eeRVR`eeeerQ   c                P   |  	 t          |d                   | _        n!# t          $ r | j        j        | _        Y nw xY w|  	 t          |d                   | _        n!# t          $ r | j        j        | _        Y nw xY wt          |d                   | _        |d         | _	        d S )Nr   r0   join_timestampr`   )
re   r0   rj   r3   self_idr  rY   r   r  r`   rm   s     rO   rM   zThreadMember._from_data  s    	*$y/**DGG 	* 	* 	*k)DGGG	* 		, d__DNN 	, 	, 	,![^DNNN	, $.d3C.D#E#Ew-


s    ==A A<;A<c                    | j         S )z3:class:`Thread`: The thread this member belongs to.)rY   rT   s    rO   threadzThreadMember.thread  s     {rQ   N)rY   r   rG   r  rI   rJ   r  )rG   r  rI   rJ   )rI   r   )
r  r  r  r  r  rP   rZ   rM   r  r$  rS   rQ   rO   r   r     s         @I   
f f f f( ( ( (     X  rQ   r   )Er  
__future__r   typingr   r   r   r   r   r	   r
   r   r   r   rg   mixinsr   abcr   r   r   enumsr   r   errorsr   r`   r   permissionsr   utilsr   r   r   r   __all__typing_extensionsr   types.threadsr   rH   r   r  r   r    types.snowflaker!   r1   r"   r
  r#   r$   r%   r&   rd   r'   r  r(   r)   r*   r+   roler,   rF   r-   r   public_threadr   rp   rS   rQ   rO   <module>r3     s   0 # " " " " " d d d d d d d d d d d d d d d d d d d d d d              9 9 9 9 9 9 9 9 9 9 ( ( ( ( ( ( ( ( # # # # # #       $ $ $ $ $ $ B B B B B B B B B B B B
  p&&&&&&            /.....MMMMMMMMMMMM00000000--------&&&&&& 79RT_Tn noL2 L2 L2 L2 L2[( L2 L2 L2^E E E E E8 E E E E ErQ   