mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-29 23:00:08 +00:00
Add applied_tags param to Webhook.send
This commit is contained in:
parent
f6182e5763
commit
50190e088e
@ -153,6 +153,7 @@ def handle_message_parameters(
|
|||||||
mention_author: Optional[bool] = None,
|
mention_author: Optional[bool] = None,
|
||||||
thread_name: str = MISSING,
|
thread_name: str = MISSING,
|
||||||
channel_payload: Dict[str, Any] = MISSING,
|
channel_payload: Dict[str, Any] = MISSING,
|
||||||
|
applied_tags: Optional[SnowflakeList] = MISSING,
|
||||||
) -> MultipartParameters:
|
) -> MultipartParameters:
|
||||||
if files is not MISSING and file is not MISSING:
|
if files is not MISSING and file is not MISSING:
|
||||||
raise TypeError('Cannot mix file and files keyword arguments.')
|
raise TypeError('Cannot mix file and files keyword arguments.')
|
||||||
@ -243,6 +244,12 @@ def handle_message_parameters(
|
|||||||
|
|
||||||
payload['attachments'] = attachments_payload
|
payload['attachments'] = attachments_payload
|
||||||
|
|
||||||
|
if applied_tags is not MISSING:
|
||||||
|
if applied_tags is not None:
|
||||||
|
payload['applied_tags'] = applied_tags
|
||||||
|
else:
|
||||||
|
payload['applied_tags'] = []
|
||||||
|
|
||||||
if channel_payload is not MISSING:
|
if channel_payload is not MISSING:
|
||||||
payload = {
|
payload = {
|
||||||
'message': payload,
|
'message': payload,
|
||||||
|
@ -45,7 +45,7 @@ from ..asset import Asset
|
|||||||
from ..partial_emoji import PartialEmoji
|
from ..partial_emoji import PartialEmoji
|
||||||
from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text
|
from ..http import Route, handle_message_parameters, MultipartParameters, HTTPClient, json_or_text
|
||||||
from ..mixins import Hashable
|
from ..mixins import Hashable
|
||||||
from ..channel import TextChannel, ForumChannel, PartialMessageable
|
from ..channel import TextChannel, ForumChannel, PartialMessageable, ForumTag
|
||||||
from ..file import File
|
from ..file import File
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -88,6 +88,7 @@ if TYPE_CHECKING:
|
|||||||
PartialChannel as PartialChannelPayload,
|
PartialChannel as PartialChannelPayload,
|
||||||
)
|
)
|
||||||
from ..types.emoji import PartialEmoji as PartialEmojiPayload
|
from ..types.emoji import PartialEmoji as PartialEmojiPayload
|
||||||
|
from ..types.snowflake import SnowflakeList
|
||||||
|
|
||||||
BE = TypeVar('BE', bound=BaseException)
|
BE = TypeVar('BE', bound=BaseException)
|
||||||
_State = Union[ConnectionState, '_WebhookState']
|
_State = Union[ConnectionState, '_WebhookState']
|
||||||
@ -1639,6 +1640,7 @@ class Webhook(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[WebhookMessage]:
|
) -> Optional[WebhookMessage]:
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
@ -1724,6 +1726,10 @@ class Webhook(BaseWebhook):
|
|||||||
in the UI, but will not actually send a notification.
|
in the UI, but will not actually send a notification.
|
||||||
|
|
||||||
.. versionadded:: 2.2
|
.. versionadded:: 2.2
|
||||||
|
applied_tags: List[:class:`ForumTag`]
|
||||||
|
Tags to apply to the thread if the webhook belongs to a :class:`~discord.ForumChannel`.
|
||||||
|
|
||||||
|
.. versionadded:: 2.4
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
--------
|
--------
|
||||||
@ -1782,6 +1788,11 @@ class Webhook(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,
|
||||||
@ -1796,6 +1807,7 @@ class Webhook(BaseWebhook):
|
|||||||
thread_name=thread_name,
|
thread_name=thread_name,
|
||||||
allowed_mentions=allowed_mentions,
|
allowed_mentions=allowed_mentions,
|
||||||
previous_allowed_mentions=previous_mentions,
|
previous_allowed_mentions=previous_mentions,
|
||||||
|
applied_tags=applied_tag_ids,
|
||||||
) as params:
|
) as params:
|
||||||
adapter = async_context.get()
|
adapter = async_context.get()
|
||||||
thread_id: Optional[int] = None
|
thread_id: Optional[int] = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user