From 53b48904358866e62c6afec1a548424f12c7e1d1 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 13 Sep 2017 09:38:05 -0400 Subject: Add category support. This adds: * CategoryChannel, which represents a category * Guild.by_category() which traverses the channels grouping by category * Guild.categories to get a list of categories * abc.GuildChannel.category to get the category a channel belongs to * sync_permissions keyword argument to abc.GuildChannel.edit to sync permissions with a pre-existing or new category * category keyword argument to abc.GuildChannel.edit to move a channel to a category --- discord/state.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'discord/state.py') diff --git a/discord/state.py b/discord/state.py index c470d11c..b145c7ec 100644 --- a/discord/state.py +++ b/discord/state.py @@ -484,6 +484,10 @@ class ConnectionState: def parse_channel_create(self, data): factory, ch_type = _channel_factory(data['type']) + if factory is None: + log.warning('CHANNEL_CREATE referencing an unknown channel type %s. Discarding.', data['type']) + return + channel = None if ch_type in (ChannelType.group, ChannelType.private): @@ -496,10 +500,6 @@ class ConnectionState: guild_id = utils._get_as_snowflake(data, 'guild_id') guild = self._get_guild(guild_id) if guild is not None: - if factory is None: - log.warning('CHANNEL_CREATE referencing an unknown channel type %s. Discarding.', data['type']) - return - channel = factory(guild=guild, state=self, data=data) guild._add_channel(channel) self.dispatch('guild_channel_create', channel) -- cgit v1.2.3