Skip to content

Commit

Permalink
fix(Member): Update member/user from voice state updates (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah authored Jul 20, 2024
1 parent 793e858 commit bcf7dee
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/structures/Member.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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() {
Expand Down

0 comments on commit bcf7dee

Please sign in to comment.