first commit
This commit is contained in:
33
events/guildBanRemove/chatlog.js
Normal file
33
events/guildBanRemove/chatlog.js
Normal file
@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user