
    cjhѡ                       d Z ddlmZ ddlZddlZddlZddlZddlZddl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 dd	l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dl!m"Z" ddl#m$Z$m%Z%m&Z& dZ' ejP                  e)      Z*e
r'ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z5 	 ddl6m7Z7m8Z8 ejt                  Z: G d d      Z; G d d      Z< G d dejz                        Z> e>       Z?d"dZ@ G d de      ZA G d  d!e$      ZBy# e9$ r Y ^w xY w)#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Literaloverload)quote   )utils)PartialMessageable)DiscordServerError	ForbiddenHTTPExceptionInvalidArgumentNotFound)Route)Message)Object)Thread   )BaseWebhook_WebhookStatehandle_message_parameters)SyncWebhookSyncWebhookMessage)	Snowflake)Embed)File)AllowedMentions)Webhook)ResponseSessionc                  (    e Zd ZddZd ZddZd Zy)DeferredLockc                     || _         d | _        y N)lockdelta)selfr&   s     G/var/www/html/venv/lib/python3.12/site-packages/discord/webhook/sync.py__init__zDeferredLock.__init__Q   s    	#'
    c                :    | j                   j                          | S r%   )r&   acquirer(   s    r)   	__enter__zDeferredLock.__enter__U   s    		r+   c                    || _         y r%   )r'   )r(   r'   s     r)   delay_byzDeferredLock.delay_byY   s	    
r+   c                    | j                   rt        j                  | j                          | j                  j	                          y r%   )r'   timesleepr&   release)r(   typevalue	tracebacks       r)   __exit__zDeferredLock.__exit__\   s)    ::JJtzz"		r+   N)r&   zthreading.Lock)r'   floatreturnNone)__name__
__module____qualname__r*   r/   r1   r9    r+   r)   r#   r#   P   s    (r+   r#   c                     e Zd Zd Zddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 	 	 dd	Zdd	 	 	 	 	 	 	 	 	 dd
Zddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	dd	 	 	 	 	 	 	 	 	 ddZ
ddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdd	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZ	 	 	 	 	 	 ddZy)WebhookAdapterc                6    t        j                         | _        y r%   )weakrefWeakValueDictionary_locksr.   s    r)   r*   zWebhookAdapter.__init__c   s    3:3N3N3Pr+   N)payload	multipartfilesreason
auth_tokenparamsc          
        i }	|xs g }d }
|j                   |j                  f}	 | j                  |   }|d|	d<   t        j                  |      }
|d| |	d<   |t        |d      |	d<   d }d }d }|j                  }|j                  }|j                   }t        |      5 }t        d      D ]X  }|D ]  }|j                  |	        |r,i }|D ]%  }|d
   }|dk(  rd|d   i}
|d   |d   |d   f||<   ' 	 |j                  |||
||	|      5 }t        j!                  d||||j"                         d|_        |j"                  |_        |j(                  xs d }|r'|j*                  d   dk(  rt-        j.                  |      }|j*                  j1                  d      }|dk(  rL|j"                  dk7  r=t        j2                  |      }t        j!                  d||       |j5                  |       d|j"                  cxkD  rdk\  rn n|cd d d        c cd d d        S |j"                  dk(  rc|j*                  j1                  d      st7        ||      |d   }t        j9                  d||       t;        j<                  |       	 d d d        |j"                  dk\  r&t;        j<                  d|dz  z          	 d d d        |j"                  dk(  rt?        ||      |j"                  dk(  rtA        ||      t7        ||       |r'|j"                  dk\  rtG        ||      t7        ||      tI        d"      # t        $ r' t	        j
                         x| j                  |<   }Y 8w xY w# 1 sw Y   nxY w# tB        $ r:}|d k  r/|jD                  d!v r!t;        j<                  d|dz  z          Y d }~ d }~ww xY w# 1 sw Y   y xY w)#Nzapplication/jsonzContent-TypezBot Authorizationz/ )safezX-Audit-Log-Reason   )seeknamepayload_jsonr7   filenamecontent_type)datarI   headersrL   z4Webhook ID %s with %s %s has returned status code %szutf-8zX-Ratelimit-Remaining0i  zGWebhook ID %s has been pre-emptively rate limited, waiting %.2f secondsi,     Viaretry_afterz7Webhook ID %s is rate limited. Retrying in %.2f secondsi  r   r	   i  i     )6   iF'  z"Unreachable code in HTTP handling.)%
