mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-19 15:36:02 +00:00
Add support for silent messages
This commit is contained in:
parent
93ed1646d2
commit
183675be74
@ -1315,6 +1315,7 @@ class Messageable:
|
||||
mention_author: bool = ...,
|
||||
view: View = ...,
|
||||
suppress_embeds: bool = ...,
|
||||
silent: bool = ...,
|
||||
) -> Message:
|
||||
...
|
||||
|
||||
@ -1334,6 +1335,7 @@ class Messageable:
|
||||
mention_author: bool = ...,
|
||||
view: View = ...,
|
||||
suppress_embeds: bool = ...,
|
||||
silent: bool = ...,
|
||||
) -> Message:
|
||||
...
|
||||
|
||||
@ -1353,6 +1355,7 @@ class Messageable:
|
||||
mention_author: bool = ...,
|
||||
view: View = ...,
|
||||
suppress_embeds: bool = ...,
|
||||
silent: bool = ...,
|
||||
) -> Message:
|
||||
...
|
||||
|
||||
@ -1372,6 +1375,7 @@ class Messageable:
|
||||
mention_author: bool = ...,
|
||||
view: View = ...,
|
||||
suppress_embeds: bool = ...,
|
||||
silent: bool = ...,
|
||||
) -> Message:
|
||||
...
|
||||
|
||||
@ -1392,6 +1396,7 @@ class Messageable:
|
||||
mention_author: Optional[bool] = None,
|
||||
view: Optional[View] = None,
|
||||
suppress_embeds: bool = False,
|
||||
silent: bool = False,
|
||||
) -> Message:
|
||||
"""|coro|
|
||||
|
||||
@ -1472,6 +1477,11 @@ class Messageable:
|
||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
silent: :class:`bool`
|
||||
Whether to suppress push and desktop notifications for the message. This will increment the mention counter
|
||||
in the UI, but will not actually send a notification.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
Raises
|
||||
--------
|
||||
@ -1514,10 +1524,12 @@ class Messageable:
|
||||
if view and not hasattr(view, '__discord_ui_view__'):
|
||||
raise TypeError(f'view parameter must be View not {view.__class__.__name__}')
|
||||
|
||||
if suppress_embeds:
|
||||
if suppress_embeds or silent:
|
||||
from .message import MessageFlags # circular import
|
||||
|
||||
flags = MessageFlags._from_value(4)
|
||||
flags = MessageFlags._from_value(0)
|
||||
flags.suppress_embeds = suppress_embeds
|
||||
flags.suppress_notifications = silent
|
||||
else:
|
||||
flags = MISSING
|
||||
|
||||
|
@ -434,6 +434,22 @@ class MessageFlags(BaseFlags):
|
||||
"""
|
||||
return 256
|
||||
|
||||
@flag_value
|
||||
def suppress_notifications(self):
|
||||
""":class:`bool`: Returns ``True`` if the message will not trigger push and desktop notifications.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
"""
|
||||
return 4096
|
||||
|
||||
@alias_flag_value
|
||||
def silent(self):
|
||||
""":class:`bool`: Alias for :attr:`suppress_notifications`.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
"""
|
||||
return 4096
|
||||
|
||||
|
||||
@fill_with_flags()
|
||||
class PublicUserFlags(BaseFlags):
|
||||
|
@ -690,6 +690,7 @@ class InteractionResponse(Generic[ClientT]):
|
||||
ephemeral: bool = False,
|
||||
allowed_mentions: AllowedMentions = MISSING,
|
||||
suppress_embeds: bool = False,
|
||||
silent: bool = False,
|
||||
delete_after: Optional[float] = None,
|
||||
) -> None:
|
||||
"""|coro|
|
||||
@ -723,6 +724,11 @@ class InteractionResponse(Generic[ClientT]):
|
||||
more information.
|
||||
suppress_embeds: :class:`bool`
|
||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||
silent: :class:`bool`
|
||||
Whether to suppress push and desktop notifications for the message. This will increment the mention counter
|
||||
in the UI, but will not actually send a notification.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
delete_after: :class:`float`
|
||||
If provided, the number of seconds to wait in the background
|
||||
before deleting the message we just sent. If the deletion fails,
|
||||
@ -744,10 +750,11 @@ class InteractionResponse(Generic[ClientT]):
|
||||
if self._response_type:
|
||||
raise InteractionResponded(self._parent)
|
||||
|
||||
if ephemeral or suppress_embeds:
|
||||
if ephemeral or suppress_embeds or silent:
|
||||
flags = MessageFlags._from_value(0)
|
||||
flags.ephemeral = ephemeral
|
||||
flags.suppress_embeds = suppress_embeds
|
||||
flags.suppress_notifications = silent
|
||||
else:
|
||||
flags = MISSING
|
||||
|
||||
|
@ -1535,6 +1535,7 @@ class Webhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: Literal[True],
|
||||
suppress_embeds: bool = MISSING,
|
||||
silent: bool = MISSING,
|
||||
) -> WebhookMessage:
|
||||
...
|
||||
|
||||
@ -1557,6 +1558,7 @@ class Webhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: Literal[False] = ...,
|
||||
suppress_embeds: bool = MISSING,
|
||||
silent: bool = MISSING,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@ -1578,6 +1580,7 @@ class Webhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: bool = False,
|
||||
suppress_embeds: bool = False,
|
||||
silent: bool = False,
|
||||
) -> Optional[WebhookMessage]:
|
||||
"""|coro|
|
||||
|
||||
@ -1658,6 +1661,11 @@ class Webhook(BaseWebhook):
|
||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
silent: :class:`bool`
|
||||
Whether to suppress push and desktop notifications for the message. This will increment the mention counter
|
||||
in the UI, but will not actually send a notification.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
Raises
|
||||
--------
|
||||
@ -1688,10 +1696,11 @@ class Webhook(BaseWebhook):
|
||||
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
|
||||
if content is None:
|
||||
content = MISSING
|
||||
if ephemeral or suppress_embeds:
|
||||
if ephemeral or suppress_embeds or silent:
|
||||
flags = MessageFlags._from_value(0)
|
||||
flags.ephemeral = ephemeral
|
||||
flags.suppress_embeds = suppress_embeds
|
||||
flags.suppress_notifications = silent
|
||||
else:
|
||||
flags = MISSING
|
||||
|
||||
|
@ -870,6 +870,7 @@ class SyncWebhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: Literal[True],
|
||||
suppress_embeds: bool = MISSING,
|
||||
silent: bool = MISSING,
|
||||
) -> SyncWebhookMessage:
|
||||
...
|
||||
|
||||
@ -890,6 +891,7 @@ class SyncWebhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: Literal[False] = ...,
|
||||
suppress_embeds: bool = MISSING,
|
||||
silent: bool = MISSING,
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@ -909,6 +911,7 @@ class SyncWebhook(BaseWebhook):
|
||||
thread_name: str = MISSING,
|
||||
wait: bool = False,
|
||||
suppress_embeds: bool = False,
|
||||
silent: bool = False,
|
||||
) -> Optional[SyncWebhookMessage]:
|
||||
"""Sends a message using the webhook.
|
||||
|
||||
@ -968,6 +971,11 @@ class SyncWebhook(BaseWebhook):
|
||||
Whether to suppress embeds for the message. This sends the message without any embeds if set to ``True``.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
silent: :class:`bool`
|
||||
Whether to suppress push and desktop notifications for the message. This will increment the mention counter
|
||||
in the UI, but will not actually send a notification.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
Raises
|
||||
--------
|
||||
@ -997,8 +1005,10 @@ class SyncWebhook(BaseWebhook):
|
||||
if content is None:
|
||||
content = MISSING
|
||||
|
||||
if suppress_embeds:
|
||||
flags = MessageFlags._from_value(4)
|
||||
if suppress_embeds or silent:
|
||||
flags = MessageFlags._from_value(0)
|
||||
flags.suppress_embeds = suppress_embeds
|
||||
flags.suppress_notifications = silent
|
||||
else:
|
||||
flags = MISSING
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user