Browse Source

Allow pinning a thread using Thread.edit

pull/7855/head
Rapptz 3 years ago
parent
commit
a8b26b9257
  1. 1
      discord/http.py
  2. 7
      discord/threads.py

1
discord/http.py

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

7
discord/threads.py

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

Loading…
Cancel
Save