From 4b51e3e253fba8b9e45ab15d6c6d4722f40bc0d6 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 5 May 2021 20:55:49 -0400 Subject: [PATCH] Add TextChannel.active_threads --- discord/channel.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/discord/channel.py b/discord/channel.py index 058cd3cb2..9b1825f90 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -704,6 +704,26 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): """ return ArchivedThreadIterator(self.id, self.guild, limit=limit, joined=joined, private=private, before=before) + async def active_threads(self) -> List[Thread]: + """|coro| + + Returns a list of active :class:`Thread` that the client can access. + + This includes both private and public threads. + + Raises + ------ + HTTPException + The request to get the active threads failed. + + Returns + -------- + List[:class:`Thread`] + The archived threads + """ + data = await self._state.http.get_active_threads(self.id) + # TODO: thread members? + return [Thread(guild=self.guild, data=d) for d in data.get('threads', [])] class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable): __slots__ = ('name', 'id', 'guild', 'bitrate', 'user_limit',