
    cjht                   ~   U 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m	Z	 ddl
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 dd
lmZmZ ddlmZ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)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 dZ4 ejj                  e6      Z7erRddl8Z8ddl9m:Z: ddlm;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA ddl&mBZB ddlCmDZD ddlEmFZF ddlGmHZH ddlIm*ZJ ddlKmLZM dd lKmNZO dd!lPmQZQ ej                  ZR G d" d#      ZS G d$ d%      ZT G d& d'e      ZUeRfeReRd(d(eReReReReReReReReRdd(d)	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d=d*ZV e	d+ eT       ,      ZWd-eXd.<    G d/ d0e,      ZY G d1 d2e,      ZZ G d3 d4      Z[ G d5 d6      Z\ G d7 d8e*      Z] G d9 d:e,      Z^ G d; d<e^      ZNy)>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)
ContextVar)TYPE_CHECKINGAnyLiteral
NamedTupleoverload)quote   )utils)Asset)ForumChannelPartialMessageable)WebhookTypetry_enum)DiscordServerError	ForbiddenHTTPExceptionInvalidArgumentNotFound)MessageFlags)Route)
AttachmentMessage)Hashable)Object)Thread)BaseUserUser)WebhookWebhookMessagePartialWebhookChannelPartialWebhookGuild)	Snowflake)TextChannel)Embed)File)Guild)Response)AllowedMentions)Poll)ConnectionState)r   )FollowerWebhook)r    )Viewc                  (    e Zd ZddZd ZddZd Zy)AsyncDeferredLockc                     || _         d | _        y N)lockdelta)selfr3   s     I/var/www/html/venv/lib/python3.12/site-packages/discord/webhook/async_.py__init__zAsyncDeferredLock.__init__X   s    	#'
    c                V   K   | j                   j                          d {    | S 7 wr2   )r3   acquirer5   s    r6   
__aenter__zAsyncDeferredLock.__aenter__\   s&     ii!!! 	"s   )')c                    || _         y r2   )r4   )r5   r4   s     r6   delay_byzAsyncDeferredLock.delay_by`   s	    
r8   c                   K   | j                   r't        j                  | j                          d {    | j                  j	                          y 7 wr2   )r4   asynciosleepr3   release)r5   typevalue	tracebacks       r6   	__aexit__zAsyncDeferredLock.__aexit__c   s8     ::--

+++		 ,s   /AA AN)r3   zasyncio.Lock)r4   floatreturnNone)__name__
__module____qualname__r7   r<   r>   rF    r8   r6   r0   r0   W   s    (r8   r0   c            	         e Zd Zd Zddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	Zdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
Zddddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d dZ	dddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d!dZ
ddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d"dZdddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZddd	 	 	 	 	 	 	 	 	 	 	 d$dZddd	 	 	 	 	 	 	 	 	 	 	 d$dZddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d%dZddd	 	 	 	 	 	 	 	 	 	 	 d&dZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d'dZddd	 	 	 	 	 	 	 	 	 	 	 d(dZy))AsyncWebhookAdapterc                6    t        j                         | _        y r2   )weakrefWeakValueDictionary_locksr;   s    r6   r7   zAsyncWebhookAdapter.__init__j   s    3:3N3N3Pr8   N)payload	multipartproxy
proxy_authfilesreason
auth_tokenparamsc                 K   i }|xs g }d }|j                   |j                  f}	 | j                  |   }|d|d<   t        j                  |      }|	d|	 |d<   |t        |d      |d<   d }d }|j                  }|j                  }|j                   }t        |      4 d {   }t        d      D ]  }|D ]  }|j                  |	        |r1t        j                  d
      }|D ]  } |j                   d!i |  |}	 |j#                  |||||
||      4 d {   }t$        j'                  d||||j(                         |j+                  d       d {   xs d }|r'|j,                  d   dk(  rt/        j0                  |      }|j,                  j3                  d      }|dk(  rL|j(                  dk7  r=t        j4                  |      }t$        j'                  d||       |j7                  |       d|j(                  cxkD  rdk\  r)n n&|cd d d       d {    c cd d d       d {    S |j(                  dk(  rs|j,                  j3                  d      st9        ||      |d   }t$        j;                  d||       t	        j<                  |       d {    	 d d d       d {    |j(                  dk\  r6t	        j<                  d|dz  z          d {    	 d d d       d {    M|j(                  dk(  rt?        ||      |j(                  dk(  rtA        ||      t9        ||       |r'|j(                  dk\  rtG        ||      t9        ||      tI        d       # t        $ r' t	        j
                         x| j                  |<   }Y rw xY w7 7 7 S7 7 7 7 7 7 # 1 d {  7  sw Y   nxY w'# tB        $ rC}|dk  r8|jD                  dv r*t	        j<                  d|dz  z          d {  7   Y d }~m d }~ww xY w# 1 d {  7  sw Y   y xY ww)"Nzapplication/jsonzContent-TypezBot Authorizationz/ )safezX-Audit-Log-Reason   )seekF)quote_fields)dataheadersr[   rV   rW   z4Webhook ID %s with %s %s has returned status code %szutf-8)encodingz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   i  i     )6   iF'  z"Unreachable code in HTTP handling.rM   )%
webhook_idwebhook_tokenrS   KeyErrorr@   Lockr   _to_jsonurlquotemethodurlr0   rangeresetaiohttpFormData	add_fieldrequest_logdebugstatustextrc   jsonloadsget_parse_ratelimit_headerr>   r   warningrA   r   r   OSErrorerrnor   RuntimeError)r5   routesessionrT   rU   rV   rW   rX   rY   rZ   r[   rc   to_sendbucketr3   responserb   rr   rs   rl   attemptfile	form_datap	remainingr4   rh   es                               r6   ry   zAsyncWebhookAdapter.requestm   s     #%15""E$7$78	8;;v&D &8GN#nnW-G!)-j\':GO$,4V$,GG()26,0ii%%
$T* X	E X	Ed 8 P! -DJJGJ,-  ' 0 0e DI& 1+	++0a01'GG&$ '%##-  /   @@ @@ "

R&"$OO '/mmWm&E EN$  ( 0 0 @DV V#'::d#3D$,$4$4$8$89P$Q	$+30F$)$A$A($KE JJ%< !+ % !MM%07C7#'K@@ @@ @@X	E X	E X	Ed $??c1#+#3#3#7#7#>&3Hd&C C15m1DK LL%/ !+ + #*--"<<<$k@@ @@ @@n $??c1")--GaK"@@@$s@@ @@ @@v $??c1"+Hd";;%__3"*8T"::"/$"??UPd ??c),Xt<<#Hd33CDDW  	8)07DKK$	8&X	E@@  !F!@@X	E~ =i@@p Aq@@ @@ @@ @@ @@D  {qww+'=%mmA!O<<< 	[X	E X	E X	Es  #P?M8 A/P?$N+%P?(AP*O!N.
"O%9ON1
B6OO!N4
"O&P*(P?4N75P?:A*O$N:
%O*O5N=6O:P*<-O)O 
*O/O:O;O?P*AO5P*8,N($P?'N((P?.O1O4O7P?:O=O OOO
OOOP*	P'$1P"P
P"P*!P""P''P**P<0P31P<8P?)tokenrV   rW   rY   c               L    t        dd|      }| j                  ||||||      S )NDELETE/webhooks/{webhook_id}rl   )r   rV   rW   rY   rZ   r   ry   r5   rl   r   r   rV   rW   rY   r   s           r6   delete_webhookz"AsyncWebhookAdapter.delete_webhook   s;     h 8ZP||!  
 	
r8   )rV   rW   rY   c               L    t        dd||      }| j                  |||||      S )Nr   &/webhooks/{webhook_id}/{webhook_token}rl   rm   r   rV   rW   rY   r   r   s           r6   delete_webhook_with_tokenz-AsyncWebhookAdapter.delete_webhook_with_token  s=     4!	
 ||7%Jv  
 	
