
    i%                   0   U d Z ddlm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mZmZmZmZmZmZmZ ddlmZ ddlZddlZddlmZ dd	lmZmZmZm Z  dd
l!m"Z" ddl#m$Z$m%Z%m&Z&m'Z' ddl(m)Z)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? dZ@ ejA        eB          ZCerddlDmEZE ddlFmGZG ddlHmIZI ddlJmKZK ddlLmMZM ddl!mNZN ddlOmPZP ddl1mQZQ ddlRmSZS ddlTmUZU ddl9mVZV dd lWmXZX dd!lYmZZZm[Z[m\Z\ dd"l]m^Z^ ddl_Z_dd#l`maZbmcZd dd
lem"Zf dd$lgm*ZhmiZj dd%lkmlZm ddlnm0Zo dd&lpmqZq dd'lrmsZt  ed(eu)          ZveePd*f         Zwejx        Zxd+eyd,<    G d- d.          Zz G d/ d0          Z{dcddd7Z|exd8exexexexexexexexdexd9dedQZ} edR e{            S          Z~dTeydU<    G dV dWe8          Z G dX dYe8          Z G dZ d[          Z G d\ d*          Z G d] d^e"          Z G d_ d`e8          Z G da dbe          ZadS )fa:  
The MIT License (MIT)

Copyright (c) 2015-present Rapptz

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )annotationsN)quote)AnyDictListLiteralOptionalTYPE_CHECKINGSequenceTupleUnionTypeVarTypeoverload)
ContextVar   )utils)HTTPException	ForbiddenNotFoundDiscordServerError)Message)try_enumWebhookTypeChannelTypeDefaultAvatar)BaseUserUser)MessageFlags)Asset)PartialEmoji)Routehandle_message_parametersMultipartParameters
HTTPClientjson_or_text)Hashable)TextChannelForumChannelPartialMessageableForumTag)File)WebhookWebhookMessagePartialWebhookChannelPartialWebhookGuild)Self)TracebackType)Embed)Client)AllowedMentions)
Attachment)ConnectionState)Response)Guild)Emoji)VoiceChannel)	Snowflake)BaseViewView
LayoutView)Poll)r-   SourceGuild)r   PartialUser)PartialChannel)SnowflakeList)InteractionCallbackBE)bound_WebhookStater   MISSINGc                  .    e Zd ZddZddZdd
ZddZdS )AsyncDeferredLocklockasyncio.Lockc                "    || _         d | _        d S N)rL   delta)selfrL   s     W/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/discord/webhook/async_.py__init__zAsyncDeferredLock.__init__h   s    	&*


    returnr1   c                H   K   | j                                          d {V  | S rO   )rL   acquirerQ   s    rR   
__aenter__zAsyncDeferredLock.__aenter__l   s1      i!!!!!!!!!rT   rP   floatNonec                    || _         d S rO   )rP   )rQ   rP   s     rR   delay_byzAsyncDeferredLock.delay_byp   s    


rT   exc_typeOptional[Type[BE]]excOptional[BE]	tracebackOptional[TracebackType]c                   K   | j         rt          j        | j                    d {V  | j                                         d S rO   )rP   asynciosleeprL   release)rQ   r^   r`   rb   s       rR   	__aexit__zAsyncDeferredLock.__aexit__s   sP       : 	,-
+++++++++	rT   N)rL   rM   rU   r1   )rP   rZ   rU   r[   )r^   r_   r`   ra   rb   rc   rU   r[   )__name__
__module____qualname__rS   rY   r]   rh    rT   rR   rK   rK   g   sd        + + + +           rT   rK   c            	      :   e Zd Zd ZddddddddddAdZddddddBdZdddddCd ZdddddDd#ZdddddDd$Zddddddd%d%d&dEd-Z	dddd.dFd1Z
ddddddd%d2dGd3Zdddd.dHd4Zddd5dId6Zddd5dId7Zddd5dJd;Zddd5dKd=Zdddddd>dLd?Zddd5dMd@ZdS )NAsyncWebhookAdapterc                6    t          j                    | _        d S rO   )weakrefWeakValueDictionary_locksrX   s    rR   rS   zAsyncWebhookAdapter.__init__   s    FMFaFcFcrT   N)payload	multipartproxy
proxy_authfilesreason
auth_tokenparamsrouter"   sessionaiohttp.ClientSessionrt   Optional[Dict[str, Any]]ru   Optional[List[Dict[str, Any]]]rv   Optional[str]rw   Optional[aiohttp.BasicAuth]rx   Optional[Sequence[File]]ry   rz   r{   rU   r   c                 K   i }|pg }d }|j         |j        f}	 | j        |         }n-# t          $ r  t	          j                    x| j        |<   }Y nw xY w|d|d<   t          j        |          }|	d|	 |d<   |t          |d          |d<   d }d }|j	        }|j
        }|j         }t          |          4 d {V }t          d          D ]}|D ]}|                    |	           |r)t          j        d
          }|D ]} |j        di | |}	 |                    |||||
||          4 d {V 	 }t$                              d||||j                   t+          |           d {V }|j                            d          }|dk    rP|j        dk    rEt          j        |          }t$                              d||           |                    |           d|j        cxk    rdk    r+n n(|cd d d           d {V  c cd d d           d {V  S |j        dk    r~|j                            d          st5          ||          d}|d         }t$                              |||           t	          j        |           d {V  	 d d d           d {V  |j        dk    r4t	          j        d|dz  z              d {V  	 d d d           d {V  |j        dk    rt;          ||          |j        dk    rt=          ||          t5          ||          # 1 d {V swxY w Y   t# t>          $ r;}|dk     r/|j         dv r&t	          j        d|dz  z              d {V  Y d }~ d }~ww xY w|r+|j        dk    rtC          ||          t5          ||          tE          d          # 1 d {V swxY w Y   d S ) 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X-Ratelimit-Remaining0i  z>Webhook ID %s has exhausted its rate limit bucket (retry: %s).i,     Viaz8Webhook ID %s is rate limited. Retrying in %.2f seconds.retry_afteri     r   i  i     )6   iF'  z"Unreachable code in HTTP handling.rm   )#
webhook_idwebhook_tokenrs   KeyErrorre   Lockr   _to_jsonurlquotemethodurlrK   rangeresetaiohttpFormData	add_fieldrequest_logdebugstatusr&   r   get_parse_ratelimit_headerr]   r   warningrf   r   r   OSErrorerrnor   RuntimeError)rQ   r|   r}   rt   ru   rv   rw   rx   ry   rz   r{   r   to_sendbucketrL   responser   r   r   r   attemptfile	form_datap	remainingrP   fmtr   es                                rR   r   zAsyncWebhookAdapter.request   s      #%:>"E$78	8;v&DD 	8 	8 	8)07DK$$$	8 &8GN#nW--G!':j':':GO$,4V$,G,G,GG()5959i%
$T** E	E E	E E	E E	E E	E E	E E	Ed 88 = =! - -DJJGJ,,,, ( ' 0e D D DI& 1 1+	+00a0000'G3&'76Y^ku  /     ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@!

R&"$O   &2(%;%;;;;;;;$,$4$8$89P$Q$Q	$++30F0F$)$A($K$KE JJ ` * %  
 !MM%0007777C77777#'/,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	EJ $?c11#+#3#7#7#>#> D&3Hd&C&C C"\C15m1DK LLj+FFF")-"<"<<<<<<<<$C,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@F $?c11")-GaK"@"@@@@@@@@$K,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@N $?c11"+Hd";";;%_33"*8T":"::"/$"?"??Y,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@ ,@\    {{qw+'='=%mA!O<<<<<<<<< 	  4?c)),Xt<<<#Hd333CDDDKE	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	E E	Es   ( 'AA>AO"M;B?L/:MO!A6L/M(O*,L/M'O)AL//