webhook_idwebhook_tokenrF   KeyError	threadingLockr
   _to_jsonurlquotemethodurlr#   rangeresetrequest_logdebugstatus_codeencodingstatustextrW   jsonloadsget_parse_ratelimit_headerr1   r   warningr3   r4   r   r   OSErrorerrnor   RuntimeError)r(   routesessionrG   rH   rI   rJ   rK   rL   rW   to_sendbucketr&   responserV   	file_datare   rf   r^   attemptfileprR   	remainingr'   r[   es                              r)   ri   zWebhookAdapter.requestf   sN    #%/3""E$7$78	:;;v&D &8GN#nnW-G!)-j\':GO$,4V$,GG()$(,0+/	ii%%
$ c	E4 8 [! -DJJGJ,-  "I& 	 y>1'5qz&BG !"* !'
 !. 1/IdO	J $' '% )  C@ "

R&"$00 -4)*2*>*>'}}4  ( 0 0 @DV V#'::d#3D$,$4$4$8$89P$Q	$+0D0D0K$)$A$A($KE JJ%< !+ % !MM%0!5!5<<#'QC@ C@'c	E c	Ez $//36#+#3#3#7#7#>&3Hd&C C15m1DK LL%/ !+ + !JJ{3$qC@ C@t $//36 JJq7Q;7$yC@ C@| $//36"+Hd";;%11S8"*8T"::"/$"??k[z ''3.,Xt<<#Hd33CDDo  	:)2)99DKK$	:NC@ C@ C@J  {qww+'=

1w{?3 	qc	E c	Es   L<  AO8M=C:M/		M=OA(M/M=O+M/;M=OAM/5O<,M,+M,/M84M=;O=	O .N;4O:N;;O  OO)tokenrJ   c               H    t        dd|      }| j                  ||||      S )NDELETE/webhooks/{webhook_id}r^   )rJ   rK   r   ri   r(   r^   r   ry   rJ   rx   s         r)   delete_webhookzWebhookAdapter.delete_webhook   s*     h 8ZP||E76e|LLr+   rJ   c               H    t        dd||      }| j                  |||      S )Nr   &/webhooks/{webhook_id}/{webhook_token}r^   r_   r   r   r   s         r)   delete_webhook_with_tokenz(WebhookAdapter.delete_webhook_with_token   s1     4!	
 ||E76|::r+   c               J    t        dd|      }| j                  |||||      S )NPATCHr   r   )rJ   rG   rK   r   r(   r^   r   rG   ry   rJ   rx   s          r)   edit_webhookzWebhookAdapter.edit_webhook  s4     g7JO||767u  
 	
r+   c               J    t        dd||      }| j                  ||||      S )Nr   r   r   )rJ   rG   r   r   s          r)   edit_webhook_with_tokenz&WebhookAdapter.edit_webhook_with_token  s3     4!	
 ||E767|KKr+   F)rG   rH   rI   	thread_idthread_namewaitc                   dt        |	      i}
|r||
d<   |r||d<   t        dd||      }| j                  ||||||
      S )Nr   r   r   POSTr   r   )rG   rH   rI   rL   )intr   ri   )r(   r^   r   ry   rG   rH   rI   r   r   r   rL   rx   s               r)   execute_webhookzWebhookAdapter.execute_webhook,  sl     #d)$"+F;%0GM"4!	
 ||  
 	
r+   r   c               \    i }|r||d<   t        dd|||      }| j                  |||      S )Nr   GET</webhooks/{webhook_id}/{webhook_token}/messages/{message_id}r^   r_   
message_idrL   r   r(   r^   r   r   ry   r   rL   rx   s           r)   get_webhook_messagez"WebhookAdapter.get_webhook_messageO  sF     "+F;J!!
 ||E76|::r+   )r   rG   rH   rI   c               b    i }	|r||	d<   t        dd|||      }
| j                  |
||	|||      S )Nr   r   r   r   )rL   rG   rH   rI   r   )r(   r^   r   r   ry   r   rG   rH   rI   rL   rx   s              r)   edit_webhook_messagez#WebhookAdapter.edit_webhook_messagef  sY     "+F;J!!
 ||  
 	
