aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNCPlayz <[email protected]>2020-05-17 02:57:32 +0100
committerRapptz <[email protected]>2020-05-23 21:56:40 -0400
commit40a460460445d2c23199da263389852c9b103f1c (patch)
tree8077a2439de4c729c5daf1b5ff6cbcb8e5d821d9
parentisinstance(x, y) and isinstance(x, z) -> isinstance(x, (y, z)) (diff)
downloaddiscord.py-40a460460445d2c23199da263389852c9b103f1c.tar.xz
discord.py-40a460460445d2c23199da263389852c9b103f1c.zip
use `_channel_factory` instead of manual checking in `Guild._sync`
-rw-r--r--discord/guild.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/discord/guild.py b/discord/guild.py
index b5f8977c..8470f1bb 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -320,15 +320,9 @@ class Guild(Hashable):
if 'channels' in data:
channels = data['channels']
for c in channels:
- c_type = c['type']
- if c_type in (ChannelType.text.value, ChannelType.news.value):
- self._add_channel(TextChannel(guild=self, data=c, state=self._state))
- elif c_type == ChannelType.voice.value:
- self._add_channel(VoiceChannel(guild=self, data=c, state=self._state))
- elif c_type == ChannelType.category.value:
- self._add_channel(CategoryChannel(guild=self, data=c, state=self._state))
- elif c_type == ChannelType.store.value:
- self._add_channel(StoreChannel(guild=self, data=c, state=self._state))
+ factory, ch_type = _channel_factory(c['type'])
+ if factory:
+ self._add_channel(factory(guild=self, data=c, state=self._state))
@property
def channels(self):