Browse Source

Add Thread.fetch_member

See: discord/discord-api-docs#3998
pull/7494/head
jack1142 3 years ago
committed by GitHub
parent
commit
9a6b2fa402
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      discord/http.py
  2. 21
      discord/threads.py

4
discord/http.py

@ -975,6 +975,10 @@ class HTTPClient:
route = Route('GET', '/guilds/{guild_id}/threads/active', guild_id=guild_id)
return self.request(route)
def get_thread_member(self, channel_id: Snowflake, user_id: Snowflake) -> Response[threads.ThreadMember]:
route = Route('GET', '/channels/{channel_id}/thread-members/{user_id}', channel_id=channel_id, user_id=user_id)
return self.request(route)
def get_thread_members(self, channel_id: Snowflake) -> Response[List[threads.ThreadMember]]:
route = Route('GET', '/channels/{channel_id}/thread-members', channel_id=channel_id)
return self.request(route)

21
discord/threads.py

@ -663,6 +663,27 @@ class Thread(Messageable, Hashable):
"""
await self._state.http.remove_user_from_thread(self.id, user.id)
async def fetch_member(self, user_id: int, /) -> ThreadMember:
"""|coro|
Retrieves a :class:`ThreadMember` for the given user ID.
Raises
-------
NotFound
The specified user is not a member of this thread.
HTTPException
Retrieving the member failed.
Returns
--------
:class:`ThreadMember`
The thread member from the user ID.
"""
data = await self._state.http.get_thread_member(self.id, user_id)
return ThreadMember(parent=self, data=data)
async def fetch_members(self) -> List[ThreadMember]:
"""|coro|

Loading…
Cancel
Save