mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 17:36:15 +00:00
Add support for thread parameter in Webhook.send
This commit is contained in:
@ -262,9 +262,12 @@ class WebhookAdapter:
|
||||
payload: Optional[Dict[str, Any]] = None,
|
||||
multipart: Optional[List[Dict[str, Any]]] = None,
|
||||
files: Optional[List[File]] = None,
|
||||
thread_id: Optional[int] = None,
|
||||
wait: bool = False,
|
||||
):
|
||||
params = {'wait': int(wait)}
|
||||
if thread_id:
|
||||
params['thread_id'] = thread_id
|
||||
route = Route('POST', '/webhooks/{webhook_id}/{webhook_token}', webhook_id=webhook_id, webhook_token=token)
|
||||
return self.request(route, session, payload=payload, multipart=multipart, files=files, params=params)
|
||||
|
||||
@ -780,6 +783,7 @@ class SyncWebhook(BaseWebhook):
|
||||
embed: Embed = MISSING,
|
||||
embeds: List[Embed] = MISSING,
|
||||
allowed_mentions: AllowedMentions = MISSING,
|
||||
thread: Snowflake = MISSING,
|
||||
wait: bool = False,
|
||||
) -> Optional[SyncWebhookMessage]:
|
||||
"""Sends a message using the webhook.
|
||||
@ -824,6 +828,10 @@ class SyncWebhook(BaseWebhook):
|
||||
Controls the mentions being processed in this message.
|
||||
|
||||
.. versionadded:: 1.4
|
||||
thread: :class:`~discord.abc.Snowflake`
|
||||
The thread to send this message to.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
Raises
|
||||
--------
|
||||
@ -866,6 +874,10 @@ class SyncWebhook(BaseWebhook):
|
||||
previous_allowed_mentions=previous_mentions,
|
||||
)
|
||||
adapter: WebhookAdapter = _context.adapter
|
||||
thread_id: Optional[int] = None
|
||||
if thread is not MISSING:
|
||||
thread_id = thread.id
|
||||
|
||||
data = adapter.execute_webhook(
|
||||
self.id,
|
||||
self.token,
|
||||
@ -873,6 +885,7 @@ class SyncWebhook(BaseWebhook):
|
||||
payload=params.payload,
|
||||
multipart=params.multipart,
|
||||
files=params.files,
|
||||
thread_id=thread_id,
|
||||
wait=wait,
|
||||
)
|
||||
if wait:
|
||||
|
Reference in New Issue
Block a user