GuildMemberRemove.js (944B)
1 'use strict'; 2 3 const Action = require('./Action'); 4 const { Events, Status } = require('../../util/Constants'); 5 6 class GuildMemberRemoveAction extends Action { 7 handle(data, shard) { 8 const client = this.client; 9 const guild = client.guilds.cache.get(data.guild_id); 10 let member = null; 11 if (guild) { 12 member = this.getMember(data, guild); 13 guild.memberCount--; 14 if (member) { 15 member.deleted = true; 16 guild.members.cache.delete(member.id); 17 /** 18 * Emitted whenever a member leaves a guild, or is kicked. 19 * @event Client#guildMemberRemove 20 * @param {GuildMember} member The member that has left/been kicked from the guild 21 */ 22 if (shard.status === Status.READY) client.emit(Events.GUILD_MEMBER_REMOVE, member); 23 } 24 guild.voiceStates.cache.delete(data.user.id); 25 } 26 return { guild, member }; 27 } 28 } 29 30 module.exports = GuildMemberRemoveAction;