r8   c          	     N    t        dd|      }| j                  |||||||      S )NPATCHr   r   )r   rV   rW   rY   rT   rZ   r   	r5   rl   r   rT   r   rV   rW   rY   r   s	            r6   edit_webhookz AsyncWebhookAdapter.edit_webhook  s>     g7JO||!  
 	
r8   c               N    t        dd||      }| j                  ||||||      S )Nr   r   r   )r   rV   rW   rY   rT   r   r   s	            r6   edit_webhook_with_tokenz+AsyncWebhookAdapter.edit_webhook_with_token-  sD     4!	
 ||!  
 	
r8   F)rV   rW   rT   rU   rX   	thread_idthread_namewaitc       	   
         dt        |      i}|	r|	|d<   |
r|
|d<   t        dd||      }| j                  ||||||||      S )Nr   r   r   POSTr   r   )rT   rV   rW   rU   rX   r[   )intr   ry   )r5   rl   r   r   rV   rW   rT   rU   rX   r   r   r   r[   r   s                 r6   execute_webhookz#AsyncWebhookAdapter.execute_webhookG  sr     #d)$"+F;%0GM"4!	
 ||!  	
 		
r8   )rV   rW   r   c               `    i }|r||d<   t        dd|||      }	| j                  |	||||      S )Nr   GET</webhooks/{webhook_id}/{webhook_token}/messages/{message_id}rl   rm   
message_idr   rV   rW   r[   r   
r5   rl   r   r   r   rV   rW   r   r[   r   s
             r6   get_webhook_messagez'AsyncWebhookAdapter.get_webhook_messagen  sR     "+F;J!!
 ||7%Jv  
 	
r8   )rV   rW   r   rT   rU   rX   c          
     f    i }|r||d<   t        dd|||      }| j                  |||||||	|
      S )Nr   r   r   r   )r[   rT   rV   rW   rU   rX   r   )r5   rl   r   r   r   rV   rW   r   rT   rU   rX   r[   r   s                r6   edit_webhook_messagez(AsyncWebhookAdapter.edit_webhook_message  s_     "+F;J!!
 ||!  	
 		
r8   c               `    i }|r||d<   t        dd|||      }	| j                  |	||||      S )Nr   r   r   r   r   r   r   s
             r6   delete_webhook_messagez*AsyncWebhookAdapter.delete_webhook_message  sR     "+F;J!!
 ||7%Jv  
 	
r8   )rV   rW   c               J    t        dd|      }| j                  |||||      S )Nr   r   r   )r   rV   rW   rZ   r   r5   rl   r   r   rV   rW   r   s          r6   fetch_webhookz!AsyncWebhookAdapter.fetch_webhook  s5     e5*M||7%JSX  
 	
r8   c               J    t        dd||      }| j                  ||||      S )Nr   r   r   r   rV   rW   r   r   s          r6   fetch_webhook_with_tokenz,AsyncWebhookAdapter.fetch_webhook_with_token  s3     4!	
 ||E7%J|WWr8   )rV   rW   rb   rX   c                  d|i}	|||	d<   ddig}
g }|xs g }t        |      D ]\  \  }}|j                  ||j                  |j                  d       |
j                  d| d|j                  |j                  dd	       ^ ||	d
<   t        j                  |	      |
d   d<   t        dd||      }| j                  ||||||
      S )NrC   rb   namepayload_jsonidfilenamedescriptionfiles[]application/octet-streamr   rD   r   content_typeattachmentsr   rD   r   z3/interactions/{webhook_id}/{webhook_token}/callbackr   )r   rV   rW   rX   rU   )		enumerateappendr   r   fpr   rp   r   ry   )r5   interaction_idr   r   rV   rW   rC   rb   rX   rT   formr   indexr   r   s                  r6   create_interaction_responsez/AsyncWebhookAdapter.create_interaction_response  s    D#
 "GFO()$U+ 	KE4 $#'#3#3 KK$UG1-!WW $$>		  "- >>'2QA%	
 ||!  
 	
