From d5033b04a28da4afba21d37e5f9568f7616bdf3a Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 21 Aug 2021 14:47:08 -0400 Subject: [PATCH] Don't clear views in READY --- discord/state.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/discord/state.py b/discord/state.py index 680d112f7..ce5fdac27 100644 --- a/discord/state.py +++ b/discord/state.py @@ -215,7 +215,7 @@ class ConnectionState: self.clear() - def clear(self) -> None: + def clear(self, *, views: bool = True) -> None: self.user: Optional[ClientUser] = None # Originally, this code used WeakValueDictionary to maintain references to the # global user mapping. @@ -233,7 +233,9 @@ class ConnectionState: self._emojis: Dict[int, Emoji] = {} self._stickers: Dict[int, GuildSticker] = {} self._guilds: Dict[int, Guild] = {} - self._view_store: ViewStore = ViewStore(self) + if views: + self._view_store: ViewStore = ViewStore(self) + self._voice_clients: Dict[int, VoiceProtocol] = {} # LRU of max size 128 @@ -524,7 +526,7 @@ class ConnectionState: self._ready_task.cancel() self._ready_state = asyncio.Queue() - self.clear() + self.clear(views=False) self.user = ClientUser(state=self, data=data['user']) self.store_user(data['user'])