L99M<L9=M O
N/N;ONN?O
OO)tokenrv   rw   ry   r   intr   Response[None]c               \    t          dd|          }|                     ||||||          S )NDELETE/webhooks/{webhook_id}r   )r}   rv   rw   ry   rz   r"   r   rQ   r   r   r}   rv   rw   ry   r|   s           rR   delete_webhookz"AsyncWebhookAdapter.delete_webhook   s9     h 8ZPPP||E7%J_erw|xxxrT   )rv   rw   ry   strc               \    t          dd||          }|                     |||||          S )Nr   &/webhooks/{webhook_id}/{webhook_token}r   r   r}   rv   rw   ry   r   r   s           rR   delete_webhook_with_tokenz-AsyncWebhookAdapter.delete_webhook_with_token   s:     h HU_otuuu||E7%J_e|fffrT   Dict[str, Any]Response[WebhookPayload]c          	     ^    t          dd|          }|                     |||||||          S )NPATCHr   r   )r}   rv   rw   ry   rt   rz   r   	rQ   r   r   rt   r}   rv   rw   ry   r|   s	            rR   edit_webhookz AsyncWebhookAdapter.edit_webhook  sI     g7JOOO||!  
 
 	
rT   c               ^    t          dd||          }|                     ||||||          S )Nr   r   r   )r}   rv   rw   ry   rt   r   r   s	            rR   edit_webhook_with_tokenz+AsyncWebhookAdapter.edit_webhook_with_token!  s=     gGT^nsttt||E7%J_eov|wwwrT   F)rv   rw   rt   ru   rx   	thread_idwaitwith_componentsr   Optional[int]r   boolr   "Response[Optional[MessagePayload]]c       	   
         t          |
          t          |          d}|	r|	|d<   t          dd||          }|                     ||||||||          S )N)r   r   r   POSTr   r   r}   rv   rw   rt   ru   rx   r{   )r   r"   r   )rQ   r   r   r}   rv   rw   rt   ru   rx   r   r   r   r{   r|   s                 rR   execute_webhookz#AsyncWebhookAdapter.execute_webhook/  s}     d))O8L8LMM 	,"+F;fFS]mrsss||!  	
 	
 		
rT   )rv   rw   r   
message_idResponse[MessagePayload]c               n    t          dd|||          }|d nd|i}	|                     |||||	          S )NGET</webhooks/{webhook_id}/{webhook_token}/messages/{message_id}r   r   r   r   r}   rv   rw   r{   r   
rQ   r   r   r   r}   rv   rw   r   r|   r{   s
             rR   get_webhook_messagez'AsyncWebhookAdapter.get_webhook_messageM  sY     J!!
 
 
 #*i0H||E7%J_e|fffrT   )rv   rw   rt   ru   rx   r   r   c          
         t          dd|||          }dt          |          i}|
r|
|d<   |                     |||||||	|          S )Nr   r   r   r   r   r   )r"   r   r   )rQ   r   r   r   r}   rv   rw   rt   ru   rx   r   r   r|   r{   s                 rR   edit_webhook_messagez(AsyncWebhookAdapter.edit_webhook_messageb  s     J!!
 
 
 $S%9%9: 	,"+F;||!  	
 	
 		
rT   c               n    t          dd|||          }|d nd|i}	|                     |||||	          S )Nr   r   r   r   r   r   r   s
             rR   delete_webhook_messagez*AsyncWebhookAdapter.delete_webhook_message  sY     J!!
 
 
 #*i0H||E7%J_e|fffrT   )rv   rw   c               Z    t          dd|          }|                     |||||          S )Nr   r   r   )r}   rv   rw   rz   r   rQ   r   r   r}   rv   rw   r|   s          rR   fetch_webhookz!AsyncWebhookAdapter.fetch_webhook  s6     e5*MMM||E7%Jch|iiirT   c               Z    t          dd||          }|                     ||||          S )Nr   r   r   r}   rv   rw   r   r   s          rR   fetch_webhook_with_tokenz,AsyncWebhookAdapter.fetch_webhook_with_token  s7     eER\lqrrr||E7%J|WWWrT   interaction_idr$   ,Response[InteractionCallbackResponsePayload]c          	         t          dd||          }ddi}|j        r&|                     |||||j        |j        |          S |                     |||||j        |          S )Nr   z3/interactions/{webhook_id}/{webhook_token}/callbackr   with_response1)r}   rv   rw   rx   ru   r{   )r}   rv   rw   rt   r{   )r"   rx   r   ru   rt   )	rQ   r   r   r}   rv   rw   r{   r|   request_paramss	            rR   create_interaction_responsez/AsyncWebhookAdapter.create_interaction_response  s     A%	
 
 
 *3/< 	<<%l *%      <<%%     rT   application_idc               Z    t          dd||          }|                     ||||          S )Nr   9/webhooks/{webhook_id}/{webhook_token}/messages/@originalr   r   r   rQ   r   r   r}   rv   rw   rs          rR   !get_original_interaction_responsez5AsyncWebhookAdapter.get_original_interaction_response  s@     G%	
 
 
 ||Awe
