diff --git a/discord/member.py b/discord/member.py index dfb20e4b4..5130a241b 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 diff --git a/discord/server.py b/discord/server.py index 0a22f38cd..aa3c230ab 100644 --- a/discord/server.py +++ b/discord/server.py @@ -31,7 +31,6 @@ from .game import Game from .channel import Channel from .enums import ServerRegion, Status from .mixins import Hashable -import copy class Server(Hashable): """Represents a Discord server. @@ -137,8 +136,9 @@ class Server(Hashable): def _update_voice_state(self, data): user_id = data.get('user_id') member = self.get_member(user_id) - before = copy.copy(member) + before = None if member is not None: + before = member._copy() ch_id = data.get('channel_id') channel = self.get_channel(ch_id) member._update_voice_state(voice_channel=channel, **data) diff --git a/discord/state.py b/discord/state.py index b59e16838..a0ce2b890 100644 --- a/discord/state.py +++ b/discord/state.py @@ -268,7 +268,7 @@ class ConnectionState: member = self._make_member(server, data) server._add_member(member) - old_member = copy.copy(member) + old_member = member._copy() member.status = data.get('status') try: member.status = Status(member.status) @@ -385,7 +385,7 @@ class ConnectionState: member = server.get_member(user_id) if member is not None: user = data['user'] - old_member = copy.copy(member) + old_member = member._copy() member.name = user['username'] member.discriminator = user['discriminator'] member.avatar = user['avatar']