r8   c               J    t        dd||      }| j                  ||||      S )Nr   9/webhooks/{webhook_id}/{webhook_token}/messages/@originalr   r   r   r5   application_idr   r   rV   rW   rs          r6   !get_original_interaction_responsez5AsyncWebhookAdapter.get_original_interaction_response   s3     G%	
 ||Awe
|SSr8   )rV   rW   rT   rU   rX   c          	     P    t        dd||      }	| j                  |	||||||      S )Nr   r   r   )r   rV   rW   rT   rU   rX   r   )
r5   r   r   r   rV   rW   rT   rU   rX   r   s
             r6   "edit_original_interaction_responsez6AsyncWebhookAdapter.edit_original_interaction_response1  sG     G%	
 ||!  
 	
r8   c               J    t        dd||      }| j                  ||||      S )Nr   r   r   r   r   r   s          r6   $delete_original_interaction_responsez8AsyncWebhookAdapter.delete_original_interaction_responseM  s3     G%	
 ||Awe
|SSr8   )r   r   r   aiohttp.ClientSessionrT   dict[str, Any] | NonerU   list[dict[str, Any]] | NonerV   
str | NonerW   aiohttp.BasicAuth | NonerX   list[File] | NonerY   r   rZ   r   r[   r   rH   r   )rl   r   r   r   r   r   rV   r   rW   r   rY   r   rH   Response[None])rl   r   r   strr   r   rV   r   rW   r   rY   r   rH   r   )rl   r   r   r   rT   zdict[str, Any]r   r   rV   r   rW   r   rY   r   rH   zResponse[WebhookPayload])rl   r   r   r   r   r   rV   r   rW   r   rT   r   rU   r   rX   r   r   
int | Noner   r   r   boolrH   zResponse[MessagePayload | None])rl   r   r   r   r   r   r   r   rV   r   rW   r   r   r   rH   Response[MessagePayload])rl   r   r   r   r   r   r   r   rV   r   rW   r   r   r   rT   r   rU   r   rX   r   rH   zResponse[WebhookMessage])rl   r   r   r   r   r   r   r   rV   r   rW   r   r   r   rH   r   )rl   r   r   r   r   r   rV   r   rW   r   rH   z1Response[WebhookPayload | FollowerWebhookPayload])r   r   r   r   r   r   rV   r   rW   r   rC   r   rb   r   rX   
list[File]rH   r   )r   r   r   r   r   r   rV   r   rW   r   rH   r   )r   r   r   r   r   r   rV   r   rW   r   rT   r   rU   r   rX   r   rH   r   )r   r   r   r   r   r   rV   r   rW   r   rH   r   )rJ   rK   rL   r7   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rM   r8   r6   rO   rO   i   s   Q *.15 /3#'!!%(,@E@E '@E
 '@E /@E @E -@E !@E @E @E &@E 
@EL ! /3!

 	

 '
 
 -
 
 

4 !/3!

 

 '
 
 -
 
 

6 !/3!

 
  	
 '
 
 -
 
 
"
: !/3!

 
  	
 '
 
 -
 
 
"
@ !/3)-15#' $"&%
%
 %

 '%
 %
 -%
 '%
 /%
 !%
 %
  %
 %
 
)%
\ !/3 $

 
 	
 '
 
 -
 
 
"
D !/3 $)-15#'#
#
 #
 	#
 '#
 #
 -#
 #
 '#
 /#
 !#
 
"#
X !/3 $

 
 	
 '
 
 -
 
 

B !/3

 

 '
 
 -
 
;
( !/3XX X
 'X X -X 
;X. !/3&* 6
6
 6

 '6
 6
 -6
 6
 $6
 6
 
6
| !/3TT T
 'T T -T 
"T. !/3)-15#'

 

 '
 
 -
 '
 /
 !
 
"
D !/3TT T
 'T T -T 
Tr8   rO   c                  ,    e Zd ZU ded<   ded<   ded<   y)ExecuteWebhookParametersr   rT   r   rU   r   rX   N)rJ   rK   rL   __annotations__rM   r8   r6   r   r   _  s    ""**r8   r   F)username
avatar_urltts	ephemeralr   rX   r   embedembedsviewpollapplied_tagsallowed_mentionsprevious_allowed_mentionssuppressc                  |t         ur|t         urt        d      |	t         ur|t         urt        d      i }|	t         ur:t        |	      dkD  rt        d      |	D cg c]  }|j	                          c}|d<   |t         ur|g n|j	                         g|d<   | t         ur| t        |       nd |d<   g }|t         ur|D cg c]  }|j	                          }}|
t         ur|
|
j                         ng |d<   |t         ur|j	                         |d<   ||d	<   |rt        |      |d
<   |r||d<   t        ||      }|j                  |d<   |t         ur||d<   |r9|#|j                  |      j	                         |d<   n)|j	                         |d<   n||j	                         |d<   g }g }|t         ur|g}|rjt        |      D ]\  \  }}|j                  d| d|j                  |j                  dd       |j                  ||j                  |j                  d       ^ |r||d<   |r.|j                  dt        j                   |      d       d }||z  }t#        |||      S c c}w c c}w )Nz,Cannot mix file and files keyword arguments.z.Cannot mix embed and embeds keyword arguments.
   z$embeds has a maximum of 10 elements.r   content