|SSSrT   )rv   rw   rt   ru   rx   c          	     `    t          dd||          }	|                     |	||||||          S )Nr   r   r   )r}   rv   rw   rt   ru   rx   r   )
rQ   r   r   r}   rv   rw   rt   ru   rx   r   s
             rR   "edit_original_interaction_responsez6AsyncWebhookAdapter.edit_original_interaction_response  sV     G%	
 
 
 ||!  
 
 	
rT   c               Z    t          dd||          }|                     ||||          S )Nr   r   r   r   r   r   s          rR   $delete_original_interaction_responsez8AsyncWebhookAdapter.delete_original_interaction_response  s@     G%	
 
 
 ||Awe
|SSSrT   )r|   r"   r}   r~   rt   r   ru   r   rv   r   rw   r   rx   r   ry   r   rz   r   r{   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   ry   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   ry   r   rU   r   )r   r   r   r   rt   r   r}   r~   rv   r   rw   r   ry   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   rt   r   ru   r   rx   r   r   r   r   r   r   r   rU   r   )r   r   r   r   r   r   r}   r~   rv   r   rw   r   r   r   rU   r   )r   r   r   r   r   r   r}   r~   rv   r   rw   r   rt   r   ru   r   rx   r   r   r   r   r   rU   r   )r   r   r   r   r   r   r}   r~   rv   r   rw   r   r   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   r{   r$   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   rt   r   ru   r   rx   r   rU   r   )r   r   r   r   r}   r~   rv   r   rw   r   rU   r   )rj   rk   rl   rS   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rm   rT   rR   ro   ro   ~   s       d d d -148#26*. $$(+/mE mE mE mE mE mEf  $#26 $y y y y y y&  $26 $g g g g g g(  $26 $
 
 
 
 
 
:  $26 $x x x x x x(  $26,048*.#' %
 
 
 
 
 
J  $26#'g g g g g g8  $26,048*.#' %"
 "
 "
 "
 "
 "
V  $26#'g g g g g g6  $26
j 
j 
j 
j 
j 
j$  $26
X 
X 
X 
X 
X 
X$  $26$ $ $ $ $ $X  $26T T T T T T.  $26,048*.
 
 
 
 
 
D  $26T T T T T T T TrT   ro   typer   r   r   rU   r$   c                <    d| i}|||d<   t          |d d           S )Nr   r   rt   ru   rx   )r$   )r   r   rt   s      rR   interaction_response_paramsr     s4    G w$dKKKKrT   F)contentttsflagsr   rx   embedembedsattachmentsviewallowed_mentionsprevious_allowed_mentionspollr   r   r   r   r   r   r   r,   rx   Sequence[File]r  Optional[Embed]r  Sequence[Embed]r  !Sequence[Union[Attachment, File]]r  Optional[BaseView]r  Optional[AllowedMentions]r  r  r@   c                   |t           ur|t           urt          d          |t           ur|t           urt          d          |t           ur|g}|t           ur|t           urt          d          d|i}|t           ur1t          |          dk    rt          d          d |D             |d<   |t           ur |g |d<   n|                                g|d<   |t           ur|t          |          |d	<   nd |d	<   |	t           urT|	M|	                                |d
<   |	                                r!|t           urd|_        nt          d          }ng |d
<   |t           ur
|j
        |d<   |
rE|+|                    |
                                          |d<   n1|
                                |d<   n||                                |d<   |t           u r|}nd |D             }|t           urxd}g }|D ]l}t          |t                    r.|                    |                    |                     |dz  }E|                    |                                           m||d<   |t           ur|                                |d<   g }|ro| |d}|                    dt!          j        |          d           d }t%          |          D ]-\  }}|                    d| d|j        |j        dd           .n| |d}t+          |||          S )Nz,Cannot mix file and files keyword arguments.z.Cannot mix embed and embeds keyword arguments.z3Cannot mix attachments and files keyword arguments.r   
   z$embeds has a maximum of 10 elements.c                6    g | ]}|                                 S rm   )to_dict).0r   s     rR   
<listcomp>z7interaction_message_response_params.<locals>.<listcomp>E  s     666!!))++666rT   r  r   
componentsT)components_v2r   r  c                <    g | ]}t          |t                    |S rm   )
isinstancer,   )r  as     rR   r  z7interaction_message_response_params.<locals>.<listcomp>n  s'    ???q:a+>+>????rT   r   r   r  r  )r   r   payload_json)namevaluezfiles[]zapplication/octet-stream)r  r  filenamecontent_typer   )rI   	TypeErrorlen
ValueErrorr  r   to_componentshas_components_v2r  r   r  merger  r,   append_to_dictr   r   	enumeratefpr  r$   )r   r   r   r   r   rx   r  r  r  r  r  r  r  r   
file_indexattachments_payload
attachmentru   indexs                      rR   #interaction_message_response_paramsr-  #  s     GG 3 3FGGGWg!5!5HIII7'!!e7&:&:MNNN 	s&D Wv;;CDDD66v666XG=DNN#mmoo.DNg!'llDOO"DO7!%!3!3!5!5D%%'' =''*.E''(t<<<E "$DGW G$0'@'F'FGW'X'X'`'`'b'bD#$$'7'?'?'A'AD#$$	"	.#<#D#D#F#F g??K???'!!
 % 	A 	AJ*d++ A#**:+=+=j+I+IJJJa

#**:+=+=+?+?@@@@1]7}}VI ,d++.5>$;O;OPPQQQ$U++ 	 	KE4-U---!W $$>	    	 d++tyNNNNrT   async_webhook_context)defaultzContextVar[AsyncWebhookAdapter]async_contextc                  >    e Zd ZdZdZddZdd	Zedd
            ZdS )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.
    )idr  r   PartialChannelPayloadrU   r[   c               T    t          |d                   | _        |d         | _        d S )Nr2  r  )r   r2  r  rQ   r   s     rR   rS   zPartialWebhookChannel.__init__  s"    4:f			rT   r   c                (    d| j         d| j         dS )Nz<PartialWebhookChannel name= id=>r  r2  rX   s    rR   __repr__zPartialWebhookChannel.__repr__  s    IdiIItwIIIIrT   c                    d| j          dS )z^:class:`str`: The string that allows you to mention the channel that the webhook is following.z<#r8  r2  rX   s    rR   mentionzPartialWebhookChannel.mention  s     DGrT   N)r   r3  rU   r[   rU   r   )	rj   rk   rl   __doc__	__slots__rS   r:  propertyr=  rm   rT   rR   r/   r/     sq          I& & & &J J J J    X  rT   r/   c                  >    e Zd ZdZdZdd	ZddZedd            ZdS )r0   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.
    )r2  r  _icon_stater   SourceGuildPayloadstate_StaterU   r[   c               |    || _         t          |d                   | _        |d         | _        |d         | _        d S )Nr2  r  icon)rD  r   r2  r  rC  )rQ   r   rF  s      rR   rS   zPartialWebhookGuild.__init__  s4    #4:f	v,


