mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-22 13:14:58 +05:00
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
const BaseEvent = require("../../base/BaseEvent");
|
|
|
|
class GuildMemberRemove extends BaseEvent {
|
|
constructor() {
|
|
super({
|
|
name: "guildMemberRemove",
|
|
once: false,
|
|
});
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {import("../../base/Client")} client
|
|
* @param {import("discord.js").GuildMember} member
|
|
*/
|
|
async execute(client, member) {
|
|
await member.guild.members.fetch();
|
|
|
|
const guildData = await client.getGuildData(member.guild.id);
|
|
|
|
if (guildData.plugins.goodbye.enabled) {
|
|
const channel = member.guild.channels.cache.get(guildData.plugins.goodbye.channel);
|
|
|
|
if (channel) {
|
|
const message = guildData.plugins.goodbye.message
|
|
.replace(/{user}/g, member.user.getUsername())
|
|
.replace(/{server}/g, member.guild.name)
|
|
.replace(/{membercount}/g, member.guild.memberCount);
|
|
|
|
await channel.send({ content: message }).catch(err => {
|
|
client.logger.error(`Failed to send goodbye message in channel ${channel.id}: ${err}`);
|
|
});
|
|
} else {
|
|
client.logger.warn(`Goodbye channel not found: ${guildData.plugins.goodbye.channel}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = GuildMemberRemove;
|