componentsr   r   r   r   )suppress_embedsr   flagsr   r   r   r   r   r   r   r   r   )r   rD   )rT   rU   rX   )MISSING	TypeErrorlenr   to_dictr   to_componentsr   rD   merger   r   r   r   r   r   rp   r   )r   r   r   r   r   r   rX   r   r   r   r   r   r   r   r   r   rT   r   _attachmentsar   rU   multipart_filesr   s                           r6   handle_message_parametersr  e  s   & GG 3FGGWg!5HIIGWv;!"HII289QQYY[9G"'-Bemmo5Fg-4-@S\d	L'!-89		9978<8H 2 2 4b7,,.GEN #J&
YGE{{GG7"".$0*C*I*I +gi &' +;*B*B*DG&'	"	.&?&G&G&I"#IO7$U+ 	KE4""$UG1-!WW $$>	  $#'#3#3	" !-.5>>';RST_$	#GyPUVVG : :s   I+I0async_webhook_context)defaultzContextVar[AsyncWebhookAdapter]async_contextc                       e Zd ZdZdZd Zd Zy)r"   a  Represents a partial channel for webhooks.

    These are typically given for channel follower webhooks.

    .. versionadded:: 2.0

    Attributes
    ----------
    id: :class:`int`
        The partial channel's ID.
    name: :class:`str`
        The partial channel's name.
    )r   r   c               >    t        |d         | _        |d   | _        y )Nr   r   )r   r   r   r5   rb   s     r6   r7   zPartialWebhookChannel.__init__  s    d4j/L	r8   c                <    d| j                   d| j                   dS )Nz<PartialWebhookChannel name= id=>r   r   r;   s    r6   __repr__zPartialWebhookChannel.__repr__  s    -dii]$twwiqIIr8   N)rJ   rK   rL   __doc__	__slots__r7   r  rM   r8   r6   r"   r"     s     I!Jr8   r"   c                  2    e Zd ZdZdZd Zd Zedd       Zy)r#   a  Represents a partial guild for webhooks.

    These are typically given for channel follower webhooks.

    .. versionadded:: 2.0

    Attributes
    ----------
    id: :class:`int`
        The partial guild's ID.
    name: :class:`str`
        The partial guild's name.
    )r   r   _icon_statec               `    || _         t        |d         | _        |d   | _        |d   | _        y )Nr   r   icon)r  r   r   r   r  )r5   rb   states      r6   r7   zPartialWebhookGuild.__init__  s.    d4j/L	&\
r8   c                <    d| j                   d| j                   dS )Nz<PartialWebhookGuild name=r  r  r  r;   s    r6   r  zPartialWebhookGuild.__repr__  s    +DII=TWWIQGGr8   c                    | j                   yt        j                  | j                  | j                  | j                         S )z-Returns the guild's icon asset, if available.N)r  r   _from_guild_iconr  r   r;   s    r6   r  zPartialWebhookGuild.icon  s2     ::%%dkk477DJJGGr8   N)rH   zAsset | None)	rJ   rK   rL   r  r  r7   r  propertyr  rM   r8   r6   r#   r#     s/     2I"H H Hr8   r#   c                      e Zd ZdZd Zy)!_FriendlyHttpAttributeErrorHelperrM   c                    t        d      )Nz2PartialWebhookState does not support http methods.)AttributeErrorr5   attrs     r6   __getattr__z-_FriendlyHttpAttributeErrorHelper.__getattr__
  s    QRRr8   N)rJ   rK   rL   r  r#  rM   r8   r6   r  r    s    ISr8   r  c                  @    e Zd ZdZd	dZd Zd Zd Zed        Z	d Z
y)
_WebhookState)_parent_webhookc                T    || _         |  t        |t              rd | _        y || _        y r2   )r'  
isinstancer%  r&  )r5   webhookparents      r6   r7   z_WebhookState.__init__  s"    $)&-@tfr8   c                R    | j                   | j                   j                  |      S y r2   )r&  
_get_guild)r5   guild_ids     r6   r-  z_WebhookState._get_guild  s$    <<#<<**844r8   c                j    | j                   | j                   j                  |      S t        | |      S Nr  rb   )r&  
store_userr   r  s     r6   r2  z_WebhookState.store_user  s.    <<#<<**400d..r8   c                    t        | |      S r0  )r   r  s     r6   create_userz_WebhookState.create_user"  s    d..r8   c                Z    | j                   | j                   j                  S t               S r2   )r&  httpr  r;   s    r6   r6  z_WebhookState.http&  s'    <<#<<$$$ 122r8   c                d    | j                   t        | j                   |      S t        d|d      )Nz%PartialWebhookState does not support .)r&  getattrr   r!  s     r6   r#  z_WebhookState.__getattr__/  s2    <<#4<<..DTHANOOr8   N)r*  r   r+  z&ConnectionState | _WebhookState | None)rJ   rK   rL   r  r7   r-  r2  r4  r  r6  r#  rM   r8   r6   r%  r%    s6    'IM
// 3 3Pr8   r%  c            	      l    e Zd ZU dZded<   ee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:: 1.6
    r%  r  Nc
                (  K   t         }
t        | d      rt        | j                        }
nit	        | j
                  t              r t        | j
                  j                        }
n/t	        | j
                  t              rt        | j                        }
|t         u r| j                  xs t         }|	t         u r| j                  j                  }	| j                  j                  j                  | j                  |||||||||
|	       d{   S 7 w)av  |coro|

        Edits the message.

        .. versionadded:: 1.6

        .. versionchanged:: 2.0
            The edit is no longer in-place, instead the newly edited message is returned.

        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.

            .. versionadded:: 2.0
        files: List[:class:`File`]
            A list of files to send with the content. This cannot be mixed with the
            ``file`` parameter.

            .. versionadded:: 2.0
        attachments: List[:class:`Attachment`]
            A list of attachments to keep in the message. If ``[]`` is passed
            then all attachments are removed.

            .. versionadded:: 2.0
        allowed_mentions: :class:`AllowedMentions`
            Controls the mentions being processed in this message.
            See :meth:`.abc.Messageable.send` for more information.
        view: Optional[:class:`~discord.ui.View`]
            The updated view to update this message with. If ``None`` is passed then
            the view is removed.

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

        Returns
        -------
        :class:`WebhookMessage`
            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
r   r   r   r   rX   r   r   r   threadr   N)r   hasattrr   r<  r)  channelr   r   r   r   r   r   r  r'  edit_message)r5   r   r   r   r   rX   r   r   r   r   r>  s              r6   editzWebhookMessage.editD  s     R 4&DOO,Ff-DLLOO,Fl3DGG_F'!**5gKwzz11H[[))66GG#- 7 
 
 	
 
s   D	DDD)delayc               h   K   dt         d      r j                  n0t         j                  t              r j                  j
                  |$|fd fd}t        j                   |              y j                  j                  j                   j
                         d{    y7 w)a  |coro|

        Deletes the message.

        Parameters
        ----------
        delay: Optional[:class:`float`]
            If provided, the number of seconds to wait before deleting the message.
            The waiting is done in the background and deletion failures are ignored.

        Raises
        ------
        Forbidden
            You do not have proper permissions to delete the message.
        NotFound
            The message was deleted already.
        HTTPException
            Deleting the message failed.
        Nr<  c                   K   t        j                  |        d {    	 j                  j                  j	                  j
                         d {    y 7 ?7 # t        $ r Y y w xY ww)Nr   )r@   rA   r  r'  delete_messager   r   )rC  r5   r   s    r6   
inner_callz)WebhookMessage.delete.<locals>.inner_call  sl     mmE***++..==9 >    + % sD   A/AA/4A  AA  A/A   	A,)A/+A,,A/rF  )rC  rG   )r?  r<  r)  r@  r   r   r@   create_taskr  r'  rG  )r5   rC  rH  r   s   `  @r6   deletezWebhookMessage.delete  s     ( !%	4&If-I05  
-++&&55dgg5SSSs   B&B2*B0+B2)r   r   r   list[Embed]r   Embed | Noner   r'   rX   r   r   list[Attachment]r   View | Noner   AllowedMentions | Noner   zbool | NonerH   r!   )rC  zfloat | NonerH   rI   )rJ   rK   rL   r  r   r   rB  rJ  rM   r8   r6   r!   r!   6  s    	  &%%#(/#37 'c
c
 c
 	c

 c
 c
 &c
 c
 1c
 c
 