rT   r   c                (    d| j         d| j         dS )Nz<PartialWebhookGuild name=r7  r8  r9  rX   s    rR   r:  zPartialWebhookGuild.__repr__  s    GDIGGTWGGGGrT   Optional[Asset]c                ^    | j         dS t          j        | j        | j        | j                   S )zGOptional[:class:`Asset`]: Returns the guild's icon asset, if available.N)rC  r    _from_guild_iconrD  r2  rX   s    rR   rI  zPartialWebhookGuild.icon  s,     :4%dk47DJGGGrT   N)r   rE  rF  rG  rU   r[   r>  rU   rK  )	rj   rk   rl   r?  r@  rS   r:  rA  rI  rm   rT   rR   r0   r0     sw          2I' ' ' 'H H H H H H H XH H HrT   r0   c                      e Zd ZdZddZdS )	!_FriendlyHttpAttributeErrorHelperrm   attrr   rU   r   c                     t          d          )Nz2PartialWebhookState does not support http methods.)AttributeErrorrQ   rQ  s     rR   __getattr__z-_FriendlyHttpAttributeErrorHelper.__getattr__  s    QRRRrT   NrQ  r   rU   r   )rj   rk   rl   r@  rU  rm   rT   rR   rP  rP    s3        IS S S S S SrT   rP  c                  |    e Zd ZdZefd"dZd#dZddd$dZd%dZe	d&d            Z
d'dZe	d(d            Zd)d Zd!S )*rH   )_parent_webhook_threadwebhookr   parentOptional[_State]threadr<   c                n    || _         |  t          |t                    rd | _        n|| _        || _        d S rO   )rY  r  rH   rX  rZ  )rQ   r[  r\  r^  s       rR   rS   z_WebhookState.__init__  s<    $/fm,, 	"DLL!DL"(rT   guild_idr   rU   Optional[Guild]c                H    | j         | j                             |          S d S rO   )rX  
_get_guild)rQ   r`  s     rR   rc  z_WebhookState._get_guild  s%    <#<**8444trT   Tcacher   &Union[UserPayload, PartialUserPayload]re  r   r   c               j    | j         | j                             ||          S t          | |          S )Nrd  rF  r   )rX  
store_userr   )rQ   r   re  s      rR   ri  z_WebhookState.store_user  s8    <#<**4u*===d....rT   c                $    t          | |          S )Nrh  )r   r5  s     rR   create_userz_WebhookState.create_user  s    d....rT   r  c                    d S rO   rm   rX   s    rR   r  z_WebhookState.allowed_mentions  s    trT   PartialEmojiPayloadUnion[PartialEmoji, Emoji, str]c                    | j         | j                             |          S t          j        |d          }|s|d         S t	          |                    dd          ||d                   S )Nr2  r  animatedF)rp  r2  r  )rX  get_emoji_from_partial_payloadr   _get_as_snowflaker!   r   )rQ   r   emoji_ids      rR   get_reaction_emojiz _WebhookState.get_reaction_emoji  sn    <#<>>tDDD*466 	 <TXXj%%@%@XTXY_T`aaaarT   4Union[HTTPClient, _FriendlyHttpAttributeErrorHelper]c                D    | j         | j         j        S t                      S rO   )rX  httprP  rX   s    rR   rw  z_WebhookState.http
  s#    <#<$$ 1222rT   rQ  r   c                `    | j         t          | j         |          S t          d|d          )Nz%PartialWebhookState does not support .)rX  getattrrS  rT  s     rR   rU  z_WebhookState.__getattr__  s6    <#4<...NTNNNOOOrT   N)r[  r   r\  r]  r^  r<   )r`  r   rU   ra  )r   rf  re  r   rU   r   )r   rf  rU   r   )rU   r  )r   rm  rU   rn  )rU   ru  rV  )rj   rk   rl   r@  rI   rS   rc  ri  rk  rA  r  rt  rw  rU  rm   rT   rR   rH   rH     s        2ISZ 	) 	) 	) 	) 	)   
 Y] / / / / / // / / /    X
b 
b 
b 
b 3 3 3 X3P P P P P PrT   c                  T    e Zd ZU dZded<   eeeeeddddZddZd dZddd!dZ	dS )"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
    rH   rD  N)r   r  r  r  r  r  r   r   r  r
  r  r	  r  r  r  r  r  r  rU   c          
     ~   K   | j         j                            | j        ||||||| j         j                   d{V S )a	  |coro|

        Edits the message.

        .. versionadded:: 1.6

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

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        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.
        attachments: List[Union[:class:`Attachment`, :class:`File`]]
            A list of attachments to keep in the message as well as new files to upload. If ``[]`` is passed
            then all attachments are removed.

            .. note::

                New files will always appear after current attachments.

            .. 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. If the webhook is partial or is not managed by the
            library, then you can not send interactable components. Otherwise, you
            can send views with any type of components.

            .. note::

                To update the message to add a :class:`~discord.ui.LayoutView`, you
                must explicitly set the ``content``, ``embed``, ``embeds``, and
                ``attachments`` parameters to either ``None`` or an empty array, as appropriate.

            .. versionadded:: 2.0

        Raises
        -------
        HTTPException
            Editing the message failed.
        Forbidden
            Edited a message that is not yours.
        TypeError
            You specified both ``embed`` and ``embeds``
        ValueError
            The length of ``embeds`` was invalid or
            there was no token associated with this webhook.

        Returns
        --------
        :class:`WebhookMessage`
            The newly edited message.
        r   r  r  r  r  r  r^  N)rD  rY  edit_messager2  rZ  )rQ   r   r  r  r  r  r  s          rR   editzWebhookMessage.edit(  sh      V [)66G#-;& 7 	
 	
 	
 	
 	
 	
 	
 	
 		
rT   rx   r,   c                P   K   |                      g | j        |           d{V S )a  |coro|

        Adds new files to the end of the message attachments.

        .. versionadded:: 2.0

        Parameters
        -----------
        \*files: :class:`File`
            New files to add to the message.

        Raises
        -------
        HTTPException
            Editing the message failed.
        Forbidden
            Tried to edit a message that isn't yours.

        Returns
        --------
        :class:`WebhookMessage`
            The newly edited message.
        r  Nr  r  )rQ   rx   s     rR   	add_fileszWebhookMessage.add_files~  s<      0 YY+FT-=+F+FYGGGGGGGGGrT   r6   c                b   K   |                      fd| j        D                        d{V S )a  |coro|

        Removes attachments from the message.

        .. versionadded:: 2.0

        Parameters
        -----------
        \*attachments: :class:`Attachment`
            Attachments to remove from the message.

        Raises
        -------
        HTTPException
            Editing the message failed.
        Forbidden
            Tried to edit a message that isn't yours.

        Returns
        --------
        :class:`WebhookMessage`
            The newly edited message.
        c                    g | ]}|v|	S rm   rm   )r  r  r  s     rR   r  z5WebhookMessage.remove_attachments.<locals>.<listcomp>  s$    +`+`+`!1T_K_K_AK_K_K_rT   r  Nr  )rQ   r  s    `rR   remove_attachmentsz!WebhookMessage.remove_attachments  sG      0 YY+`+`+`+`t7G+`+`+`YaaaaaaaaarT   )delayr  Optional[float]r[   c                   K   |&|fd fd}t          j         |                       dS  j        j                             j         j        j                   d{V  dS )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  rZ   c                   K   t          j        |            d {V  	 j        j                            j        j        j                   d {V  d S # t          $ r Y d S w xY w)Nr^  )re   rf   rD  rY  delete_messager2  rZ  r   )r  rQ   s    rR   
inner_callz)WebhookMessage.delete.<locals>.inner_call  s      mE*********+.==dgdkNa=bbbbbbbbbbb$   DDs   6A 
A%$A%r  )r  rZ   )re   create_taskrD  rY  r  r2  rZ  )rQ   r  r  s   `  rR   deletezWebhookMessage.delete  s      * 05        

-----+&55dgdkFY5ZZZZZZZZZZZrT   )r   r   r  r
  r  r	  r  r  r  r  r  r  rU   r.   )rx   r,   rU   r.   )r  r6   rU   r.   )r  r  rU   r[   )
