@@ -747,12 +747,15 @@ def get_voice_state(self, user_id: Optional["Snowflake_Type"]) -> Optional[Voice
747747 """
748748 return self .voice_state_cache .get (to_optional_snowflake (user_id ))
749749
750- async def place_voice_state_data (self , data : discord_typings .VoiceStateData ) -> Optional [VoiceState ]:
750+ async def place_voice_state_data (
751+ self , data : discord_typings .VoiceStateData , update_cache = True
752+ ) -> Optional [VoiceState ]:
751753 """
752754 Take json data representing a VoiceState, process it, and cache it.
753755
754756 Args:
755757 data: json representation of the VoiceState
758+ update_cache: Bool for updating cache or not
756759
757760 Returns:
758761 The processed VoiceState object
@@ -768,7 +771,7 @@ async def place_voice_state_data(self, data: discord_typings.VoiceStateData) ->
768771 # check if the channel_id is None
769772 # if that is the case, the user disconnected, and we can delete them from the cache
770773 if not data ["channel_id" ]:
771- if user_id in self .voice_state_cache :
774+ if update_cache and user_id in self .voice_state_cache :
772775 self .voice_state_cache .pop (user_id )
773776 voice_state = None
774777
@@ -780,7 +783,8 @@ async def place_voice_state_data(self, data: discord_typings.VoiceStateData) ->
780783 new_channel ._voice_member_ids .append (user_id )
781784
782785 voice_state = VoiceState .from_dict (data , self ._client )
783- self .voice_state_cache [user_id ] = voice_state
786+ if update_cache :
787+ self .voice_state_cache [user_id ] = voice_state
784788
785789 return voice_state
786790
0 commit comments