'use strict';

const { Events } = require('../../../util/Events.js');

module.exports = (client, { d: data }) => {
  const guild = client.guilds.cache.get(data.guild_id);
  if (guild) {
    guild.memberCount++;
    const member = guild.members._add(data);
    /**
     * Emitted whenever a user joins a guild.
     *
     * @event Client#guildMemberAdd
     * @param {GuildMember} member The member that has joined a guild
     */
    client.emit(Events.GuildMemberAdd, member);
  }
};