rj   rk   rl   r?  __annotations__rI   r  r  r  r  rm   rT   rR   r.   r.     s         	 	 
 ")")!(9@#*6:T
 T
 T
 T
 T
 T
lH H H H4b b b b4 8<  [  [  [  [  [  [  [  [rT   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e	d%d            Ze	d%d            ZdS )&BaseWebhook)r2  r   r`  
channel_idr   rz   userr  _avatarsource_channelsource_guildrD  Tuple[str, ...]r@  Nr   WebhookPayloadr   r   rF  r]  rU   r[   c                n    || _         |pt          | |          | _        |                     |           d S )N)r\  )rz   rH   rD  _update)rQ   r   r   rF  s       rR   rS   zBaseWebhook.__init__  s<     */#H}T%'H'H'HTrT   c                   t          |d                   | _        t          t          t          |d                             | _        t          j        |d          | _        t          j        |d          | _        |	                    d          | _
        |	                    d          | _        |	                    d          | _        |	                    d          }d | _        |t          | j        |	          | _        |	                    d
          }|rt!          |          }|| _        |	                    d          }|rt%          || j                  }|| _        d S )Nr2  r   r  r`  r  avatarr   r  rh  r  )r   r  )r   rF  )r   r2  r   r   r   r   rr  r  r`  r   r  r  r   r  r   rD  r/   r  r0   r  )rQ   r   r  r  r  s        rR   r  zBaseWebhook._update  s4   4:!)+s4<7H7H!I!I	).)@|)T)T','>tZ'P'P#'88F#3#3	&*hhx&8&8$(HHW$5$5
xx59	4;T:::DI"233 	H2GGGN?Mxx// 	U.LTTTL;GrT   r   c                    | j         du S )zY:class:`bool`: Whether the webhook is a "partial" webhook.

        .. versionadded:: 2.0N)r  rX   s    rR   
is_partialzBaseWebhook.is_partial
  s     $&&rT   c                    | j         duS )zm:class:`bool`: Whether the webhook is authenticated with a bot token.

        .. versionadded:: 2.0
        N)rz   rX   s    rR   is_authenticatedzBaseWebhook.is_authenticated  s    
 d**rT   ra  c                N    | j         o| j                             | j                  S )zOptional[:class:`Guild`]: The guild this webhook belongs to.

        If this is a partial webhook, then this will always return ``None``.
        )rD  rc  r`  rX   s    rR   guildzBaseWebhook.guild  s#     {Dt{55dmDDDrT   8Optional[Union[ForumChannel, VoiceChannel, TextChannel]]c                H    | j         }|o|                    | j                  S )zOptional[Union[:class:`ForumChannel`, :class:`VoiceChannel`, :class:`TextChannel`]]: The channel this webhook belongs to.

        If this is a partial webhook, then this will always return ``None``.
        )r  get_channelr  )rQ   r  s     rR   channelzBaseWebhook.channel  s&     
;**4?;;;rT   datetime.datetimec                4    t          j        | j                  S )zG:class:`datetime.datetime`: Returns the webhook's creation time in UTC.)r   snowflake_timer2  rX   s    rR   
created_atzBaseWebhook.created_at(  s     #DG,,,rT   rK  c                ^    | j         %t          j        | j        | j        | j                   S dS )a  Optional[:class:`Asset`]: Returns an :class:`Asset` for the avatar the webhook has.

        If the webhook does not have a traditional avatar, ``None`` is returned.
        If you want the avatar that a webhook has displayed, consider :attr:`display_avatar`.
        N)r  r    _from_avatarrD  r2  rX   s    rR   r  zBaseWebhook.avatar-  s,     <#%dk47DLIIItrT   r    c                p    t          j        | j        | j        dz	  t	          t
                    z            S )z\
        :class:`Asset`: Returns the default avatar.

        .. versionadded:: 2.0
           )r    _from_default_avatarrD  r2  r   r   rX   s    rR   default_avatarzBaseWebhook.default_avatar8  s,     )$+2]I[I[7[\\\rT   c                    | j         p| j        S )z:class:`Asset`: Returns the webhook's display avatar.

        This is either webhook's default avatar or uploaded avatar.

        .. versionadded:: 2.0
        )r  r  rX   s    rR   display_avatarzBaseWebhook.display_avatarA  s     {1d11rT   )NN)r   r  r   r   rF  r]  rU   r[   )r   r  rU   r[   )rU   r   )rU   ra  )rU   r  )rU   r  rN  )rU   r    )rj   rk   rl   r@  r  rS   r  r  r  rA  r  r  r  r  r  r  rm   rT   rR   r  r    sZ        "I    $  $"&	    H H H H6' ' ' '+ + + + E E E XE < < < X< - - - X-    X ] ] ] X] 2 2 2 X2 2 2rT   r  c                      e Zd ZU dZdZded<   	 	 	 	 dpdq fdZdrdZedrd            Z	e
eedddsd            Ze
eedddtd             Ze
dud!            Ze
dvd#            Zd$d%dwd(Zdd$d)dxd+Zdeedd$d,dyd2Zdzd5Zeeeeeeeeeeeed6d{dK            ZeeeeeeedLeeeeedMd|dO            ZeefeeeeeeeeeeeeeeeedPd}dZ            ZeefeeeeeeeeeeeedLeeeed[d~d\            Zefeed]d]eeeeeeeed]d]d]eed[dd`ZedaddbZedLdLdLdcddh            ZedLdLdLdLdLdLdLdiddl            ZeeeeedediddnZedaddoZ xZS )r-   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`,
    :meth:`.TextChannel.webhooks`, :meth:`.VoiceChannel.webhooks`
    and :meth:`.ForumChannel.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 webhooks'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   r  r@  Nr   r  r}   r~   r   r   rF  r]  rv   rw   r   rU   r[   c                x    t                                          |||           || _        || _        || _        d S rO   )superrS   r}   rv   rw   )rQ   r   r}   r   rF  rv   rw   	__class__s          rR   rS   zWebhook.__init__  s:     	ue,,,.5$)
7ArT   r   c                8    d| j         d| j        d| j        dS )Nz<Webhook id=z type=z name=r8  )r2  r   r  rX   s    rR   r:  zWebhook.__repr__  s)    PdgPPtyPP$)PPPPrT   c                &    d| j          d| j         S )z):class:`str` : Returns the webhook's url.z!https://discord.com/api/webhooks//)r2  r   rX   s    rR   r   zWebhook.url  s     J47IITZIIIrT   )r}   client	bot_tokenr2  r   r  r4   r  r1   c                   |d|d}d}|t           ur|j        }|t           u r|j        j        }|t           u rt	          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
        client: :class:`Client`
            The client to initialise this webhook with. This allows it to
            attach the client's internal state. If ``session`` is not given
            while this is given then the client's internal session will be used.

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

            .. versionadded:: 2.0

        Raises
        -------
        TypeError
            Neither ``session`` nor ``client`` were given.

        Returns
        --------
        :class:`Webhook`
            A partial :class:`Webhook`.
            A partial webhook is just a webhook object with an ID and a token.
        r   )r2  r   r   Nsession or client must be givenr   rF  )rI   _connectionrw  _HTTPClient__sessionr  )clsr2  r   r}   r  r  r   rF  s           rR   partialzWebhook.partial  s|    `  
  
   &E'!! +:g=>>>s4	????rT   r   c                  t          j        d|          }|t          d          d}|t          ur|j        }|t          u r|j        j        }|t          u rt          d          |                                }d|d<    | ||||          S )aH  Creates a partial :class:`Webhook` from a webhook URL.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        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
        client: :class:`Client`
            The client to initialise this webhook with. This allows it to
            attach the client's internal state. If ``session`` is not given
            while this is given then the client's internal session will be used.

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

            .. versionadded:: 2.0

        Raises
        -------
        ValueError
            The URL is invalid.
        TypeError
            Neither ``session`` nor ``client`` were given.

        Returns
        --------
        :class:`Webhook`
            A partial :class:`Webhook`.
            A partial webhook is just a webhook object with an ID and a token.
        zXdiscord(?:app)?\.com/api/webhooks/(?P<id>[0-9]{17,20})/(?P<token>[A-Za-z0-9\.\-\_]{60,})NzInvalid webhook URL given.r  r   r   r  )	researchr!  rI   r  rw  r  r  	groupdict)r  r   r}   r  r  mrF  r   s           rR   from_urlzWebhook.from_url  s    d Iqsvww99:::  &E'!! +:g=>>> {{}}Vs4	????rT   c                  |j          d| }|d         d||j        |j         j        |j        |j        |j        |j        |j        |j        dd}|j        }|j        }|j	        }|j
        }	|j        }
 | ||||	|
