2020-01-25 10:02:43 +00:00
|
|
|
|
module.exports = async (client, member) => {
|
|
|
|
|
const settings = client.getSettings(member.guild.id);
|
|
|
|
|
|
|
|
|
|
if (settings.leaveMessage !== "off") {
|
2020-03-09 01:11:33 +00:00
|
|
|
|
let chanExists = member.guild.channels.cache.get(settings.welcomeChannel)
|
2020-01-25 10:02:43 +00:00
|
|
|
|
if (!chanExists) {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
leaveMessage = settings.leaveMessage.replace("[[user]]", member.user);
|
|
|
|
|
leaveMessage = leaveMessage.replace("[[server]]", member.guild.name);
|
|
|
|
|
leaveMessage = leaveMessage.replace("[[members]]", member.guild.memberCount);
|
|
|
|
|
|
|
|
|
|
member.guild.channels
|
2020-03-09 01:11:33 +00:00
|
|
|
|
.cache.get(settings.welcomeChannel)
|
2020-01-25 10:02:43 +00:00
|
|
|
|
.send(leaveMessage)
|
|
|
|
|
.catch(console.error);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (settings.chatlogsChannel !== "off") {
|
2020-03-09 01:11:33 +00:00
|
|
|
|
const channel = member.guild.channels.cache.find(
|
2020-01-25 10:02:43 +00:00
|
|
|
|
channel => channel.name === settings.chatlogsChannel
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (channel) {
|
2020-03-09 01:11:33 +00:00
|
|
|
|
let embed = new Discord.MessageEmbed();
|
2020-01-25 10:02:43 +00:00
|
|
|
|
embed.setColor("#006798");
|
2020-03-09 01:11:33 +00:00
|
|
|
|
embed.setAuthor("User left:", member.user.avatarURL({dynamic: true}));
|
2020-01-25 10:02:43 +00:00
|
|
|
|
embed.setDescription(`❯ ${member.user.tag} (${member.user.id})`, true);
|
|
|
|
|
try {
|
|
|
|
|
channel.send({ embed });
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// probably no permissions to send messages/embeds there
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|