mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-14 17:59:48 +00:00
Add support for new thread_name parameter in Webhook.send
This commit is contained in:
parent
259c6733a3
commit
e543abd950
@ -148,6 +148,7 @@ def handle_message_parameters(
|
|||||||
stickers: Optional[SnowflakeList] = MISSING,
|
stickers: Optional[SnowflakeList] = MISSING,
|
||||||
previous_allowed_mentions: Optional[AllowedMentions] = None,
|
previous_allowed_mentions: Optional[AllowedMentions] = None,
|
||||||
mention_author: Optional[bool] = None,
|
mention_author: Optional[bool] = None,
|
||||||
|
thread_name: str = MISSING,
|
||||||
channel_payload: Dict[str, Any] = MISSING,
|
channel_payload: Dict[str, Any] = MISSING,
|
||||||
) -> MultipartParameters:
|
) -> MultipartParameters:
|
||||||
if files is not MISSING and file is not MISSING:
|
if files is not MISSING and file is not MISSING:
|
||||||
@ -206,6 +207,9 @@ def handle_message_parameters(
|
|||||||
if flags is not MISSING:
|
if flags is not MISSING:
|
||||||
payload['flags'] = flags.value
|
payload['flags'] = flags.value
|
||||||
|
|
||||||
|
if thread_name is not MISSING:
|
||||||
|
payload['thread_name'] = thread_name
|
||||||
|
|
||||||
if allowed_mentions:
|
if allowed_mentions:
|
||||||
if previous_allowed_mentions is not None:
|
if previous_allowed_mentions is not None:
|
||||||
payload['allowed_mentions'] = previous_allowed_mentions.merge(allowed_mentions).to_dict()
|
payload['allowed_mentions'] = previous_allowed_mentions.merge(allowed_mentions).to_dict()
|
||||||
|
@ -1514,6 +1514,7 @@ class Webhook(BaseWebhook):
|
|||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
view: View = MISSING,
|
view: View = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: Literal[True],
|
wait: Literal[True],
|
||||||
suppress_embeds: bool = MISSING,
|
suppress_embeds: bool = MISSING,
|
||||||
) -> WebhookMessage:
|
) -> WebhookMessage:
|
||||||
@ -1535,6 +1536,7 @@ class Webhook(BaseWebhook):
|
|||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
view: View = MISSING,
|
view: View = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: Literal[False] = ...,
|
wait: Literal[False] = ...,
|
||||||
suppress_embeds: bool = MISSING,
|
suppress_embeds: bool = MISSING,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -1555,6 +1557,7 @@ class Webhook(BaseWebhook):
|
|||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
view: View = MISSING,
|
view: View = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: bool = False,
|
wait: bool = False,
|
||||||
suppress_embeds: bool = False,
|
suppress_embeds: bool = False,
|
||||||
) -> Optional[WebhookMessage]:
|
) -> Optional[WebhookMessage]:
|
||||||
@ -1625,6 +1628,13 @@ class Webhook(BaseWebhook):
|
|||||||
thread: :class:`~discord.abc.Snowflake`
|
thread: :class:`~discord.abc.Snowflake`
|
||||||
The thread to send this webhook to.
|
The thread to send this webhook to.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
thread_name: :class:`str`
|
||||||
|
The thread name to create with this webhook if the webhook belongs
|
||||||
|
to a :class:`~discord.ForumChannel`. Note that this is mutually
|
||||||
|
exclusive with the ``thread`` parameter, as this will create a
|
||||||
|
new thread with the given name.
|
||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
suppress_embeds: :class:`bool`
|
suppress_embeds: :class:`bool`
|
||||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||||
@ -1640,7 +1650,8 @@ class Webhook(BaseWebhook):
|
|||||||
Forbidden
|
Forbidden
|
||||||
The authorization token for the webhook is incorrect.
|
The authorization token for the webhook is incorrect.
|
||||||
TypeError
|
TypeError
|
||||||
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``.
|
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
|
||||||
|
or ``thread`` and ``thread_name``.
|
||||||
ValueError
|
ValueError
|
||||||
The length of ``embeds`` was invalid, there was no token
|
The length of ``embeds`` was invalid, there was no token
|
||||||
associated with this webhook or ``ephemeral`` was passed
|
associated with this webhook or ``ephemeral`` was passed
|
||||||
@ -1683,6 +1694,9 @@ class Webhook(BaseWebhook):
|
|||||||
if ephemeral is True and view.timeout is None:
|
if ephemeral is True and view.timeout is None:
|
||||||
view.timeout = 15 * 60.0
|
view.timeout = 15 * 60.0
|
||||||
|
|
||||||
|
if thread_name is not MISSING and thread is not MISSING:
|
||||||
|
raise TypeError('Cannot mix thread_name and thread keyword arguments.')
|
||||||
|
|
||||||
params = handle_message_parameters(
|
params = handle_message_parameters(
|
||||||
content=content,
|
content=content,
|
||||||
username=username,
|
username=username,
|
||||||
@ -1694,6 +1708,7 @@ class Webhook(BaseWebhook):
|
|||||||
embeds=embeds,
|
embeds=embeds,
|
||||||
flags=flags,
|
flags=flags,
|
||||||
view=view,
|
view=view,
|
||||||
|
thread_name=thread_name,
|
||||||
allowed_mentions=allowed_mentions,
|
allowed_mentions=allowed_mentions,
|
||||||
previous_allowed_mentions=previous_mentions,
|
previous_allowed_mentions=previous_mentions,
|
||||||
)
|
)
|
||||||
|
@ -864,6 +864,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
embeds: Sequence[Embed] = MISSING,
|
embeds: Sequence[Embed] = MISSING,
|
||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: Literal[True],
|
wait: Literal[True],
|
||||||
suppress_embeds: bool = MISSING,
|
suppress_embeds: bool = MISSING,
|
||||||
) -> SyncWebhookMessage:
|
) -> SyncWebhookMessage:
|
||||||
@ -883,6 +884,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
embeds: Sequence[Embed] = MISSING,
|
embeds: Sequence[Embed] = MISSING,
|
||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: Literal[False] = ...,
|
wait: Literal[False] = ...,
|
||||||
suppress_embeds: bool = MISSING,
|
suppress_embeds: bool = MISSING,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -901,6 +903,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
embeds: Sequence[Embed] = MISSING,
|
embeds: Sequence[Embed] = MISSING,
|
||||||
allowed_mentions: AllowedMentions = MISSING,
|
allowed_mentions: AllowedMentions = MISSING,
|
||||||
thread: Snowflake = MISSING,
|
thread: Snowflake = MISSING,
|
||||||
|
thread_name: str = MISSING,
|
||||||
wait: bool = False,
|
wait: bool = False,
|
||||||
suppress_embeds: bool = False,
|
suppress_embeds: bool = False,
|
||||||
) -> Optional[SyncWebhookMessage]:
|
) -> Optional[SyncWebhookMessage]:
|
||||||
@ -950,6 +953,13 @@ class SyncWebhook(BaseWebhook):
|
|||||||
thread: :class:`~discord.abc.Snowflake`
|
thread: :class:`~discord.abc.Snowflake`
|
||||||
The thread to send this message to.
|
The thread to send this message to.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
thread_name: :class:`str`
|
||||||
|
The thread name to create with this webhook if the webhook belongs
|
||||||
|
to a :class:`~discord.ForumChannel`. Note that this is mutually
|
||||||
|
exclusive with the ``thread`` parameter, as this will create a
|
||||||
|
new thread with the given name.
|
||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
suppress_embeds: :class:`bool`
|
suppress_embeds: :class:`bool`
|
||||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||||
@ -966,6 +976,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
The authorization token for the webhook is incorrect.
|
The authorization token for the webhook is incorrect.
|
||||||
TypeError
|
TypeError
|
||||||
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
|
You specified both ``embed`` and ``embeds`` or ``file`` and ``files``
|
||||||
|
or ``thread`` and ``thread_name``.
|
||||||
ValueError
|
ValueError
|
||||||
The length of ``embeds`` was invalid or
|
The length of ``embeds`` was invalid or
|
||||||
there was no token associated with this webhook.
|
there was no token associated with this webhook.
|
||||||
@ -988,6 +999,9 @@ class SyncWebhook(BaseWebhook):
|
|||||||
else:
|
else:
|
||||||
flags = MISSING
|
flags = MISSING
|
||||||
|
|
||||||
|
if thread_name is not MISSING and thread is not MISSING:
|
||||||
|
raise TypeError('Cannot mix thread_name and thread keyword arguments.')
|
||||||
|
|
||||||
params = handle_message_parameters(
|
params = handle_message_parameters(
|
||||||
content=content,
|
content=content,
|
||||||
username=username,
|
username=username,
|
||||||
@ -997,6 +1011,7 @@ class SyncWebhook(BaseWebhook):
|
|||||||
files=files,
|
files=files,
|
||||||
embed=embed,
|
embed=embed,
|
||||||
embeds=embeds,
|
embeds=embeds,
|
||||||
|
thread_name=thread_name,
|
||||||
allowed_mentions=allowed_mentions,
|
allowed_mentions=allowed_mentions,
|
||||||
previous_allowed_mentions=previous_mentions,
|
previous_allowed_mentions=previous_mentions,
|
||||||
flags=flags,
|
flags=flags,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user