From bcf7dee617e42d8109b702176e5707a174136153 Mon Sep 17 00:00:00 2001 From: Snazzah <7025343+Snazzah@users.noreply.github.com> Date: Sat, 20 Jul 2024 09:48:29 -0500 Subject: [PATCH] fix(Member): Update member/user from voice state updates (#1521) --- lib/structures/Member.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/structures/Member.js b/lib/structures/Member.js index 83a0b77c6..abeae423f 100644 --- a/lib/structures/Member.js +++ b/lib/structures/Member.js @@ -78,6 +78,18 @@ class Member extends Base { } update(data) { + // Handle updates from voice states + if(data.hasOwnProperty("member") && data.hasOwnProperty("channel_id") && this.guild) { + const state = this.guild.voiceStates.get(this.id); + if(data.channel_id === null && !data.mute && !data.deaf && !data.suppress) { + this.guild.voiceStates.delete(this.id); + } else if(state) { + state.update(data); + } else if(data.channel_id || data.mute || data.deaf || data.suppress) { + this.guild.voiceStates.update(data); + } + data = data.member; + } if(data.status !== undefined) { this.status = data.status; } @@ -93,16 +105,6 @@ class Member extends Base { if(data.premium_since !== undefined) { this.premiumSince = data.premium_since === null ? null : Date.parse(data.premium_since); } - if(data.hasOwnProperty("mute") && this.guild) { - const state = this.guild.voiceStates.get(this.id); - if(data.channel_id === null && !data.mute && !data.deaf) { - this.guild.voiceStates.delete(this.id); - } else if(state) { - state.update(data); - } else if(data.channel_id || data.mute || data.deaf || data.suppress) { - this.guild.voiceStates.update(data); - } - } if(data.nick !== undefined) { this.nick = data.nick; } @@ -125,6 +127,9 @@ class Member extends Base { if(data.flags !== undefined) { this.flags = data.flags; } + if(data.user !== undefined) { + this.user.update(data.user); + } } get accentColor() {