From 5497674ae2c0bd24d03f6f35ddadddf473b61e6f Mon Sep 17 00:00:00 2001 From: Vioshim <63890837+Vioshim@users.noreply.github.com> Date: Thu, 18 Apr 2024 02:38:10 -0500 Subject: [PATCH] Add support for applied_tags in Webhook.send overloaded methods --- discord/webhook/async_.py | 2 ++ discord/webhook/sync.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index b74916db8..767db38cc 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1596,6 +1596,7 @@ class Webhook(BaseWebhook): wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> WebhookMessage: ... @@ -1619,6 +1620,7 @@ class Webhook(BaseWebhook): wait: Literal[False] = ..., suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> None: ... diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py index 5fee0e41e..198cdf53b 100644 --- a/discord/webhook/sync.py +++ b/discord/webhook/sync.py @@ -44,7 +44,7 @@ from .. import utils from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError from ..message import Message, MessageFlags from ..http import Route, handle_message_parameters -from ..channel import PartialMessageable +from ..channel import PartialMessageable, ForumTag from .async_ import BaseWebhook, _WebhookState @@ -71,6 +71,7 @@ if TYPE_CHECKING: from ..types.message import ( Message as MessagePayload, ) + from ..types.snowflake import SnowflakeList BE = TypeVar('BE', bound=BaseException) @@ -870,6 +871,7 @@ class SyncWebhook(BaseWebhook): wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> SyncWebhookMessage: ... @@ -891,6 +893,7 @@ class SyncWebhook(BaseWebhook): wait: Literal[False] = ..., suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> None: ... @@ -911,6 +914,7 @@ class SyncWebhook(BaseWebhook): wait: bool = False, suppress_embeds: bool = False, silent: bool = False, + applied_tags: List[ForumTag] = MISSING, ) -> Optional[SyncWebhookMessage]: """Sends a message using the webhook. @@ -1014,6 +1018,11 @@ class SyncWebhook(BaseWebhook): if thread_name is not MISSING and thread is not MISSING: raise TypeError('Cannot mix thread_name and thread keyword arguments.') + if applied_tags is MISSING: + applied_tag_ids = MISSING + else: + applied_tag_ids: SnowflakeList = [tag.id for tag in applied_tags] + with handle_message_parameters( content=content, username=username, @@ -1027,6 +1036,7 @@ class SyncWebhook(BaseWebhook): allowed_mentions=allowed_mentions, previous_allowed_mentions=previous_mentions, flags=flags, + applied_tags=applied_tag_ids, ) as params: adapter: WebhookAdapter = _get_webhook_adapter() thread_id: Optional[int] = None