r+   c               \    i }|r||d<   t        dd|||      }| j                  |||      S )Nr   r   r   r   r   r   r   s           r)   delete_webhook_messagez%WebhookAdapter.delete_webhook_message  sF     "+F;J!!
 ||E76|::r+   c               F    t        dd|      }| j                  |||      S )Nr   r   r   )ry   rK   r   r(   r^   r   ry   rx   s        r)   fetch_webhookzWebhookAdapter.fetch_webhook  s(     e5*M||E7u|EEr+   c               F    t        dd||      }| j                  ||      S )Nr   r   r   ry   r   r   s        r)   fetch_webhook_with_tokenz'WebhookAdapter.fetch_webhook_with_token  s/     4!	
 ||E7|33r+   )rx   r   ry   r!   rG   dict[str, Any] | NonerH   list[dict[str, Any]] | NonerI   list[File] | NonerJ   
str | NonerK   r   rL   r   r;   r   )r^   r   r   r   ry   r!   rJ   r   )r^   r   r   strry   r!   rJ   r   )
r^   r   r   r   rG   zdict[str, Any]ry   r!   rJ   r   )r^   r   r   r   ry   r!   rG   r   rH   r   rI   r   r   
int | Noner   r   r   bool)
r^   r   r   r   r   r   ry   r!   r   r   )r^   r   r   r   r   r   ry   r!   r   r   rG   r   rH   r   rI   r   )r^   r   r   r   ry   r!   )r=   r>   r?   r*   ri   r   r   r   r   r   r   r   r   r   r   r@   r+   r)   rB   rB   b   s   Q *.15#'!!%(,JEJE JE
 'JE /JE !JE JE JE &JE 
JE` !!	M	M 		M
 	M 	M" ";; ;
 ; ;. "

 
  	
 
 
* "LL L  	L L L. *.15#' $"&!
!
 !

 !
 '!
 /!
 !!
 !
  !
 !
T !%;; ; 	; ; ;< !%)-15#'

 
 	
 
 
 '
 /
 !
P !%;; ; 	; ; ;.FF F
 F44 4
 4r+   rB   c                      e Zd ZU dZded<   y)_WebhookContextNzWebhookAdapter | Noneadapter)r=   r>   r?   r   __annotations__r@   r+   r)   r   r     s    %)G")r+   r   c                 h    t         j                  t               t         _        t         j                  S r%   )_contextr   rB   r@   r+   r)   _get_webhook_adapterr     s%    )+r+   c                  `    e Zd ZU dZded<   eeeeedef	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddd	dZy)
r   a  Represents a message sent from your webhook.

    This allows you to edit or delete a message sent by your
    webhook.

    This inherits from :class:`discord.Message` with changes to
    :meth:`edit` and :meth:`delete` to work.

    .. versionadded:: 2.0
    r   _stateNc                p   t         }t        | d      rt        | j                        }n9t	        | j
                  t              rt        | j
                  j                        }|t         u r| j                  j                  }| j                  j                  j                  | j                  ||||||||	      S )a  Edits the message.

        Parameters
        ----------
        content: Optional[:class:`str`]
            The content to edit the message with or ``None`` to clear it.
        embeds: List[:class:`Embed`]
            A list of embeds to edit the message with.
        embed: Optional[:class:`Embed`]
            The embed to edit the message with. ``None`` suppresses the embeds.
            This should not be mixed with the ``embeds`` parameter.
        file: :class:`File`
            The file to upload. This cannot be mixed with ``files`` parameter.
        files: List[:class:`File`]
            A list of files to send with the content. This cannot be mixed with the
            ``file`` parameter.
        allowed_mentions: :class:`AllowedMentions`
            Controls the mentions being processed in this message.
            See :meth:`.abc.Messageable.send` for more information.
        suppress: Optional[:class:`bool`]
            Whether to suppress embeds for the message.

        Returns
        -------
        :class:`SyncWebhookMessage`
            The newly edited message.

        Raises
        ------
        HTTPException
            Editing the message failed.
        Forbidden
            Edited a message that is not yours.
        TypeError
            You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
        ValueError
            The length of ``embeds`` was invalid
        InvalidArgument
            There was no token associated with this webhook.
        
