Browse Source

Fix crashing for now when a category is created.

A full implementation will come later.
pull/772/head
Rapptz 8 years ago
parent
commit
1367877d36
  1. 5
      discord/guild.py
  2. 4
      discord/state.py

5
discord/guild.py

@ -249,10 +249,11 @@ class Guild(Hashable):
for c in channels:
if c['type'] == ChannelType.text.value:
channel = TextChannel(guild=self, data=c, state=self._state)
else:
self._add_channel(channel)
elif c['type'] == ChannelType.voice.value:
channel = VoiceChannel(guild=self, data=c, state=self._state)
self._add_channel(channel)
self._add_channel(channel)
@property
def channels(self):

4
discord/state.py

@ -496,6 +496,10 @@ 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)

Loading…
Cancel
Save