c
J 59 'Tr8   r!   c                      e Zd ZU dZded<   	 	 d	 	 	 	 	 ddZddZddZddZe	dd	       Z
e	dd
       Ze	dd       Ze	dd       Zy)BaseWebhook)r   rC   r.  
channel_idr   rZ   userr   _avatarsource_channelsource_guildr  tuple[str, ...]r  Nc                `    || _         |xs t        | |      | _        | j                  |       y )Nr+  )rZ   r%  r  _update)r5   rb   r   r  s       r6   r7   zBaseWebhook.__init__  s2     ',7< 8
A
 	Tr8   c                v   t        |d         | _        t        t        t        |d               | _        t        j                  |d      | _        t        j                  |d      | _        |j                  d      | _
        |j                  d      | _        |j                  d      | _        |j                  d      }d | _        |t        | j                  |	      | _        |j                  d
      }|rt!        |      }|| _        |j                  d      }|rt%        || j                        }|| _        y )Nr   rC   rR  r.  r   avatarr   rS  r1  rU  )rb   rV  )rb   r  )r   r   r   r   rC   r   _get_as_snowflakerR  r.  r   r   rT  r   rS  r   r  r"   rU  r#   rV  )r5   rb   rS  rU  rV  s        r6   rZ  zBaseWebhook._update  s    d4j/[#d6l*;<	11$E//jAHHV$	xx)XXg&
xx,0	4;;T:DI"232GN<Jxx/.LTL8Dr8   c                    | j                   du S )zSWhether the webhook is a "partial" webhook.

        .. versionadded:: 2.0
        N)rR  r;   s    r6   
is_partialzBaseWebhook.is_partial
  s    
 $&&r8   c                    | j                   duS )z^Whether the webhook is authenticated with a bot token.

        .. versionadded:: 2.0
        N)rZ   r;   s    r6   is_authenticatedzBaseWebhook.is_authenticated  s    
 d**r8   c                h    | j                   xr% | j                   j                  | j                        S )zyThe guild this webhook belongs to.

        If this is a partial webhook, then this will always return ``None``.
        )r  r-  r.  r;   s    r6   guildzBaseWebhook.guild  s&     {{Dt{{55dmmDDr8   c                X    | j                   }|xr |j                  | j                        S )zThe text channel this webhook belongs to.

        If this is a partial webhook, then this will always return ``None``.
        )rc  get_channelrR  )r5   rc  s     r6   r@  zBaseWebhook.channel   s'     

;**4??;;r8   c                @    t        j                  | j                        S )z+Returns the webhook's creation time in UTC.)r   snowflake_timer   r;   s    r6   
created_atzBaseWebhook.created_at)  s     ##DGG,,r8   c                    | j                    t        j                  | j                  d      S t        j                  | j                  | j
                  | j                         S )zReturns an :class:`Asset` for the avatar the webhook has.

        If the webhook does not have a traditional avatar, an asset for
        the default avatar is returned instead.
        r   )rT  r   _from_default_avatarr  _from_avatarr   r;   s    r6   r\  zBaseWebhook.avatar.  sF     <<--dkk1==!!$++twwEEr8   )NN)rb   'WebhookPayload | FollowerWebhookPayloadr   r   r  zConnectionState | None)rb   rl  )rH   r   )rH   zGuild | None)rH   zTextChannel | None)rH   zdatetime.datetime)rH   r   )rJ   rK   rL   r  r   r7   rZ  r_  ra  r  rc  r@  rh  r\  rM   r8   r6   rQ  rQ    s    "I $ !(,	
5
 
 &	
E6'+ E E < < - - 	F 	Fr8   rQ  c                  6    e Zd ZU dZdZded<   	 	 	 	 d"	 	 	 	 	 	 	 	 	 d# fdZd Zed$d       Z	e
dddd		 	 	 	 	 	 	 	 	 	 	 	 	 d%d
       Ze
dddd		 	 	 	 	 	 	 	 	 	 	 d&d       Ze
d'd       Ze
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eeededd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d+d       Zeefeeeeeeeeeeeededdd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d,d       Zefeeddeeeeeeeededdd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d-dZdd	 	 	 	 	 d.dZeeeeeeededd
	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d/d Zdd	 	 	 	 	 d0d!Z xZS )1r    a
  Represents an asynchronous Discord webhook.

    Webhooks are a form to send messages to channels in Discord without a
    bot user or authentication.

    There are two main ways to use Webhooks. The first is through the ones
    received by the library such as :meth:`.Guild.webhooks` and
    :meth:`.TextChannel.webhooks`. The ones received by the library will
    automatically be bound using the library's internal HTTP session.

    The second form involves creating a webhook object manually using the
    :meth:`~.Webhook.from_url` or :meth:`~.Webhook.partial` classmethods.

    For example, creating a webhook from a URL and using :doc:`aiohttp <aio:index>`:

    .. code-block:: python3

        from discord import Webhook
        import aiohttp

        async def foo():
            async with aiohttp.ClientSession() as session:
                webhook = Webhook.from_url('url-here', session=session)
                await webhook.send('Hello World', username='Foo')

    For a synchronous counterpart, see :class:`SyncWebhook`.

    .. 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   rW  r  Nc                R    t         |   |||       || _        || _        || _        y r2   )superr7   r   rV   rW   )r5   rb   r   rV   rW   r   r  	__class__s          r6   r7   zWebhook.__init__  s+     	ue,!&
4>r8   c                "    d| j                   dS )Nz<Webhook id=r  )r   r;   s    r6   r  zWebhook.__repr__  s    dgg[**r8   c                :    d| j                    d| j                   S )zReturns the webhook's url.z!https://discord.com/api/webhooks//)r   r   r;   s    r6   rs   zWebhook.url  s     3477)1TZZLIIr8   )rV   rW   	bot_tokenc               (    |d|d} | |||||      S )a/  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:`aiohttp.ClientSession`
            The session to use to send requests with. Note
            that the library does not manage the session and
            will not close it.

            .. versionadded:: 2.0
        bot_token: Optional[:class:`str`]
            The bot authentication token for authenticated requests
            involving the webhook.

            .. versionadded:: 2.0

        Returns
        -------
        :class:`Webhook`
            A partial :class:`Webhook`.
            A partial webhook is just a webhook object with an ID and a token.
        ri   )r   rC   r   rV   rW   r   rM   )clsr   r   r   rV   rW   rt  rb   s           r6   partialzWebhook.partial  s*    L  
 4*IVVr8   c                   t        j                  d|      }|t        d      |j                         }d|d<    | |||||      S )aJ  Creates a partial :class:`Webhook` from a webhook URL.

        Parameters
        ----------
        url: :class:`str`
            The URL of the webhook.
        session: :class:`aiohttp.ClientSession`
            The session to use to send requests with. Note
            that the library does not manage the session and
            will not close it.

            .. versionadded:: 2.0
        bot_token: Optional[:class:`str`]
            The bot authentication token for authenticated requests
            involving the webhook.

            .. versionadded:: 2.0

        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})zInvalid webhook URL given.ri   rC   rv  )researchr   	groupdict)rw  rs   r   rV   rW   rt  mrb   s           r6   from_urlzWebhook.from_url  sS    N II]
 9!">?? {{}V4*IVVr8   c                  |j                    d| }|d   d||j                  |j                   j                  |j                  |j                  |j                  |j                  |j
                  dd}|j                  }|j                  }|j                  }|j                  }	|j                  }
 | ||||	|
|j                  j                        S )Nz #rl   r   )r   discriminatorglobal_namer   r\  )r   rC   r   rR  r.  rS  r   r  rW   rV   r   )rc  r   r   r  r  rT  r  r6  _HTTPClient__sessionrW   rV   r   )rw  rb   r@  rS  r   feedr  r6  r   rW   rV   s              r6   _as_followerzWebhook._as_follower  s    --7),|$!**(( II!%!3!3#//gg,, 
 zz++__


!**""
 	
r8   c                    |j                   }|j                  }|j                  }|j                  } | ||||||j                   j                        S )Nr  )r6  r  rW   rV   r   )rw  rb   r  r6  r   rW   rV   s          r6   
from_statezWebhook.from_state!  sQ    zz++__


!**""
 	
r8   T)prefer_authc               N  K   t         j                         }|r]| j                  rQ|j                  | j                  | j                  | j
                  | j                  | j                         d{   }nh| j                  rQ|j                  | j                  | j                  | j
                  | j                  | j                         d{   }nt        d      t        || j
                  | j                  | j                  | j                  | j                        S 7 7 Uw)a  |coro|

        Fetches the current webhook.

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

        .. versionadded:: 2.0

        .. 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:`Webhook`
            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   N5This webhook does not have a token associated with itr   rV   rW   r   r  )r  r   rZ   r   r   r   rV   rW   r   r   r   r    r  )r5   r  adapterrb   s       r6   fetchzWebhook.fetch0  s     F  ##%4?? ..jj?? /  D ZZ 99

jj?? :  D "G  LL**//++
 	
)s&   A.D%0D!1AD%D#AD%#D%)rY   r  c                 K   | j                   | j                  t        d      t        j	                         }|r^| j                  rR|j                  | j                  | j                  | j                  | j                  | j                  |       d{    y| j                   rR|j                  | j                  | j                   | j                  | j                  | j                  |       d{    yy7 d7 w)a  |coro|

        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``.

            .. versionadded:: 2.0

        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   r   rV   rW   rY   r   )r   rZ   r   r  r   r   r   r   rV   rW   r   )r5   rY   r  r  s       r6   rJ  zWebhook.deletes  s     8 ::$//"9!G   ##%4??((oojj?? )    ZZ33

jj?? 4    s%   BC=C9AC=2C;3C=;C=)rY   r   r\  r@  r  c          	       K   | j                   | j                  t        d      i }|t        ur|t	        |      nd|d<   |t        ur|t        j                  |      nd|d<   t        j                         }d}|x| j                  t        d      |j                  |d<   |j                  | j                  | j                  || j                  | j                  | j                  |       d{   }|r_| j                  rS|j                  | j                  | j                  || j                  | j                  | j                  |       d{   }n^| j                   rR|j                  | j                  | j                   || j                  | j                  | j                  |       d{   }|t        d      t!        || j                  | j                  | j                  | j                  | j"                  	      S 7 7 7 Yw)
aK  |coro|

        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.

            .. versionadded:: 2.0
        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``.

            .. versionadded:: 2.0

        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  r   r\  z.Editing channel requires authenticated webhookrR  )rT   r   rV   rW   rY   z+Unreachable code hit: data was not assignedr  )r   rZ   r   r   r   r   _bytes_to_base64_datar  r   r   r   r   rV   rW   r   r   r    r  )	r5   rY   r   r\  r@  r  rT   r  rb   s	            r6   rB  zWebhook.edit  s    V ::$//"9!G  w+/+;c$iGFO 7=7I++F3t H  ##%&*&%&VWW$+JJGL! --jj?? .  D 4?? --jj?? .  D ZZ 88

jj?? 9  D <LMMLL**//++
 	
Es9   C/H1H2AHHAH0H
1AHH
Hc                    t        | | j                        }| j                  xs# t        | j                  t	        |d               }t        |||      S )NrY  rR  )r  r   )rb   r  r@  )r%  r  r@  r   r   r!   )r5   rb   r  r@  s       r6   _create_messagezWebhook._create_message  sF    d4;;7,,c"44;;3tT`OaKb"c4ugFFr8   )r   r   r   r   r   rX   r   r   r   r   r   r>  r   r   delete_afterc                  K   y wr2   rM   r5   r   r   r   r   r   r   rX   r   r   r   r   r   r>  r   r   r   r  s                     r6   sendzWebhook.send  s     *    .)r   r   r   r   r   rX   r   r   r   r   r   r>  r   r   r   r  c                  K   y wr2   rM   r  s                     r6   r  zWebhook.send4  s     * r  Fc               ^  K   | j                   t        d      t        | j                  dd      }|t        }|r|rt        d      |r|s|st        d      | j
                  t        j                  u }|r|st        d      |rd}|t        ur<t        | j                  t              rt        d      |du r|j                  d	|_
        |t        }t        ||||||||	|||||
