aboutsummaryrefslogtreecommitdiff
path: root/discord/member.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-07-23 05:18:56 -0400
committerRapptz <[email protected]>2016-07-23 05:18:56 -0400
commitb0e535771677fe34cefeec2716a7c4ed750e032f (patch)
tree77ce630b048dceebc18fad3ddd5dd2b5421c9bfd /discord/member.py
parentFix TypeError when constructing a channel in start_private_message. (diff)
downloaddiscord.py-b0e535771677fe34cefeec2716a7c4ed750e032f.tar.xz
discord.py-b0e535771677fe34cefeec2716a7c4ed750e032f.zip
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.
Diffstat (limited to 'discord/member.py')
-rw-r--r--discord/member.py11
1 files changed, 7 insertions, 4 deletions
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