Add Thread.members and Thread.fetch_members
This commit is contained in:
parent
b73f02b9c3
commit
68453c7bed
@ -217,6 +217,16 @@ class Thread(Messageable, Hashable):
|
|||||||
""":class:`str`: The string that allows you to mention the thread."""
|
""":class:`str`: The string that allows you to mention the thread."""
|
||||||
return f'<#{self.id}>'
|
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
|
@property
|
||||||
def last_message(self) -> Optional[Message]:
|
def last_message(self) -> Optional[Message]:
|
||||||
"""Fetches the last message from this channel in cache.
|
"""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)
|
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):
|
async def delete(self):
|
||||||
"""|coro|
|
"""|coro|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user