aboutsummaryrefslogtreecommitdiff
path: root/discord/state.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-09-13 09:38:05 -0400
committerRapptz <[email protected]>2017-09-13 09:44:36 -0400
commit53b48904358866e62c6afec1a548424f12c7e1d1 (patch)
tree77d14c0e8e0bf62311f731e29bec9487cab684d3 /discord/state.py
parent[commands] Fix NameError when given an invalid prefix. (diff)
downloaddiscord.py-53b48904358866e62c6afec1a548424f12c7e1d1.tar.xz
discord.py-53b48904358866e62c6afec1a548424f12c7e1d1.zip
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
Diffstat (limited to 'discord/state.py')
-rw-r--r--discord/state.py8
1 files changed, 4 insertions, 4 deletions
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)