_thread_idcontentembedsembedr   rI   allowed_mentionsthreadsuppress)MISSINGhasattrr   r   
isinstancechannelr   idflagssuppress_embedsr   _webhookedit_message)	r(   r   r   r   r   rI   r   r   r   s	            r)   editzSyncWebhookMessage.edit  s    d 4&DOO,Ff-DLLOO,Fwzz11H{{##00GG- 1 

 
	
r+   )delayc               *   d}t        | d      r| j                  }n0t        | j                  t              r| j                  j
                  }|t        j                  |       | j                  j                  j                  | j
                  |       y)a  Deletes the message.

        Parameters
        ----------
        delay: Optional[:class:`float`]
            If provided, the number of seconds to wait before deleting the message.
            This blocks the thread.

        Raises
        ------
        Forbidden
            You do not have proper permissions to delete the message.
        NotFound
            The message was deleted already.
        HTTPException
            Deleting the message failed.
        Nr   r   )r   r   r   r   r   r   r3   r4   r   r   delete_message)r(   r   r   s      r)   deletezSyncWebhookMessage.delete  sj    & !%	4&If-IJJu++DGGy+Ir+   )r   r   r   list[Embed]r   Embed | Noner   r   rI   
list[File]r   AllowedMentions | Noner   zbool | Noner;   r   )r   zfloat | Noner;   r<   )r=   r>   r?   __doc__r   r   r   r   r@   r+   r)   r   r     s    	  &%%#37 'E
E
 E
 	E

 E
 E
 1E
 E
 
E
N /3 Jr+   r   c                      e Zd ZU dZdZded<   	 	 d 	 	 	 	 	 d! fdZd Zed"d       Z	e
edd		 	 	 	 	 	 	 	 	 d#d
       Ze
