Fix Client.fetch_channel not returning Thread

This commit is contained in:
Alex Nørgaard
2021-07-04 02:35:31 +01:00
committed by GitHub
parent 097b6064f1
commit d1dc41ec2f
7 changed files with 22 additions and 15 deletions

View File

@@ -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