From d2ea33e5e920683b182d78f8fc49b0adb43d506d Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 27 Aug 2021 05:52:07 +1000 Subject: [PATCH] Add support for invitable thread option --- discord/http.py | 3 +++ discord/threads.py | 11 +++++++++++ discord/types/threads.py | 1 + 3 files changed, 15 insertions(+) diff --git a/discord/http.py b/discord/http.py index 739f0f663..72fab011d 100644 --- a/discord/http.py +++ b/discord/http.py @@ -826,6 +826,7 @@ class HTTPClient: 'archived', 'auto_archive_duration', 'locked', + 'invitable', 'default_auto_archive_duration', ) payload = {k: v for k, v in options.items() if k in valid_keys} @@ -907,12 +908,14 @@ class HTTPClient: name: str, auto_archive_duration: threads.ThreadArchiveDuration, type: threads.ThreadType, + invitable: bool, reason: Optional[str] = None, ) -> Response[threads.Thread]: payload = { 'name': name, 'auto_archive_duration': auto_archive_duration, 'type': type, + 'invitable': invitable, } route = Route('POST', '/channels/{channel_id}/threads', channel_id=channel_id) diff --git a/discord/threads.py b/discord/threads.py index 1b0166341..6c9a74955 100644 --- a/discord/threads.py +++ b/discord/threads.py @@ -111,6 +111,9 @@ class Thread(Messageable, Hashable): Whether the thread is archived. locked: :class:`bool` Whether the thread is locked. + invitable: :class:`bool` + Whether non-moderators can add other non-moderators to this thread. + This is always ``True`` for public threads. archiver_id: Optional[:class:`int`] The user's ID that archived this thread. auto_archive_duration: :class:`int` @@ -136,6 +139,7 @@ class Thread(Messageable, Hashable): 'me', 'locked', 'archived', + 'invitable', 'archiver_id', 'auto_archive_duration', 'archive_timestamp', @@ -184,6 +188,7 @@ class Thread(Messageable, Hashable): self.auto_archive_duration = data['auto_archive_duration'] self.archive_timestamp = parse_time(data['archive_timestamp']) self.locked = data.get('locked', False) + self.invitable = data.get('invitable', True) def _update(self, data): try: @@ -521,6 +526,7 @@ class Thread(Messageable, Hashable): name: str = MISSING, archived: bool = MISSING, locked: bool = MISSING, + invitable: bool = MISSING, slowmode_delay: int = MISSING, auto_archive_duration: ThreadArchiveDuration = MISSING, ) -> Thread: @@ -543,6 +549,9 @@ class Thread(Messageable, Hashable): Whether to archive the thread or not. locked: :class:`bool` Whether to lock the thread or not. + invitable: :class:`bool` + Whether non-moderators can add other non-moderators to this thread. + Only available for private threads. auto_archive_duration: :class:`int` The new duration in minutes before a thread is automatically archived for inactivity. Must be one of ``60``, ``1440``, ``4320``, or ``10080``. @@ -571,6 +580,8 @@ class Thread(Messageable, Hashable): payload['auto_archive_duration'] = auto_archive_duration if locked is not MISSING: payload['locked'] = locked + if invitable is not MISSING: + payload['invitable'] = invitable if slowmode_delay is not MISSING: payload['rate_limit_per_user'] = slowmode_delay diff --git a/discord/types/threads.py b/discord/types/threads.py index baf8def40..328be1310 100644 --- a/discord/types/threads.py +++ b/discord/types/threads.py @@ -41,6 +41,7 @@ class ThreadMember(TypedDict): class _ThreadMetadataOptional(TypedDict, total=False): archiver_id: Snowflake locked: bool + invitable: bool class ThreadMetadata(_ThreadMetadataOptional):