edd		 	 	 	 	 	 	 d$d       Zddd%dZdddd&dZdeeddd	 	 	 	 	 	 	 	 	 	 	 d'dZd Zeefeeeeeeeeedd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(d       Zeefeeeeeeeeedded	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)d       Zefeedeeeeeedddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d*dZdd	 	 	 	 	 d+dZeeeeededd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,dZddd-dZ xZS ).r   ae  Represents a synchronous Discord webhook.

    For an asynchronous counterpart, see :class:`Webhook`.

    .. container:: operations

        .. describe:: x == y

            Checks if two webhooks are equal.

        .. describe:: x != y

            Checks if two webhooks are not equal.

        .. describe:: hash(x)

            Returns the webhook's hash.

    .. versionchanged:: 1.4
        Webhooks are now comparable and hashable.

    Attributes
    ----------
    id: :class:`int`
        The webhook's ID
    type: :class:`WebhookType`
        The type of the webhook.

        .. versionadded:: 1.3

    token: Optional[:class:`str`]
        The authentication token of the webhook. If this is ``None``
        then the webhook cannot be used to make requests.
    guild_id: Optional[:class:`int`]
        The guild ID this webhook is for.
    channel_id: Optional[:class:`int`]
        The channel ID this webhook is for.
    user: Optional[:class:`abc.User`]
        The user this webhook was created by. If the webhook was
        received without authentication then this will be ``None``.
    name: Optional[:class:`str`]
        The default name of the webhook.
    source_guild: Optional[:class:`PartialWebhookGuild`]
        The guild of the channel that this webhook is following.
        Only given if :attr:`type` is :attr:`WebhookType.channel_follower`.

        .. versionadded:: 2.0

    source_channel: Optional[:class:`PartialWebhookChannel`]
        The channel that this webhook is following.
        Only given if :attr:`type` is :attr:`WebhookType.channel_follower`.

        .. versionadded:: 2.0
    r   ztuple[str, ...]	__slots__Nc                6    t         |   |||       || _        y r%   )superr*   ry   )r(   rV   ry   r   state	__class__s        r)   r*   zSyncWebhook.__init__s  s     	ue,r+   c                "    d| j                   dS )Nz<Webhook id=>)r   r.   s    r)   __repr__zSyncWebhook.__repr__}  s    dgg[**r+   c                :    d| j                    d| j                   S )zReturns the webhook's url.z!https://discord.com/api/webhooks//)r   r   r.   s    r)   rf   zSyncWebhook.url  s     3477)1TZZLIIr+   )ry   	bot_tokenc                   |d|d}ddl }|t        u r|}n.t        ||j                        st	        d|j
                         | |||      S )aA  Creates a partial :class:`Webhook`.

        Parameters
        ----------
        id: :class:`int`
            The ID of the webhook.
        token: :class:`str`
            The authentication token of the webhook.
        session: :class:`requests.Session`
            The session to use to send requests with. Note
            that the library does not manage the session and
            will not close it. If not given, the ``requests``
            auto session creation functions are used instead.
        bot_token: Optional[:class:`str`]
            The bot authentication token for authenticated requests
            involving the webhook.

        Returns
        -------
        :class:`Webhook`
            A partial :class:`Webhook`.
            A partial webhook is just a webhook object with an ID and a token.
        r   )r   r6   r   r   Nexpected requests.Session not r   )requestsr   r   r!   	TypeErrorr   )clsr   r   ry   r   rV   r   s          r)   partialzSyncWebhook.partial  s`    B  

 	gGGX%5%56<W=N=N<QRSS4	22r+   c                  t        j                  d|      }|t        d      |j                         }d|d<   ddl}|t
        u r|}n.t        ||j                        st        d|j                         | |||      S )	a\  Creates a partial :class:`Webhook` from a webhook URL.

        Parameters
        ----------
        url: :class:`str`
            The URL of the webhook.
        session: :class:`requests.Session`
            The session to use to send requests with. Note
            that the library does not manage the session and
            will not close it. If not given, the ``requests``
            auto session creation functions are used instead.
        bot_token: Optional[:class:`str`]
            The bot authentication token for authenticated requests
            involving the webhook.

        Returns
        -------
        :class:`Webhook`
            A partial :class:`Webhook`.
            A partial webhook is just a webhook object with an ID and a token.

        Raises
        ------
        InvalidArgument
            The URL is invalid.
        zNdiscord(?:app)?.com/api/webhooks/(?P<id>\d{17,20})/(?P<token>[\w\.\-_]{60,68})NzInvalid webhook URL given.r   r6   r   r   r   )
researchr   	groupdictr   r   r   r!   r   r   )r   rf   ry   r   mrV   r   s          r)   from_urlzSyncWebhook.from_url  s    < II]
 9!">?? {{}VgGGX%5%56<W=N=N<QRSS4	22r+   T)prefer_authc                  t               }|r?| j                  r3|j                  | j                  | j                  | j                        }nJ| j
                  r3|j                  | j                  | j
                  | j                        }nt        d      t        || j                  | j                  | j                        S )a\  Fetches the current webhook.

        This could be used to get a full webhook from a partial webhook.

        .. note::

            When fetching with an unauthenticated webhook, i.e.
            :meth:`is_authenticated` returns ``False``, then the
            returned webhook does not contain any user information.

        Parameters
        ----------
        prefer_auth: :class:`bool`
            Whether to use the bot token over the webhook token
            if available. Defaults to ``True``.

        Returns
        -------
        :class:`SyncWebhook`
            The fetched webhook.

        Raises
        ------
        HTTPException
            Could not fetch the webhook
        NotFound
            Could not find the webhook by this ID
        InvalidArgument
            This webhook does not have a token associated with it.
        r   5This webhook does not have a token associated with it)r   r   )
r   rK   r   r   ry   r   r   r   r   r   )r(   r   r   rV   s       r)   fetchzSyncWebhook.fetch  s    > #7"84??(($//4<<(XDZZ33T\\ 4 D "G  4T__DKKXXr+   )rJ   r   c               b   | j                   | j                  t        d      t               }|r@| j                  r4|j	                  | j
                  | j                  | j                  |       y| j                   r4|j                  | j
                  | j                   | j                  |       yy)a  Deletes this Webhook.

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

            .. versionadded:: 1.4
        prefer_auth: :class:`bool`
            Whether to use the bot token over the webhook token
            if available. Defaults to ``True``.

        Raises
        ------
        HTTPException
            Deleting the webhook failed.
        NotFound
            This webhook does not exist.
        Forbidden
            You do not have permissions to delete this webhook.
        InvalidArgument
            This webhook does not have a token associated with it.
        Nr   )r   ry   rJ   )ry   rJ   )r   rK   r   r   r   r   ry   r   )r(   rJ   r   r   s       r)   r   zSyncWebhook.delete  s    0 ::$//"9!G  #7"84??""tV #  ZZ--T\\& .  r+   )rJ   rR   avatarr   r   c                  | j                   | j                  t        d      i }|t        ur|t	        |      nd|d<   |t        ur|t        j                  |      nd|d<   t               }d}|Z| j                  t        d      |j                  |d<   |j                  | j                  | j                  || j                  |      }|rA| j                  r5|j                  | j                  | j                  || j                  |      }n@| j                   r4|j                  | j                  | j                   || j                  |      }|t        d      t        || j                  | j                  | j                  	      S )
aY  Edits this Webhook.

        Parameters
        ----------
        name: Optional[:class:`str`]
            The webhook's new default name.
        avatar: Optional[:class:`bytes`]
            A :term:`py:bytes-like object` representing the webhook's new default avatar.
        channel: Optional[:class:`abc.Snowflake`]
            The webhook's new channel. This requires an authenticated webhook.
        reason: Optional[:class:`str`]
            The reason for editing this webhook. Shows up on the audit log.

            .. versionadded:: 1.4
        prefer_auth: :class:`bool`
            Whether to use the bot token over the webhook token
            if available. Defaults to ``True``.

        Returns
        -------
        :class:`SyncWebhook`
            The newly edited webhook.

        Raises
        ------
        HTTPException
            Editing the webhook failed.
        NotFound
            This webhook does not exist.
        InvalidArgument
            This webhook does not have a token associated with it, or
            it tried editing a channel without authentication.
        Nr   rR   r   z.Editing channel requires authenticated webhook
channel_id)rG   ry   rJ   z+Unreachable code hit: data was not assigned)rV   ry   r   r   )r   rK   r   r   r   r
   _bytes_to_base64_datar   r   r   ry   r   rw   r   r   )	r(   rJ   rR   r   r   r   rG   r   rV   s	            r)   r   zSyncWebhook.edit7  s   T ::$//"9!G  w+/+;c$iGFO 7=7I++F3t H #7"8&*&%&VWW$+JJGL!'' ( D 4??'' ( D ZZ22

 3 D <LMMt||4??$++
 	
r+   c                    t        | | j                        }| j                  xs# t        | j                  t	        |d               }t        |||      S )N)parentr   )r   r   )rV   r   r   )r   r   r   r   r   r   )r(   rV   r   r   s       r)   _create_messagezSyncWebhook._create_message  sF    d4;;7,,c"44;;3tT`OaKb"c!t5'JJr+   )
username
avatar_urlttsr   rI   r   r   r   r   r   c                    y r%   r@   )r(   r   r  r  r  r   rI   r   r   r   r   r   r   s                r)   sendzSyncWebhook.send  s      !r+   .)r  r  r  r   rI   r   r   r   r   r   r   r   c                    y r%   r@   )r(   r   r  r  r  r   rI   r   r   r   r   r   r   r   s                 r)   r  zSyncWebhook.send  s    " r+   Fc                  | j                   t        d      t        | j                  dd      }|t        }|
r|rt        d      t        |||||||||	||      }t               }d}|
t        ur|
j                  }|j                  | j                  | j                   | j                  |j                  |j                  |j                  |||	      }|r| j                  |      S y)a  Sends a message using the webhook.

        The content must be a type that can convert to a string through ``str(content)``.

        To upload a single file, the ``file`` parameter should be used with a
        single :class:`File` object.

        If the ``embed`` parameter is provided, it must be of type :class:`Embed` and
        it must be a rich embed type. You cannot mix the ``embed`` parameter with the
        ``embeds`` parameter, which must be a :class:`list` of :class:`Embed` objects to send.

        Parameters
        ----------
        content: :class:`str`
            The content of the message to send.
        wait: :class:`bool`
            Whether the server should wait before sending a response. This essentially
            means that the return type of this function changes from ``None`` to
            a :class:`WebhookMessage` if set to ``True``.
        username: :class:`str`
            The username to send with this message. If no username is provided
            then the default username for the webhook is used.
        avatar_url: :class:`str`
            The avatar URL to send with this message. If no avatar URL is provided
            then the default avatar for the webhook is used. If this is not a
            string then it is explicitly cast using ``str``.
        tts: :class:`bool`
            Indicates if the message should be sent using text-to-speech.
        file: :class:`File`
            The file to upload. This cannot be mixed with ``files`` parameter.
        files: List[:class:`File`]
            A list of files to send with the content. This cannot be mixed with the
            ``file`` parameter.
        embed: :class:`Embed`
            The rich embed for the content to send. This cannot be mixed with
            ``embeds`` parameter.
        embeds: List[:class:`Embed`]
            A list of embeds to send with the content. Maximum of 10. This cannot
            be mixed with the ``embed`` parameter.
        allowed_mentions: :class:`AllowedMentions`
            Controls the mentions being processed in this message.

            .. versionadded:: 1.4
        thread: :class:`~discord.abc.Snowflake`
            The thread to send this message to.

            .. versionadded:: 2.0
        thread_name: :class:`str`
            The name of the thread to create. Only works for forum channels.

            .. versionadded:: 2.0
        suppress: :class:`bool`
            Whether to suppress embeds for the message.

        Returns
        -------
        Optional[:class:`SyncWebhookMessage`]
            If ``wait`` is ``True`` then the message that was sent, otherwise ``None``.

        Raises
        ------
        HTTPException
            Sending the message failed.
        NotFound
            This webhook was not found.
        Forbidden
            The authorization token for the webhook is incorrect.
        TypeError
            You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
        ValueError
            The length of ``embeds`` was invalid
        InvalidArgument
            There was no token associated with this webhook, or you specified both
            a thread to send to and a thread to create (the ``thread`` and ``thread_name`` parameters).
        Nr   r   z2You cannot specify both a thread and a thread name)r   r  r  r  r   rI   r   r   r   previous_allowed_mentionsr   )ry   rG   rH   rI   r   r   r   )r   r   getattrr   r   r   r   r   r   ry   rG   rH   rI   r   )r(   r   r  r  r  r   rI   r   r   r   r   r   r   r   previous_mentionsrL   r   r   rV   s                      r)   r  zSyncWebhook.send  s   z ::!G  5<KK+T5
 ?Gk!"VWW*!-&7
 #7"8 $	 		I&&GGJJLLNN&&,,# ' 

 ''-- r+   r   c                  | j                   t        d      t               }|j                  | j                  | j                   || j
                  |      }| j                  |      }|r!t        |j                  t              r||_
        |S )a   Retrieves a single :class:`~discord.SyncWebhookMessage` owned by this webhook.

        .. versionadded:: 2.0

        Parameters
        ----------
        id: :class:`int`
            The message ID to look for.
        thread_id: Optional[:class:`int`]
            The ID of the thread that contains the message.

        Returns
        -------
        :class:`~discord.SyncWebhookMessage`
            The message asked for.

        Raises
        ------
        ~discord.NotFound
            The specified message was not found.
        ~discord.Forbidden
            You do not have the permissions required to get a message.
        ~discord.HTTPException
            Retrieving the message failed.
        InvalidArgument
            There was no token associated with this webhook.
        r   ry   r   )r   r   r   r   r   ry   r   r   r   r   r   )r(   r   r   r   rV   msgs         r)   fetch_messagezSyncWebhook.fetch_messageO  s    > ::!G  #7"8**GGJJLL + 
 ""4(CKK1CD&CN
r+   r   c          
        | j                   t        d      t        | j                  dd      }