|
      }t        j                         }d}|t        ur|j                  }|j                  | j                  | j                   | j                   | j"                  | j$                  |j&                  |j(                  |j*                  |||       d{   }d|r| j-                  |      |t        urG|j/                         s7dnj                  }dn|_        | j                  j3                  ||       6fd}t5        j6                   |       | j                  j8                         S 7 w)a  |coro|

        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``. If the type of webhook
            is :attr:`WebhookType.application` then this is always 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.
        ephemeral: :class:`bool`
            Indicates if the message should only be visible to the user.
            This is only available to :attr:`WebhookType.application` webhooks.
            If a view is sent with an ephemeral message, and it has no timeout set
            then the timeout is set to 15 minutes.

            .. versionadded:: 2.0
        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
        view: :class:`discord.ui.View`
            The view to send with the message. You can only send a view
            if this webhook is not partial and has state attached. A
            webhook has state attached if the webhook is managed by the
            library.

            .. versionadded:: 2.0
        thread: :class:`~discord.abc.Snowflake`
            The thread to send this webhook to.

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

            .. versionadded:: 2.0
        applied_tags: List[:class:`Snowflake`]
            A list of tags to apply to the message. Only works for threads.

            .. versionadded:: 2.5
        delete_after: :class:`float`
            If provided, the number of seconds to wait in the background
            before deleting the message we just sent.
        poll: :class:`Poll`
            The poll to send.

            .. versionadded:: 2.6

        Returns
        -------
        Optional[:class:`WebhookMessage`]
            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
            Either there was no token associated with this webhook, ``ephemeral`` was passed
            with the improper webhook type, there was no state attached with this webhook when
            giving it a view, you specified both ``thread_name`` and ``thread``, or ``applied_tags``
            was passed with neither ``thread_name`` nor ``thread`` specified.
        Nr  r   z0You cannot specify both a thread and thread_namez0You cannot specify applied_tags without a threadz=ephemeral messages can only be sent from application webhooksTz:Webhook views require an associated state with the webhookg      @)r   r   r   r   r   rX   r   r   r   r   r   r   r   r   )	r   rV   rW   rT   rU   rX   r   r   r   c                    K   t        j                          d {    j                          d {    y 7 7 wr2   )r@   rA   rJ  )r  msgs   r6   rJ  zWebhook.send.<locals>.delete  s1     mmL111jjl"" 2"s   >:><>>)loop)r   r   r9  r  r   rC   r   applicationr)  r%  timeoutr  r  r   r   r   r   rV   rW   rT   rU   rX   r  is_finishedmessage