|j        j                  S )Nz #r   r   )usernamediscriminatorr2  r  avatar_decoration_dataglobal_name)r2  r   r  r  r`  r  r}   rF  rw   rv   r   )r  r2  r  r  r  _avatar_decoration_datar  rD  rw  r  rw   rv   r   )r  r   r  r  r  feedrF  rw  r}   rw   rv   s              rR   _as_followerzWebhook._as_follower8  s    -,,7,,|$!*( I!%!3g,*.*F#/  
  
  z+_

s4*TYafakaqrrrrrT   r7   c                p    |j         }|j        }|j        }|j        } | ||||||j         j                  S )Nr  )rw  r  rw   rv   r   )r  r   rF  rw  r}   rw   rv   s          rR   
from_statezWebhook.from_stateR  sD    z+_

s4*TYafakaqrrrrrT   T)prefer_authr  r   c                 K   t                                           }|rA| j        r:|                    | j        | j        | j        | j        | j                   d{V }nP| j        r:|	                    | j        | j        | j        | j        | j                   d{V }nt          d          t          || j        | j        | j        | j        | j                  S )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``.

        Raises
        -------
        HTTPException
            Could not fetch the webhook
        NotFound
            Could not find the webhook by this ID
        ValueError
            This webhook does not have a token associated with it.

        Returns
        --------
        :class:`Webhook`
            The fetched webhook.
        r   N5This webhook does not have a token associated with itr}   rv   rw   r   rF  )r0  r   rz   r   r2  r}   rv   rw   r   r   r!  r-   rD  )rQ   r  adapterr   s       rR   fetchzWebhook.fetchZ  s$     F  ##%% 	V4? 	V ..j? /        DD Z 		V 99
j? :        DD TUUUL*/+
 
 
 	
rT   )ry   r  ry   c                 K   | j         | j        t          d          t                                          }|rC| j        r<|                    | j        | j        | j        | j        | j	        |           d{V  dS | j         r<|
                    | j        | j         | j        | j        | j	        |           d{V  dS dS )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.
        ValueError
            This webhook does not have a token associated with it.
        Nr  )r   r}   rv   rw   ry   r   )r   rz   r!  r0  r   r   r2  r}   rv   rw   r   )rQ   ry   r  r  s       rR   r  zWebhook.delete  s      8 :$/"9TUUU##%% 	4? 	((oj? )            Z 	33
j? 4           	 	rT   )ry   r  r  r  r  r  r  Optional[bytes]r  Optional[Snowflake]c          	     H  K   | j         | j        t          d          i }|t          ur|t	          |          nd|d<   |t          ur|t          j        |          nd|d<   t                                          }d}|\| j        t          d          |j	        |d<   |
                    | j	        | j        || j        | j        | j        |           d{V }n|rC| j        r<|
                    | j	        | j        || j        | j        | j        |           d{V }nB| j         r;|                    | j	        | j         || j        | j        | j        |           d{V }|t          d          t!          || j        | j        | j        | j        | j        	          S )
a  |coro|

        Edits this Webhook.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        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.
        ValueError
            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 webhookr  )rt   r}   rv   rw   ry   z+Unreachable code hit: data was not assignedr  )r   rz   r!  rI   r   r   _bytes_to_base64_datar0  r   r2  r   r}   rv   rw   r   r   r-   rD  )	rQ   ry   r  r  r  r  rt   r  r   s	            rR   r  zWebhook.edit  s*     ^ :$/"9TUUUw+/+;c$iiiGFO  GMGY ;F C C C_cGH##%%)-& !QRRR$+JGL! --j? .        DD  	T_ 	 --j? .        DD Z 		 88
j? 9        D <LMMML*/+
 
 
 	
