From 5061915b2ab032ca0c56fd27fad81dd4bd795679 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 17 Mar 2019 14:32:51 -0400 Subject: Add support for store channels. --- discord/guild.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'discord/guild.py') diff --git a/discord/guild.py b/discord/guild.py index 52199e52..5ccf293c 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -261,13 +261,15 @@ class Guild(Hashable): if 'channels' in data: channels = data['channels'] for c in channels: - if c['type'] == ChannelType.text.value or c['type'] == ChannelType.news.value: + 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: + elif c_type == ChannelType.voice.value: self._add_channel(VoiceChannel(guild=self, data=c, state=self._state)) - elif c['type'] == ChannelType.category.value: + 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)) @property def channels(self): @@ -359,7 +361,7 @@ class Guild(Hashable): as_list = [(_get(k), v) for k, v in grouped.items()] as_list.sort(key=key) for _, channels in as_list: - channels.sort(key=lambda c: (not isinstance(c, TextChannel), c.position, c.id)) + channels.sort(key=lambda c: (c._sorting_bucket, c.position, c.id)) return as_list def get_channel(self, channel_id): -- cgit v1.2.3