From 7e2ca02fd1e3570e8a07a3bab79eb38e025ab842 Mon Sep 17 00:00:00 2001 From: Sacul Date: Fri, 15 Aug 2025 23:38:56 +0800 Subject: [PATCH] Add total_message_sent attribute to threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alex Nørgaard Co-authored-by: dolfies --- discord/app_commands/models.py | 6 ++++++ discord/threads.py | 6 ++++++ discord/types/channel.py | 1 + discord/types/interactions.py | 1 + discord/types/threads.py | 1 + 5 files changed, 15 insertions(+) diff --git a/discord/app_commands/models.py b/discord/app_commands/models.py index 1dd004f1d..b51339c26 100644 --- a/discord/app_commands/models.py +++ b/discord/app_commands/models.py @@ -790,6 +790,10 @@ class AppCommandThread(Hashable): member_count: :class:`int` An approximate number of members in this thread. This caps at 50. + .. versionadded:: 2.6 + total_message_sent: :class:`int` + The total number of messages sent, including deleted messages. + .. versionadded:: 2.6 permissions: :class:`~discord.Permissions` The resolved permissions of the user who invoked @@ -830,6 +834,7 @@ class AppCommandThread(Hashable): 'member_count', 'slowmode_delay', 'last_message_id', + 'total_message_sent', '_applied_tags', '_flags', '_created_at', @@ -855,6 +860,7 @@ class AppCommandThread(Hashable): self.message_count: int = int(data['message_count']) self.last_message_id: Optional[int] = _get_as_snowflake(data, 'last_message_id') self.slowmode_delay: int = data.get('rate_limit_per_user', 0) + self.total_message_sent: int = data.get('total_message_sent', 0) self._applied_tags: array.array[int] = array.array('Q', map(int, data.get('applied_tags', []))) self._flags: int = data.get('flags', 0) self._unroll_metadata(data['thread_metadata']) diff --git a/discord/threads.py b/discord/threads.py index 0c8060193..1700a5e61 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -109,6 +109,10 @@ class Thread(Messageable, Hashable): An approximate number of messages in this thread. member_count: :class:`int` An approximate number of members in this thread. This caps at 50. + total_message_sent: :class:`int` + The total number of messages sent, including deleted messages. + + .. versionadded:: 2.6 me: Optional[:class:`ThreadMember`] A thread member representing yourself, if you've joined the thread. This could not be available. @@ -152,6 +156,7 @@ class Thread(Messageable, Hashable): 'archiver_id', 'auto_archive_duration', 'archive_timestamp', + 'total_message_sent', '_created_at', '_flags', '_applied_tags', @@ -185,6 +190,7 @@ class Thread(Messageable, Hashable): self.slowmode_delay: int = data.get('rate_limit_per_user', 0) self.message_count: int = data['message_count'] self.member_count: int = data['member_count'] + self.total_message_sent: int = data.get('total_message_sent', 0) self._flags: int = data.get('flags', 0) # SnowflakeList is sorted, but this would not be proper for applied tags, where order actually matters. self._applied_tags: array.array[int] = array.array('Q', map(int, data.get('applied_tags', []))) diff --git a/discord/types/channel.py b/discord/types/channel.py index 4b593e554..f3cc680b5 100644 --- a/discord/types/channel.py +++ b/discord/types/channel.py @@ -126,6 +126,7 @@ class ThreadChannel(_BaseChannel): rate_limit_per_user: int message_count: int member_count: int + total_message_sent: int thread_metadata: ThreadMetadata member: NotRequired[ThreadMember] owner_id: NotRequired[Snowflake] diff --git a/discord/types/interactions.py b/discord/types/interactions.py index 6b6e352a4..f34166959 100644 --- a/discord/types/interactions.py +++ b/discord/types/interactions.py @@ -85,6 +85,7 @@ class PartialThread(_BasePartialChannel): rate_limit_per_user: int last_message_id: NotRequired[Optional[Snowflake]] flags: NotRequired[int] + total_message_sent: int class ResolvedData(TypedDict, total=False): diff --git a/discord/types/threads.py b/discord/types/threads.py index f3b8f808c..1dce6fac1 100644 --- a/discord/types/threads.py +++ b/discord/types/threads.py @@ -60,6 +60,7 @@ class Thread(TypedDict): type: ThreadType member_count: int message_count: int + total_message_sent: int rate_limit_per_user: int thread_metadata: ThreadMetadata member: NotRequired[ThreadMember]