From a2aceec2ce3ea76470142993df91969446f33fba 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 ac8a4d499..e6cff254d 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1372,6 +1372,7 @@ class Webhook(BaseWebhook): wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> WebhookMessage: ... @@ -1393,6 +1394,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 4023348b9..a5eebfbca 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) @@ -869,6 +870,7 @@ class SyncWebhook(BaseWebhook): wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> SyncWebhookMessage: ... @@ -890,6 +892,7 @@ class SyncWebhook(BaseWebhook): wait: Literal[False] = ..., suppress_embeds: bool = MISSING, silent: bool = MISSING, + applied_tags: List[ForumTag] = MISSING, ) -> None: ... @@ -910,6 +913,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. @@ -1013,6 +1017,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, @@ -1026,6 +1035,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