diff options
| author | Rapptz <[email protected]> | 2017-09-23 18:54:12 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-09-23 18:54:12 -0400 |
| commit | 148816c4e8316c2bcad49e81882d8a180734154a (patch) | |
| tree | af0d1ea87f1723e100b463ad479b2fb5ce11b648 | |
| parent | Changed discord.Client.event to debug log success instead of info log. (diff) | |
| download | discord.py-148816c4e8316c2bcad49e81882d8a180734154a.tar.xz discord.py-148816c4e8316c2bcad49e81882d8a180734154a.zip | |
Temporarily add created channels to cache.
This should fix issues when doing a `abc.GuildChannel.edit` immediately
afterwards and then when the corresponding CHANNEL_CREATE comes in the
channel instance should hopefully be overwritten by the authoritative
figure, the WebSocket.
| -rw-r--r-- | discord/guild.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/discord/guild.py b/discord/guild.py index 1ab9cea0..e241531f 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -601,7 +601,11 @@ class Guild(Hashable): The channel that was just created. """ data = yield from self._create_channel(name, overwrites, ChannelType.text, reason=reason) - return TextChannel(state=self._state, guild=self, data=data) + channel = TextChannel(state=self._state, guild=self, data=data) + + # temporarily add to the cache + self._channels[channel.id] = channel + return channel @asyncio.coroutine def create_voice_channel(self, name, *, overwrites=None, reason=None): @@ -610,7 +614,11 @@ class Guild(Hashable): Same as :meth:`create_text_channel` except makes a :class:`VoiceChannel` instead. """ data = yield from self._create_channel(name, overwrites, ChannelType.voice, reason=reason) - return VoiceChannel(state=self._state, guild=self, data=data) + channel = VoiceChannel(state=self._state, guild=self, data=data) + + # temporarily add to the cache + self._channels[channel.id] = channel + return channel @asyncio.coroutine def create_category(self, name, *, overwrites=None, reason=None): @@ -619,7 +627,11 @@ class Guild(Hashable): Same as :meth:`create_text_channel` except makes a :class:`CategoryChannel` instead. """ data = yield from self._create_channel(name, overwrites, ChannelType.category, reason=reason) - return CategoryChannel(state=self._state, guild=self, data=data) + channel = CategoryChannel(state=self._state, guild=self, data=data) + + # temporarily add to the cache + self._channels[channel.id] = channel + return channel create_category_channel = create_category |