aboutsummaryrefslogtreecommitdiff
path: root/discord/channel.py
diff options
context:
space:
mode:
authorAlex Nørgaard <[email protected]>2021-07-04 02:35:31 +0100
committerGitHub <[email protected]>2021-07-03 21:35:31 -0400
commitd1dc41ec2f6e0e6e6489151f33a39b7fccfc8f6f (patch)
tree1f3e91c728e87df04dcb32fcda5927af719004ed /discord/channel.py
parentFix ui.Button constructor default style to match the decorator (diff)
downloaddiscord.py-d1dc41ec2f6e0e6e6489151f33a39b7fccfc8f6f.tar.xz
discord.py-d1dc41ec2f6e0e6e6489151f33a39b7fccfc8f6f.zip
Fix Client.fetch_channel not returning Thread
Diffstat (limited to 'discord/channel.py')
-rw-r--r--discord/channel.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 5a213fe1..dbe8533f 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -691,7 +691,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
type=ChannelType.public_thread.value,
)
- return Thread(guild=self.guild, data=data)
+ return Thread(guild=self.guild, state=self._state, data=data)
def archived_threads(
self,
@@ -753,7 +753,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
"""
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', [])]
+ return [Thread(guild=self.guild, state=self._state, data=d) for d in data.get('threads', [])]
class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
@@ -1924,3 +1924,9 @@ def _channel_factory(channel_type: Union[ChannelType, int]):
return GroupChannel, value
else:
return cls, value
+
+def _threaded_channel_factory(channel_type: Union[ChannelType, int]):
+ cls, value = _channel_factory(channel_type)
+ if value in (ChannelType.private_thread, ChannelType.public_thread, ChannelType.news_thread):
+ return Thread, value
+ return cls, value