rT   r^  r<   c               h   t          | | j        |          }|t          u rt          |d                   }| j        }| j        |k    rHt          |t                    rt          j	        n|o|j
        }t          | j        | j        ||          }n| j        pt          | j        | j        |          }nn| j        }t          |t          t          f          r|                    |j                  }|/t          | j        | j        t          |d                             }t!          |||          S )N)r\  r^  r  )rF  r`  r2  r   )rF  r`  r2  )r   rF  r  )rH   rD  rI   r   r  r  r  r)   r   public_threadr   r*   r`  r(   
get_threadr2  r.   )rQ   r   r^  rF  r  r  r   s          rR   _create_messagezWebhook._create_message;  s+   d4;vFFFWT,/00JlG *,,4>w4U4Uu{00\c\thoht,4;[elpqqq,v*<4;Y]Yfku*v*v*vlG'L+#>?? 8!,,VY77,4;[^_cdp_q[r[rsss 4ugFFFFrT   )r  
avatar_url	ephemeralr   rx   r  r^  thread_namesuppress_embedssilentapplied_tagsr  r  r   r  r   r,   rx   r  r  r5   r  r?   r   Literal[True]r  r  r  r  List[ForumTag]r.   c               
   K   d S rO   rm   rQ   r  r  r  r   rx   r  r  r   r^  r  r  r  r  s                 rR   sendzWebhook.sendS  s      " rT   .)r  r  r  r   rx   r  r   r^  r  r  r  r  Literal[False]c               
   K   d S rO   rm   r  s                 rR   r  zWebhook.sendf  s      " srT   )r  r  r   r  r   rx   r  r  r  r  r^  r  r  r  r  r  r   r   r  r3   r  r
  r>   r  r@   c               
   K   d S rO   rm   rQ   r   r  r  r   r  r   rx   r  r  r  r  r^  r  r   r  r  r  r  s                      rR   r  zWebhook.sendy  s      , rT   )r  r  r   r  r   rx   r  r  r  r  r^  r  r   r  r  r  r  c               
   K   d S rO   rm   r  s                      rR   r  zWebhook.send  s      , srT   Fr=   Optional[WebhookMessage]c               r  K   | j         t          d          t          | j        dd          }|t          }|s|s|r*t          j        d          }||_        ||_        ||_	        nt          }| j
        t          j        u }|r|st          d          |rd}|t          urt          |d          st          d|j        j                   t#          | j        t$                    r#|                                rt          d	          |du r"|j        |                                rd
|_        |t          ur|t          urt          d          |t          u rt          }nd |D             }t+          ||||||||	||||
|||          5 }t,                                          }d}|t          ur|j        }|                    | j        | j         | j        | j        | j        |j        |j        |j        |||t          u           d{V }ddd           n# 1 swxY w Y   d}|r|                      ||          }|t          urN|!                                s:|                                r&|dn|j        }| j        "                    ||           |t          ur|r|#                    |           |S )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.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        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: Union[:class:`discord.ui.View`, :class:`discord.ui.LayoutView`]
            The view to send with the message. If the webhook is partial or
            is not managed by the library, then you can not send interactable components.
            Otherwise, you can send views with any type of components.

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

            .. versionadded:: 2.0
        thread_name: :class:`str`
            The thread name to create with this webhook if the webhook belongs
            to a :class:`~discord.ForumChannel`. Note that this is mutually
            exclusive with the ``thread`` parameter, as this will create a
            new thread with the given name.

            .. versionadded:: 2.0
        suppress_embeds: :class:`bool`
            Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.

            .. versionadded:: 2.0
        silent: :class:`bool`
            Whether to suppress push and desktop notifications for the message. This will increment the mention counter
            in the UI, but will not actually send a notification.

            .. versionadded:: 2.2
        applied_tags: List[:class:`ForumTag`]
            Tags to apply to the thread if the webhook belongs to a :class:`~discord.ForumChannel`.

            .. versionadded:: 2.4

        poll: :class:`Poll`
            The poll to send with this message.

            .. warning::

                When sending a Poll via webhook, you cannot manually end it.

            .. versionadded:: 2.4

        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``
            or ``thread`` and ``thread_name``.
        ValueError
            The length of ``embeds`` was invalid, there was no token
            associated with this webhook or ``ephemeral`` was passed
            with the improper webhook type or there was no state
            attached with this webhook when giving it a view that had
            components other than URL buttons.

        Returns
        ---------
        Optional[:class:`WebhookMessage`]
            If ``wait`` is ``True`` then the message that was sent, otherwise ``None``.
        Nr  r  r   z=ephemeral messages can only be sent from application webhooksT__discord_ui_view__>expected view parameter to be of type View or LayoutView, not WWebhook views with interactable components require an associated state with the webhookg      @z4Cannot mix thread_name and thread keyword arguments.c                    g | ]	}|j         
S rm   r<  )r  tags     rR   r  z Webhook.send.<locals>.<listcomp>]  s    -M-M-Mcf-M-M-MrT   )r   r  r  r   r   rx   r  r  r   r  r  r  r  r  r  )	r}   rv   rw   rt   ru   rx   r   r   r   r  )$r   r!  rz  rD  rI   r   _from_valuer  r  suppress_notificationsr   r   applicationhasattrr  r  rj   r  rH   is_dispatchabletimeoutr#   r0  r   r2  r   r}   rv   rw   rt   ru   rx   r  is_finished
store_viewr  )rQ   r   r  r  r   r  r   rx   r  r  r  r  r^  r  r   r  r  r  r  previous_mentionsr   application_webhookapplied_tag_idsr{   r  r   r   msgr   s                                rR   r  zWebhook.send  s|     ^ :TUUU7>t{L^`d7e7e?G 	 	6 	 ,Q//E'EO$3E!+1E((E"i;+BB 	^0 	^\]]] 	Dw4!677 | zaeaoax z z{{{$+}55 |$:N:N:P:P | !z{{{D  T\%9d>R>R>T>T%9(g%%&*?*?RSSS7""%OO-M-M-M-M-MO&!#-&7(
 
 
 "	  #''))G'+IW$$"I	 00
j? *l# $G 3 1        D-"	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	 "	H  	<&&tF&;;Cwt'7'7'9'9d>R>R>T>T!$#&JK""4444w3LL
s   BHH!Hr  c         	     ,  K   | j         t          d          d}|t          ur|j        }t                                          }|                    | j        | j         || j        | j        | j	        |           d{V }| 
                    ||          S )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: :class:`~discord.abc.Snowflake`
            The thread to look in.

        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.
        ValueError
            There was no token associated with this webhook.

        Returns
        --------
        :class:`~discord.WebhookMessage`
            The message asked for.
        Nr  r}   rv   rw   r   r  )r   r!  rI   r2  r0  r   r   r}   rv   rw   r  )rQ   r2  r^  r   r  r   s         rR   fetch_messagezWebhook.fetch_message  s      > :TUUU#'	  	I##%%00GJL* 1 
 
 
 
 
 
 
 
 ##D#888rT   )r  r  r^  r   r  r  r  c               
   K   d S rO   rm   )rQ   r   r  r  r  r^  s         rR   r~  zWebhook.edit_message  s       rT   r}  r	  Optional[View]c               
   K   d S rO   rm   )	rQ   r   r   r  r  r  r  r  r^  s	            rR   r~  zWebhook.edit_message  s       rT   r  c               X  K   | j         t          d          |rit          |d          st          d|j        j                   t          | j        t                    r#|	                                rt          d          t          | j        dd          }	t          |||||||	          5 }
d}|t          ur|j        }t                                          }|                    | j        | j         || j        | j        | j        |
j        |
j        |
j        |t/          |                     d{V }ddd           n# 1 swxY w Y   |                     ||	          }|rC|                                s/|	                                r| j                            ||           |S )
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.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        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[Union[:class:`Attachment`, :class:`File`]]
            A list of attachments to keep in the message as well as new files to upload. 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[Union[:class:`~discord.ui.View`, :class:`~discord.ui.LayoutView`]]
            The updated view to update this message with. If ``None`` is passed then
            the view is removed. If the webhook is partial or is not managed by the
            library, then you can not send interactable components. Otherwise, you
            can send views with any type of components.

            .. note::

                To update the message to add a :class:`~discord.ui.LayoutView`, you
                must explicitly set the ``content``, ``embed``, ``embeds``, and
                ``attachments`` parameters to either ``None`` or an empty array, as appropriate.

            .. versionadded:: 2.0
        thread: :class:`~discord.abc.Snowflake`
            The thread the webhook message belongs to.

            .. versionadded:: 2.0

        Raises
        -------
        HTTPException
            Editing the message failed.
        Forbidden
            Edited a message that is not yours.
        TypeError
            You specified both ``embed`` and ``embeds``
        ValueError
            The length of ``embeds`` was invalid,
            there was no token associated with this webhook or the webhook had
            no state.

        Returns
        --------
        :class:`WebhookMessage`
            The newly edited webhook message.
        Nr  r  r  r  r  )r   r  r  r  r  r  r  )r}   rv   rw   rt   ru   rx   r   r   r  )r   r!  r  r  r  rj   r  rD  rH   r  rz  r#   rI   r2  r0  r   r   r}   rv   rw   rt   ru   rx   r   r  r  r  )rQ   r   r   r  r  r  r  r  r^  r  r{   r   r  r   messages                  rR   r~  zWebhook.edit_message  s%     h :TUUU 	|4!677 | zaeaoax z z{{{$+}55 |$:N:N:P:P | !z{{{7>t{L^`d7e7e&#-&7
 
 
 	 '+IW$$"I	#''))G 55