t	        |||||||
|	      }t               }d}|t        ur|j                  }|j                  | j                  | j                   || j                  ||j                  |j                  |j                        }| j                  |      S )au  Edits a message owned by this webhook.

        This is a lower level interface to :meth:`WebhookMessage.edit` in case
        you only have an ID.

        .. versionadded:: 1.6

        Parameters
        ----------
        message_id: :class:`int`
            The message ID to edit.
        content: Optional[:class:`str`]
            The content to edit the message with or ``None`` to clear it.
        embeds: List[:class:`Embed`]
            A list of embeds to edit the message with.
        embed: Optional[:class:`Embed`]
            The embed to edit the message with. ``None`` suppresses the embeds.
            This should not be mixed with the ``embeds`` parameter.
        file: :class:`File`
            The file to upload. This cannot be mixed with ``files`` parameter.
        files: List[:class:`File`]
            A list of files to send with the content. This cannot be mixed with the
            ``file`` parameter.
        allowed_mentions: :class:`AllowedMentions`
            Controls the mentions being processed in this message.
            See :meth:`.abc.Messageable.send` for more information.
        thread: Optional[:class:`~discord.abc.Snowflake`]
            The thread that contains the message.

        Raises
        ------
        HTTPException
            Editing the message failed.
        Forbidden
            Edited a message that is not yours.
        TypeError
            You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
        ValueError
            The length of ``embeds`` was invalid
        InvalidArgument
            There was no token associated with this webhook.
        Nr   r   )r   r   rI   r   r   r   r  r   )ry   r   rG   rH   rI   )r   r   r	  r   r   r   r   r   r   ry   rG   rH   rI   r   )r(   r   r   r   r   r   rI   r   r   r   r
  rL   r   r   rV   s                  r)   r   zSyncWebhook.edit_message  s    p ::!G  5<KK+T5
 +-&7	
 #7"8 $	 		I++GGJJLLNN&&,, , 	
 ##D))r+   c                   | j                   t        d      t               }|j                  | j                  | j                   || j
                  |       y)a4  Deletes a message owned by this webhook.

        This is a lower level interface to :meth:`WebhookMessage.delete` in case
        you only have an ID.

        .. versionadded:: 1.6

        Parameters
        ----------
        message_id: :class:`int`
            The message ID to delete.
        thread_id: Optional[:class:`int`]
            The ID of the thread that contains the message.

        Raises
        ------
        HTTPException
            Deleting the message failed.
        Forbidden
            Deleted a message that is not yours.
        Nr   r  )r   r   r   r   r   ry   )r(   r   r   r   s       r)   r   zSyncWebhook.delete_message  sV    , ::!G  #7"8&&GGJJLL 	' 	
