Files
BluBot/events/guildBanAdd/chatlog.js
2025-06-21 15:13:58 -05:00

33 lines
969 B
JavaScript

const { Events, GuildMember } = require("discord.js");
const { modLogEmbed } = require("../../embeds/modLogs");
module.exports = {
name: Events.GuildBanAdd,
async execute(member) {
try {
const auditLogs = await member.guild.fetchAuditLogs({ type: 22 });
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("ban", 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);
}
},
};