j? *l# $T

 6        D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	8 &&tF&;; 	5((** 	5t/C/C/E/E 	5K""4444s   0BEE
Ec         	       K   | j         t          d          d}|t          ur|j        }t                                          }|                    | j        | j         || j        | j        | j	        |           d{V  dS )a  |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

        .. versionchanged:: 2.0

            ``message_id`` parameter is now positional-only.

        .. versionchanged:: 2.0
            This function will now raise :exc:`ValueError` instead of
            ``InvalidArgument``.

        Parameters
        ------------
        message_id: :class:`int`
            The message ID to delete.
        thread: :class:`~discord.abc.Snowflake`
            The thread the webhook message belongs to.

            .. versionadded:: 2.0

        Raises
        -------
        HTTPException
            Deleting the message failed.
        Forbidden
            Deleted a message that is not yours.
        ValueError
            This webhook does not have a token associated with it.
        Nr  r  )
r   r!  rI   r2  r0  r   r   r}   rv   rw   )rQ   r   r^  r   r  s        rR   r  zWebhook.delete_message[  s      H :TUUU#'	  	I##%%,,GJL* - 
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
rT   )NNNN)r   r  r}   r~   r   r   rF  r]  rv   r   rw   r   rU   r[   r>  )r2  r   r   r   r}   r~   r  r4   r  r   rU   r1   )
r   r   r}   r~   r  r4   r  r   rU   r1   ri   )r   r  rF  r7   rU   r1   )r  r   rU   r-   )ry   r   r  r   rU   r[   )ry   r   r  r   r  r  r  r  r  r   rU   r-   )r^  r<   )r  r   r  r   r  r   r   r,   rx   r  r  r5   r  r?   r   r  r^  r<   r  r   r  r   r  r   r  r  rU   r.   )r  r   r  r   r  r   r   r,   rx   r  r  r5   r  r?   r   r  r^  r<   r  r   r  r   r  r   r  r  rU   r[   )&r   r   r  r   r  r   r   r   r  r   r   r,   rx   r  r  r3   r  r
  r  r5   r  r>   r^  r<   r  r   r   r  r  r   r  r   r  r  r  r@   rU   r.   )&r   r   r  r   r  r   r   r   r  r   r   r,   rx   r  r  r3   r  r
  r  r5   r  r>   r^  r<   r  r   r   r  r  r   r  r   r  r  r  r@   rU   r[   )&r   r   r  r   r  r   r   r   r  r   r   r,   rx   r  r  r3   r  r
  r  r5   r  r=   r^  r<   r  r   r   r   r  r   r  r   r  r  r  r@   rU   r  )r2  r   r^  r<   rU   r.   )r   r   r  r  r  r?   r  r  r^  r<   rU   r.   )r   r   r   r   r  r
  r  r	  r  r  r  r  r  r  r^  r<   rU   r.   )r   r   r   r   r  r
  r  r	  r  r  r  r  r  r  r^  r<   rU   r.   )r   r   r^  r<   rU   r[   )rj   rk   rl   r?  r@  r  rS   r:  rA  r   classmethodrI   r  r  r  r  r  r  r  r  r   r  r	  r~  r  __classcell__)r  s   @rR   r-   r-   L  s        N N` "DICCCC  $"&#26B B B B B B BQ Q Q Q J J J XJ  *1 #'=@ =@ =@ =@ =@ [=@~ 
 *1 #'@@ @@ @@ @@ @@ [@@D s s s [s2 s s s [s 26 ?
 ?
 ?
 ?
 ?
 ?
B 7;PT 2 2 2 2 2 2n !%%")'+ j
 j
 j
 j
 j
 j
XG G G G0   !! ',3 $" ''.     X$   !! ',3"#" ''.     X$    !! '"),3#" ''.)     X.    !! '"),3#"" ''.)     X2 e  ! '"),3 #" %'.)e e e e e eN FM 09 09 09 09 09 09d 
 :=69     X 
 "%"%!$9<"69     X" ")")!(9@#*6:#~ ~ ~ ~ ~ ~@ OV 4
 4
 4
 4
 4
 4
 4
 4
 4
 4
rT   r-   rO   )r   r   r   r   rU   r$   )r   r   r   r   r   r   r   r   r   r,   rx   r  r  r	  r  r
  r  r  r  r  r  r  r  r  r  r@   rU   r$   )r?  
__future__r   loggingre   r  urllib.parser   r   typingr   r   r   r   r	   r
   r   r   r   r   r   r   contextvarsr   rq   r    r   errorsr   r   r   r   r  r   enumsr   r   r   r   r  r   r   r   r   assetr    partial_emojir!   rw  r"   r#   r$   r%   r&   mixinsr'   r  r(   r)   r*   r+   r   r,   __all__	getLoggerrj   r   typing_extensionsr1   typesr2   r  r3   r  r4   mentionsr5   r6   rF  r7   r8   r  r9   emojir:   r;   abcr<   ui.viewr=   r>   r?   r  r@   datetimetypes.webhookr-   r  rA   rE  types.messageMessagePayload
types.userUserPayloadrB   PartialUserPayloadtypes.channelrC   r3  types.emojirm  types.snowflakerD   types.interactionsrE   "InteractionCallbackResponsePayloadBaseExceptionrF   rG  rI   r  rK   ro   r   r-  r0  r/   r0   rP  rH   r.   r  rm   rT   rR   <module>r2     s    0 # " " " " "   				 * * * * * * u u u u u u u u u u u u u u u u u u u u u u u u u u u u " " " " " "         K K K K K K K K K K K K       E E E E E E E E E E E E ! ! ! ! ! ! ! !                   ( ( ( ( ( ( b b b b b b b b b b b b b b       M M M M M M M M M M M M       w"" &5&&&&&&######******$$$$$$''''''&&&&&&4444444444OOO                         BAAAAA//////      
]	+	+	+B?O34F}           .WT WT WT WT WT WT WT WTtL L L L L %!#$%5<&29;?mO mO mO mO mO mO` 2<<S]p]p]r]r1s1s1s s s s s    H   <H H H H H( H H HDS S S S S S S S:P :P :P :P :P :P :P :Pzx[ x[ x[ x[ x[W x[ x[ x[vt2 t2 t2 t2 t2( t2 t2 t2nC
 C
 C
 C
 C
k C
 C
 C
 C
 C
rT   