r+   )NN)rV   WebhookPayloadry   r!   r   r   )r;   r   )
r   r   r   r   ry   r!   r   r   r;   r   )rf   r   ry   r!   r   r   r;   r   )r   r   r;   r   )rJ   r   r   r   r;   r<   )rJ   r   rR   r   r   zbytes | Noner   Snowflake | Noner   r   r;   r   )r   r   r  r   r  r   r  r   r   r   rI   r   r   r   r   r   r   r   r   r   r   r   r   zLiteral[True]r;   r   )r   r   r  r   r  r   r  r   r   r   rI   r   r   r   r   r   r   r   r   r   r   r   r   zLiteral[False]r   r   r;   r<   )r   r   r  r   r  r   r  r   r   r   rI   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r;   zSyncWebhookMessage | None)r   r   r   r   r;   r   )r   r   r   r   r   r   r   r   r   r   rI   r   r   r   r   r  r   r   r;   r   )r   r   r   r   r;   r<   )r=   r>   r?   r   r   r   r*   r   propertyrf   classmethodr   r   r   r   r   r   r   r   r  r  r   r   __classcell__)r   s   @r)   r   r   9  sv   5n ".I- !  	+ J J  # $*3*3 *3
 *3 *3 
*3 *3X -4d,3,3#*,3AK,3	,3 ,3\ ,0 ,Y\ .2t &V ""&$( _
 _
 	_

 _
 "_
 _
 
_
BK  !  !#%,3#"&!! 	!
 ! ! ! ! ! ! *! !  ! ! 
! !"    !#%,3#"&"  	
       *       
! ( I.  !#%,3#"&I.I. 	I.
 I. I. I. I. I. I. *I. I.  I. I. I.  
#!I.X 3700%/0	0l &%%#37#*Z*Z* 	Z*
 Z* Z* Z* Z* 1Z* !Z* Z* 
Z*x JN "
 "
r+   r   )r;   rB   )Cr   
__future__r   rp   loggingr   ra   r3   rD   typingr   r   r   r   urllib.parser   rd    r
   r   r   errorsr   r   r   r   r   httpr   messager   objectr   threadsr   async_r   r   r   __all__	getLoggerr=   rj   abcr   r   r   r   r   mentionsr   types.webhookr   r  r   r    r!   ModuleNotFoundErrorr   r#   rB   localr   r   r   r   r   r@   r+   r)   <module>r(     s   > #   	    8 8 *  (      I I
 w"*9. -- $S4 S4l
*ioo * qJ qJhF
+ F
_  s   $D D
D