@@ -99,11 +99,17 @@ def delete_webhook(self, *, reason=None):
99
99
def edit_webhook (self , * , reason = None , ** payload ):
100
100
return self .request ('PATCH' , self ._request_url , payload = payload , reason = reason )
101
101
102
- def edit_webhook_message (self , message_id , payload ):
103
- return self .request ('PATCH' , '{}/messages/{}' .format (self ._request_url , message_id ), payload = payload )
104
-
105
- def delete_webhook_message (self , message_id ):
106
- return self .request ('DELETE' , '{}/messages/{}' .format (self ._request_url , message_id ))
102
+ def edit_webhook_message (self , message_id , payload , thread_id : int = None ):
103
+ url = '{}/messages/{}' .format (self ._request_url , message_id )
104
+ if thread_id :
105
+ url += f'?thread_id={ thread_id } '
106
+ return self .request ('PATCH' , url , payload = payload )
107
+
108
+ def delete_webhook_message (self , message_id , thread_id : int = None ):
109
+ url = '{}/messages/{}' .format (self ._request_url , message_id )
110
+ if thread_id :
111
+ url += f'?thread_id={ thread_id } '
112
+ return self .request ('DELETE' , url )
107
113
108
114
def handle_execution_response (self , data , * , wait ):
109
115
"""Transforms the webhook execution response into something
@@ -129,7 +135,7 @@ async def _wrap_coroutine_and_cleanup(self, coro, cleanup):
129
135
finally :
130
136
cleanup ()
131
137
132
- def execute_webhook (self , * , payload , wait = False , file = None , files = None ):
138
+ def execute_webhook (self , * , payload , wait = False , thread_id : int = None , file = None , files = None ):
133
139
cleanup = None
134
140
if file is not None :
135
141
multipart = {
@@ -159,6 +165,8 @@ def _anon():
159
165
files_to_pass = None
160
166
161
167
url = '%s?wait=%d' % (self ._request_url , wait )
168
+ if thread_id :
169
+ url += f'&thread_id={ thread_id } '
162
170
maybe_coro = None
163
171
try :
164
172
maybe_coro = self .request ('POST' , url , multipart = multipart , payload = data , files = files_to_pass )
@@ -241,7 +249,7 @@ async def request(self, verb, url, payload=None, multipart=None, *, files=None,
241
249
# Banned by Cloudflare more than likely.
242
250
raise HTTPException (r , data )
243
251
244
- retry_after = response ['retry_after' ] / 1000.0
252
+ retry_after = response ['retry_after' ]
245
253
log .warning ('Webhook ID %s is rate limited. Retrying in %.2f seconds' , _id , retry_after )
246
254
await asyncio .sleep (retry_after )
247
255
continue
@@ -344,7 +352,7 @@ def request(self, verb, url, payload=None, multipart=None, *, files=None, reason
344
352
# Banned by Cloudflare more than likely.
345
353
raise HTTPException (r , data )
346
354
347
- retry_after = response ['retry_after' ] / 1000.0
355
+ retry_after = response ['retry_after' ]
348
356
log .warning ('Webhook ID %s is rate limited. Retrying in %.2f seconds' , _id , retry_after )
349
357
time .sleep (retry_after )
350
358
continue
@@ -730,7 +738,7 @@ def guild(self):
730
738
731
739
@property
732
740
def channel (self ):
733
- """Optional[:class:`TextChannel`]: The text channel this webhook belongs to.
741
+ """Optional[:class:`TextChannel`, :class:`ForumChannel` ]: The text or forum channel this webhook belongs to.
734
742
735
743
If this is a partial webhook, then this will always return ``None``.
736
744
"""
@@ -882,7 +890,7 @@ def edit(self, *, reason=None, **kwargs):
882
890
883
891
return self ._adapter .edit_webhook (reason = reason , ** payload )
884
892
885
- def send (self , content = None , * , wait = False , username = None , avatar_url = None , tts = False ,
893
+ def send (self , content = None , * , wait = False , thread_id : int = None , username = None , avatar_url = None , tts = False ,
886
894
file = None , files = None , embed = None , embeds = None , allowed_mentions = None ):
887
895
"""|maybecoro|
888
896
@@ -986,7 +994,7 @@ def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=
986
994
elif previous_mentions is not None :
987
995
payload ['allowed_mentions' ] = previous_mentions .to_dict ()
988
996
989
- return self ._adapter .execute_webhook (wait = wait , file = file , files = files , payload = payload )
997
+ return self ._adapter .execute_webhook (wait = wait , thread_id = thread_id , file = file , files = files , payload = payload )
990
998
991
999
def execute (self , * args , ** kwargs ):
992
1000
"""An alias for :meth:`~.Webhook.send`."""
0 commit comments