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
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user