Allow pinning a thread using Thread.edit

This commit is contained in:
Rapptz 2022-04-06 23:20:45 -04:00
parent 92eb9d7d8e
commit a8b26b9257
2 changed files with 8 additions and 0 deletions

View File

@ -883,6 +883,7 @@ class HTTPClient:
'locked',
'invitable',
'default_auto_archive_duration',
'flags',
)
payload = {k: v for k, v in options.items() if k in valid_keys}
return self.request(r, reason=reason, json=payload)

View File

@ -514,6 +514,7 @@ class Thread(Messageable, Hashable):
archived: bool = MISSING,
locked: bool = MISSING,
invitable: bool = MISSING,
pinned: bool = MISSING,
slowmode_delay: int = MISSING,
auto_archive_duration: ThreadArchiveDuration = MISSING,
) -> Thread:
@ -536,6 +537,8 @@ class Thread(Messageable, Hashable):
Whether to archive the thread or not.
locked: :class:`bool`
Whether to lock the thread or not.
pinned: :class:`bool`
Whether to pin the thread or not. This only works if the thread is part of a forum.
invitable: :class:`bool`
Whether non-moderators can add other non-moderators to this thread.
Only available for private threads.
@ -571,6 +574,10 @@ class Thread(Messageable, Hashable):
payload['invitable'] = invitable
if slowmode_delay is not MISSING:
payload['rate_limit_per_user'] = slowmode_delay
if pinned is not MISSING:
flags = self.flags
flags.pinned = pinned
payload['flags'] = flags.value
data = await self._state.http.edit_channel(self.id, **payload)
# The data payload will always be a Thread payload