From b0e535771677fe34cefeec2716a7c4ed750e032f Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 23 Jul 2016 05:18:56 -0400 Subject: Fix voice state update issue in on_voice_state_update Bug was caused to the shallow copy not copying over the VoiceState information embedded into the copy. This would mean that when the event is called, before and after voice state information is essentially equivalent. The solution to fix this is to also copy the VoiceState objects. --- discord/member.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'discord/member.py') diff --git a/discord/member.py b/discord/member.py index dfb20e4b..5130a241 100644 --- a/discord/member.py +++ b/discord/member.py @@ -29,6 +29,7 @@ from .game import Game from . import utils from .enums import Status, ChannelType from .colour import Colour +import copy class VoiceState: """Represents a Discord user's voice state. @@ -63,10 +64,7 @@ class VoiceState: self.is_afk = kwargs.get('suppress', False) self.mute = kwargs.get('mute', False) self.deaf = kwargs.get('deaf', False) - self._handle_voice_channel(kwargs.get('voice_channel'), kwargs.get('user_id')) - - def _handle_voice_channel(self, voice_channel, user_id): - self.voice_channel = voice_channel + self.voice_channel = kwargs.get('voice_channel') def flatten_voice_states(cls): for attr in VoiceState.__slots__: @@ -142,6 +140,11 @@ class Member(User): self.voice.voice_channel = vc + def _copy(self): + ret = copy.copy(self) + ret.voice = copy.copy(self.voice) + return ret + @property def colour(self): """A property that returns a :class:`Colour` denoting the rendered colour -- cgit v1.2.3