store_viewr@   ensure_futurer  )r5   r   r   r   r   r   r   rX   r   r   r   r   r   r>  r   r   r   r  previous_mentionsapplication_webhookr[   r  r   rb   r   rJ  r  s                    `        @r6   r  zWebhook.sendK  s3    z ::!G  5<KK+T5
 ?Gk!"TUU;!"TUU"ii;+B+BB0!O  Dw$++}5%P  D T\\%9(<D*!%-&7
   ##% $	 		I,,GGJJLL**NN&&,,# - 
 
 &&t,Cwt'7'7'9!$#&&J#&;4CDLKK""44## !!&(1A1AB
?
s   FH-H+	B#H-rF  c          	     t  K   | j                   t        d      t        j                         }|j	                  | j
                  | j                   || j                  | j                  | j                  |       d{   }| j                  |      }|r!t        |j                  t              r||_        |S 7 :w)a(  |coro|

        Retrieves a single :class:`~discord.WebhookMessage` 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.WebhookMessage`
            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.
        Nr  r   rV   rW   r   )r   r   r  r   r   r   r   rV   rW   r  r)  r@  r   r<  )r5   r   r   r  rb   r  s         r6   fetch_messagezWebhook.fetch_message#  s     B ::!G   ##%00GGJJLL** 1 
 
 ""4(CKK1CD&CN

s   A9B8;B6<;B8r=  c       
          K   | j                   t        d      |t        ur@t        | j                  t
              rt        d      | j                  j                  |       t        | j                  dd      }t        ||||||||	||
      }d}|
