diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f83c577f4..aee21f704d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,10 @@ These changes are available on the `master` branch, but have not yet been releas - Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`. ([#1992](https://github.com/Pycord-Development/pycord/pull/1992)) - Added `custom_message` to AutoModActionMetadata. -- ([#2029](https://github.com/Pycord-Development/pycord/pull/2029)) + ([#2029](https://github.com/Pycord-Development/pycord/pull/2029)) +- Added support for + [voice messages](https://github.com/discord/discord-api-docs/pull/6082). + ([#2016](https://github.com/Pycord-Development/pycord/pull/2016)) ### Changed diff --git a/discord/flags.py b/discord/flags.py index ae5d74da82..28f78284c2 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -404,6 +404,14 @@ def suppress_notifications(self): return 4096 + @flag_value + def is_voice_message(self): + """:class:`bool`: Returns ``True`` if this message is a voice message. + + .. versionadded:: 2.5 + """ + return 8192 + @fill_with_flags() class PublicUserFlags(BaseFlags): diff --git a/discord/message.py b/discord/message.py index 77193b2920..c74f40c288 100644 --- a/discord/message.py +++ b/discord/message.py @@ -159,7 +159,7 @@ class Attachment(Hashable): case of images. When the message is deleted, this URL might be valid for a few minutes or not valid at all. content_type: Optional[:class:`str`] - The attachment's `media type `_ + The attachment's `media type `_. ephemeral: :class:`bool` Whether the attachment is ephemeral or not. @@ -169,6 +169,16 @@ class Attachment(Hashable): The attachment's description. .. versionadded:: 2.0 + + duration_secs: Optional[:class:`float`] + The duration of the audio file (currently for voice messages). + + .. versionadded:: 2.5 + + waveform: Optional[:class:`str`] + The base64 encoded bytearray representing a sampled waveform (currently for voice messages). + + .. versionadded:: 2.5 """ __slots__ = ( @@ -183,6 +193,8 @@ class Attachment(Hashable): "content_type", "ephemeral", "description", + "duration_secs", + "waveform", ) def __init__(self, *, data: AttachmentPayload, state: ConnectionState): @@ -197,6 +209,8 @@ def __init__(self, *, data: AttachmentPayload, state: ConnectionState): self.content_type: str | None = data.get("content_type") self.ephemeral: bool = data.get("ephemeral", False) self.description: str | None = data.get("description") + self.duration_secs: float | None = data.get("duration_secs") + self.waveform: str | None = data.get("waveform") def is_spoiler(self) -> bool: """Whether this attachment contains a spoiler.""" diff --git a/discord/permissions.py b/discord/permissions.py index 43dc6f2f7d..e94e6c2116 100644 --- a/discord/permissions.py +++ b/discord/permissions.py @@ -610,6 +610,14 @@ def moderate_members(self) -> int: """ return 1 << 40 + @flag_value + def send_voice_messages(self) -> int: + """:class:`bool`: Returns ``True`` if a member can send voice messages. + + .. versionadded:: 2.5 + """ + return 1 << 46 + PO = TypeVar("PO", bound="PermissionOverwrite") @@ -727,6 +735,7 @@ class PermissionOverwrite: use_external_stickers: bool | None start_embedded_activities: bool | None moderate_members: bool | None + send_voice_messages: bool | None def __init__(self, **kwargs: bool | None): self._values: dict[str, bool | None] = {} diff --git a/discord/types/message.py b/discord/types/message.py index 4d6d295d09..b141531e9a 100644 --- a/discord/types/message.py +++ b/discord/types/message.py @@ -66,6 +66,8 @@ class Attachment(TypedDict): size: int url: str proxy_url: str + duration_secs: NotRequired[float] + waveform: NotRequired[str] MessageActivityType = Literal[1, 2, 3, 5]