fix(Guild): remove member's voice state on guildMemberRemove

fixes #2430
This commit is contained in:
Pascal
2018-04-09 17:43:07 +02:00
parent b3ff7c728e
commit b955a514f6
2 changed files with 10 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ class GuildMemberRemoveAction extends Action {
member = guild.members.get(data.user.id);
guild.memberCount--;
if (member) {
guild.voiceStates.delete(member.id);
guild.members.remove(member.id);
if (client.status === Status.READY) client.emit(Events.GUILD_MEMBER_REMOVE, member);
}

View File

@@ -1033,6 +1033,15 @@ class VoiceStateCollection extends Collection {
}
super.set(id, voiceState);
}
delete(id) {
const voiceState = this.get(id);
if (voiceState && voiceState.channel_id) {
const channel = this.guild.channels.get(voiceState.channel_id);
if (channel) channel.members.delete(id);
}
return super.delete(id);
}
}
module.exports = Guild;