aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2021-08-18 01:57:07 -0400
committerRapptz <[email protected]>2021-08-18 01:58:16 -0400
commit68453c7bed7c18682c6146c50e011693cb99fe72 (patch)
treef83951879e6bea59b40697ca349d24f357333069
parentRemove deprecated TextChannel.active_threads for Guild version (diff)
downloaddiscord.py-68453c7bed7c18682c6146c50e011693cb99fe72.tar.xz
discord.py-68453c7bed7c18682c6146c50e011693cb99fe72.zip
Add Thread.members and Thread.fetch_members
-rw-r--r--discord/threads.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/discord/threads.py b/discord/threads.py
index a8d33f67..0550916c 100644
--- a/discord/threads.py
+++ b/discord/threads.py
@@ -218,6 +218,16 @@ class Thread(Messageable, Hashable):
return f'<#{self.id}>'
@property
+ def members(self) -> List[ThreadMember]:
+ """List[:class:`ThreadMember`]: A list of thread members in this thread.
+
+ This requires :attr:`Intents.members` to be properly filled. Most of the time however,
+ this data is not provided by the gateway and a call to :meth:`fetch_members` is
+ needed.
+ """
+ return list(self._members.values())
+
+ @property
def last_message(self) -> Optional[Message]:
"""Fetches the last message from this channel in cache.
@@ -636,6 +646,28 @@ class Thread(Messageable, Hashable):
"""
await self._state.http.remove_user_from_thread(self.id, user.id)
+ async def fetch_members(self) -> List[ThreadMember]:
+ """|coro|
+
+ Retrieves all :class:`ThreadMember` that are in this thread.
+
+ This requires :attr:`Intents.members` to get information about members
+ other than yourself.
+
+ Raises
+ -------
+ HTTPException
+ Retrieving the members failed.
+
+ Returns
+ --------
+ List[:class:`ThreadMember`]
+ All thread members in the thread.
+ """
+
+ members = await self._state.http.get_thread_members(self.id)
+ return [ThreadMember(parent=self, data=data) for data in members]
+
async def delete(self):
"""|coro|