mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 16:51:59 +00:00
Don't unnecessarily re-create private channels.
New API change[1] will make it so CHANNEL_CREATE will keep getting sent for private channels, so might as well avoid the overhead of constantly creating the channel if we can avoid it. [1]: https://github.com/hammerandchisel/discord-api-docs/issues/184
This commit is contained in:
parent
c220b3faa4
commit
169f3a8322
@ -469,10 +469,13 @@ class ConnectionState:
|
||||
def parse_channel_create(self, data):
|
||||
factory, ch_type = _channel_factory(data['type'])
|
||||
channel = None
|
||||
|
||||
if ch_type in (ChannelType.group, ChannelType.private):
|
||||
channel = factory(me=self.user, data=data, state=self)
|
||||
self._add_private_channel(channel)
|
||||
self.dispatch('private_channel_create', channel)
|
||||
channel_id = int(data['id'])
|
||||
if self._get_private_channel(channel_id) is None:
|
||||
channel = factory(me=self.user, data=data, state=self)
|
||||
self._add_private_channel(channel)
|
||||
self.dispatch('private_channel_create', channel)
|
||||
else:
|
||||
guild_id = utils._get_as_snowflake(data, 'guild_id')
|
||||
guild = self._get_guild(guild_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user