From 1ad6c07054f7e9815c8fd0ad2eaf5ef3d852c0d0 Mon Sep 17 00:00:00 2001 From: dolfies Date: Mon, 8 Nov 2021 17:36:21 -0500 Subject: [PATCH] Add _private_channel_factory --- discord/channel.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/discord/channel.py b/discord/channel.py index 1effb9623..b9d87165c 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1884,7 +1884,7 @@ class GroupChannel(discord.abc.Messageable, discord.abc.Connectable, Hashable): def _get_voice_client_key(self) -> Tuple[int, str]: return self.me.id, 'self_id' - def _get_voice_state_pair(self) Tuple[int, int]: + def _get_voice_state_pair(self) -> Tuple[int, int]: return self.me.id, self.id async def _get_channel(self): @@ -2168,14 +2168,21 @@ def _guild_channel_factory(channel_type: int): return None, value -def _channel_factory(channel_type: int): - cls, value = _guild_channel_factory(channel_type) +def _private_channel_factory(channel_type: int): + value = try_enum(ChannelType, channel_type) if value is ChannelType.private: return DMChannel, value elif value is ChannelType.group: return GroupChannel, value else: - return cls, value + return None, value + + +def _channel_factory(channel_type: int): + cls, value = _guild_channel_factory(channel_type) + if cls is None: + cls, value = _private_channel_factory(channel_type) + return cls, value def _threaded_channel_factory(channel_type: int):