Files
SupportBot/events/guildMemberRemove.js
T

51 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

2020-12-18 13:37:56 +00:00
// SupportBot 6.0, Created by Emerald Services
// Ready Event
2020-06-21 15:56:16 +01:00
const Discord = require("discord.js");
const fs = require("fs");
const yaml = require('js-yaml');
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
module.exports = async (bot, member) => {
2021-05-23 10:40:32 +02:00
if (supportbot.SystemMessages) {
2021-10-04 13:54:30 +01:00
const SystemChannel = member.guild.channels.cache.find(channel => channel.name === supportbot.UserDeparted_Channel) || member.guild.channels.cache.get(supportbot.UserDeparted_Channel)
2020-06-21 15:56:16 +01:00
if (!SystemChannel) return;
2021-10-04 13:54:30 +01:00
console.log(`\u001b[31m.`, `[${supportbot.Bot_Name}]: ${member.user.username} has left ${member.guild.name}!`)
2020-06-21 15:56:16 +01:00
2021-10-04 13:54:30 +01:00
if (supportbot.UserDeparted_Type === "embed") {
2020-06-21 15:56:16 +01:00
const GuildRemoveMember = new Discord.MessageEmbed()
2021-10-04 13:54:30 +01:00
.setTitle(supportbot.Departed_Title)
.setDescription(supportbot.DepartedMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name))
2020-06-21 15:56:16 +01:00
.setColor(supportbot.EmbedColour)
if (supportbot.SystemMessage_Icon === "BOT") {
2020-08-02 13:53:14 +01:00
GuildRemoveMember.setThumbnail(bot.user.displayAvatarURL())
2020-06-21 15:56:16 +01:00
}
if (supportbot.SystemMessage_Icon === "USER") {
2020-08-02 13:53:14 +01:00
GuildRemoveMember.setThumbnail(member.user.displayAvatarURL())
2020-06-21 15:56:16 +01:00
}
2021-10-04 13:54:30 +01:00
if (supportbot.SystemMessage_Icon === "CUSTOM") {
SuggestionMessage.setThumbnail(supportbot.SystemMessageIcon_URL)
}
2020-06-21 15:56:16 +01:00
2021-10-04 13:54:30 +01:00
if (supportbot.SystemMessage_EmbedFooter) {
2020-08-02 13:53:14 +01:00
GuildRemoveMember.setFooter(supportbot.EmbedFooter)
2020-06-21 15:56:16 +01:00
}
2021-10-04 13:54:30 +01:00
SystemChannel.send({ embeds: [GuildRemoveMember] });
2020-06-21 15:56:16 +01:00
}
if (supportbot.SystemMessage_Type === "normal") {
2021-10-04 13:54:30 +01:00
SystemChannel.send({content: supportbot.DepartedMessage.replace(/%member%/g, member.user.username).replace(/%guildname%/g, member.guild.name)})
2020-06-21 15:56:16 +01:00
}
}
};