33 lines
974 B
JavaScript
33 lines
974 B
JavaScript
const { Events, GuildMember } = require("discord.js");
|
|
const { modLogEmbed } = require("../../embeds/modLogs");
|
|
|
|
|
|
|
|
module.exports = {
|
|
name: Events.GuildBanRemove,
|
|
async execute(member) {
|
|
try {
|
|
const auditLogs = await member.guild.fetchAuditLogs({ type: 23 });
|
|
const banEntry = auditLogs.entries.first();
|
|
const modLogsChannel = member.guild.channels.cache.find(channel => channel.name === 'mod-logs');
|
|
|
|
if (!banEntry) return;
|
|
|
|
const { target, executor, reason } = banEntry;
|
|
|
|
if (!modLogsChannel) return;
|
|
|
|
// Call modLogEmbed and send the embed
|
|
const embed = modLogEmbed("unban", member, reason || "No reason provided");
|
|
|
|
if (embed) {
|
|
await modLogsChannel.send({ embeds: [embed] });
|
|
//console.log(`Ban logged: ${target.tag} banned by ${executor.tag}`);
|
|
}
|
|
} catch (error) {
|
|
console.error(error);
|
|
}
|
|
|
|
|
|
},
|
|
}; |