const Log = require("../util/log.js");
const common = require("../util/common.js");
const setting_global = require("../settings.json");
const setting_color = setting_global.commands.user.guilds.color;
const setting_mute = setting_global.commands.admin.mute;
const setting = setting_global.events.memberAdd;

module.exports = (client, member) => {
    Log.memberAdd(member.user);
    if (setting.welcomeMessage.enabled)
        common.getChannel(client, setting.welcomeMessage.channel)
            .send(setting.welcomeMessage.template[
                common.getRandom(0, setting.welcomeMessage.template.length)]
                .replace("{user}", member.user));
                .find("name", role)));
    if (setting.autoRole.random_color)
        member.addRole(member.guild.roles
            .find("name", setting_color.colors[common.getRandom(0, setting_color.colors.length)].role));
    if (client.muted && setting.auto_mute)
    {
        let time = client.muted[member.id];
        if (time)
            member.addRole(member.guild.find("name", setting_mute.role));
    }
};
    if (setting.autoRole.role)
        setting.autoRole.role.forEach((role) =>
            member.addRole(member.guild.roles