@@ -747,12 +747,15 @@ def get_voice_state(self, user_id: Optional["Snowflake_Type"]) -> Optional[Voice
747
747
"""
748
748
return self .voice_state_cache .get (to_optional_snowflake (user_id ))
749
749
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 ]:
751
753
"""
752
754
Take json data representing a VoiceState, process it, and cache it.
753
755
754
756
Args:
755
757
data: json representation of the VoiceState
758
+ update_cache: Bool for updating cache or not
756
759
757
760
Returns:
758
761
The processed VoiceState object
@@ -768,7 +771,7 @@ async def place_voice_state_data(self, data: discord_typings.VoiceStateData) ->
768
771
# check if the channel_id is None
769
772
# if that is the case, the user disconnected, and we can delete them from the cache
770
773
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 :
772
775
self .voice_state_cache .pop (user_id )
773
776
voice_state = None
774
777
@@ -780,7 +783,8 @@ async def place_voice_state_data(self, data: discord_typings.VoiceStateData) ->
780
783
new_channel ._voice_member_ids .append (user_id )
781
784
782
785
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
784
788
785
789
return voice_state
786
790
0 commit comments