Add support for applied_tags in Webhook.send overloaded methods

This commit is contained in:
Vioshim 2024-04-18 02:38:10 -05:00 committed by GitHub
parent f1a19f2f21
commit 5497674ae2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -1596,6 +1596,7 @@ class Webhook(BaseWebhook):
wait: Literal[True], wait: Literal[True],
suppress_embeds: bool = MISSING, suppress_embeds: bool = MISSING,
silent: bool = MISSING, silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> WebhookMessage: ) -> WebhookMessage:
... ...
@ -1619,6 +1620,7 @@ class Webhook(BaseWebhook):
wait: Literal[False] = ..., wait: Literal[False] = ...,
suppress_embeds: bool = MISSING, suppress_embeds: bool = MISSING,
silent: bool = MISSING, silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> None: ) -> None:
... ...

View File

@ -44,7 +44,7 @@ from .. import utils
from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError
from ..message import Message, MessageFlags from ..message import Message, MessageFlags
from ..http import Route, handle_message_parameters from ..http import Route, handle_message_parameters
from ..channel import PartialMessageable from ..channel import PartialMessageable, ForumTag
from .async_ import BaseWebhook, _WebhookState from .async_ import BaseWebhook, _WebhookState
@ -71,6 +71,7 @@ if TYPE_CHECKING:
from ..types.message import ( from ..types.message import (
Message as MessagePayload, Message as MessagePayload,
) )
from ..types.snowflake import SnowflakeList
BE = TypeVar('BE', bound=BaseException) BE = TypeVar('BE', bound=BaseException)
@ -870,6 +871,7 @@ class SyncWebhook(BaseWebhook):
wait: Literal[True], wait: Literal[True],
suppress_embeds: bool = MISSING, suppress_embeds: bool = MISSING,
silent: bool = MISSING, silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> SyncWebhookMessage: ) -> SyncWebhookMessage:
... ...
@ -891,6 +893,7 @@ class SyncWebhook(BaseWebhook):
wait: Literal[False] = ..., wait: Literal[False] = ...,
suppress_embeds: bool = MISSING, suppress_embeds: bool = MISSING,
silent: bool = MISSING, silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> None: ) -> None:
... ...
@ -911,6 +914,7 @@ class SyncWebhook(BaseWebhook):
wait: bool = False, wait: bool = False,
suppress_embeds: bool = False, suppress_embeds: bool = False,
silent: bool = False, silent: bool = False,
applied_tags: List[ForumTag] = MISSING,
) -> Optional[SyncWebhookMessage]: ) -> Optional[SyncWebhookMessage]:
"""Sends a message using the webhook. """Sends a message using the webhook.
@ -1014,6 +1018,11 @@ class SyncWebhook(BaseWebhook):
if thread_name is not MISSING and thread is not MISSING: if thread_name is not MISSING and thread is not MISSING:
raise TypeError('Cannot mix thread_name and thread keyword arguments.') 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( with handle_message_parameters(
content=content, content=content,
username=username, username=username,
@ -1027,6 +1036,7 @@ class SyncWebhook(BaseWebhook):
allowed_mentions=allowed_mentions, allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions, previous_allowed_mentions=previous_mentions,
flags=flags, flags=flags,
applied_tags=applied_tag_ids,
) as params: ) as params:
adapter: WebhookAdapter = _get_webhook_adapter() adapter: WebhookAdapter = _get_webhook_adapter()
thread_id: Optional[int] = None thread_id: Optional[int] = None