t        ur|
j                  }t        j                         }|j                  | j                  | j                   || j                  | j                  | j                  ||j                   |j"                  |j$                  
       d{   }| j'                  |      }|r3|j)                         s#||_        | j                  j-                  ||       |S 7 Lw)a	  |coro|

        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

        .. versionchanged:: 2.0
            The edit is no longer in-place, instead the newly edited message is returned.

        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.
        attachments: List[:class:`Attachment`]
            A list of attachments to keep in the message. If ``[]`` is passed
            then all attachments are removed.
        file: :class:`File`
            The file to upload. This cannot be mixed with ``files`` parameter.

            .. versionadded:: 2.0
        files: List[:class:`File`]
            A list of files to send with the content. This cannot be mixed with the
            ``file`` parameter.

            .. versionadded:: 2.0
        allowed_mentions: :class:`AllowedMentions`
            Controls the mentions being processed in this message.
            See :meth:`.abc.Messageable.send` for more information.
        view: Optional[:class:`~discord.ui.View`]
            The updated view to update this message with. If ``None`` is passed then
            the view is removed. The webhook must have state attached, similar to
            :meth:`send`.

            .. versionadded:: 2.0
        thread: Optional[:class:`~discord.abc.Snowflake`]
            The thread that contains the message.
        suppress: :class:`bool`
            Whether to suppress embeds for the message.

        Returns
        -------
        :class:`WebhookMessage`
            The newly edited webhook 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 or the webhook had
            no state.
        Nr  z3This webhook does not have state associated with itr   )
r   r   rX   r   r   r   r   r   r   r   )r   rV   rW   r   rT   rU   rX   )r   r   r   r)  r  r%  prevent_view_updates_forr9  r  r   r  r   r   r   rV   rW   rT   rU   rX   r  r  r  r  )r5   r   r   r   r   r   rX   r   r   r   r>  r   r  r[   r   r  rb   r  s                     r6   rA  zWebhook.edit_messageY  se    h ::!G  w$++}5%I  KK00<4;KK+T5
 +#-&7
 !%	 		I##%11GGJJLL**NN&&,, 2 
 
 &&t,((*"DLKK""44#
s   D$E5&E3'AE5c          	     
  K   | j                   t        d      t        j                         }|j	                  | j
                  | j                   || j                  | j                  | j                  |       d{    y7 w)aD  |coro|

        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   r   r   rV   rW   )r5   r   r   r  s       r6   rG  zWebhook.delete_message  sx     4 ::!G   ##%,,GGJJLL** - 
 	
 	
s   A9B;B<B)NNNN)
rb   rl  r   r   rV   r   rW   r   r   r   )rH   r   )r   r   r   r   r   r   rV   r   rW   r   rt  r   rH   r    )rs   r   r   r   rV   r   rW   r   rt  r   rH   r    )rH   r    )r  r   rH   r    )rY   r   r  r   )rY   r   r   r   r\  zbytes | Noner@  Snowflake | Noner  r   rH   r    )$r   r   r   r   r   r   r   r   r   r   r   r'   rX   r   r   r&   r   rK  r   r*   r   r.   r   r+   r>  r$   r   r   r   list[Snowflake]r   zLiteral[True]r  rG   rH   r!   )$r   r   r   r   r   r   r   r   r   r   r   r'   rX   r   r   r&   r   rK  r   r*   r   r.   r   r+   r>  r$   r   r   r   r  r   zLiteral[False]r  rG   rH   rI   )$r   r   r   r   r   r   r   r   r   r   r   r'   rX   r   r   r&   r   rK  r   r*   r   r.   r   r+   r>  r$   r   r   r   r  r   r   r  rG   rH   zWebhookMessage | None)r   r   r   r   rH   r!   )r   r   r   r   r   rK  r   rL  r   r'   rX   r   r   rM  r   rN  r   rO  r>  r  r   r   rH   r!   )r   r   r   r   rH   rI   )rJ   rK   rL   r  r  r   r7   r  r  rs   classmethodrx  r~  r  r  r  rJ  r   rB  r  r	   r  r  rA  rG  __classcell__)rp  s   @r6   r    r    ;  s   L\ "DIC !/3 ?5? '? 	?
 -? ?+ J J  !/3 $*W*W *W
 '*W *W -*W *W 
*W *WX  !/3 $/W/W '	/W
 /W -/W /W 
/W /Wb 
 
> 
 
 26 A
F 48T 4r ""&$( k
 k
 	k

 k
 "k
 k
 
k
ZG    !!#%,3#"&(/"' 	
        *      !" &#$ %& '( 
) ,    !!#%,3#"&(/""' 	
        *      !" &#$ %& '( 
) 0 V  !#%,3#"&(/"'VV 	V
 V V V V V V V *V V V V   !V" &#V$ %V& 'V( 
)Vr 3744%/4	4t &%%#(/#37#*GG 	G
 G G G G &G G 1G !G G 
GT ;?(
(
-7(
	(
r8   r    )"r   r   r   r   r   r   r   r   r   r   r   r'   rX   r   r   rM  r   rL  r   rK  r   rN  r   zPoll | Noner   r  r   rO  r   rO  r   r   rH   r   )_r  
__future__r   r@   r~   loggingrz  rQ   contextvarsr   typingr   r   r   r   r	   urllib.parser
   rq   rv    r   assetr   r@  r   r   enumsr   r   errorsr   r   r   r   r   r   r   r6  r   r  r   r   mixinsr   objectr   threadsr   rS  r   r   __all__	getLoggerrJ   rz   datetimeabcr$   r%   r   r&   r   r'   rc  r(   r)   mentionsr*   r   r+   r  r,   types.messageMessagePayloadtypes.webhookr-   FollowerWebhookPayloadr    WebhookPayloadui.viewr.   r   r0   rO   r   r  r  r   r"   r#   r  r%  r!   rQ  rM   r8   r6   <module>r     s`  2 #    	  " D D *    6 )  !  )    ! w"%*'9I9
-- $sT sTlz  "_W $+!!$+/68<#_W_W _W 	_W
 
_W _W _W _W "_W _W _W _W _W "_W -_W   6!_W" #_W$ %_WD 2<%8%:2. 
JH J2H( HDS S%P %PPZTW ZTzeF( eFPO
k O
r8   