first commit

This commit is contained in:
2025-06-21 15:13:58 -05:00
commit 07f75bbd93
37 changed files with 3125 additions and 0 deletions

View File

@ -0,0 +1,33 @@
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);
}
},
};

View File

@ -0,0 +1,48 @@
const { Events, GuildMember } = require("discord.js");
const db = require("../../db");
/**
* @param {Client} client
* @param {GuildMember} member
*/
module.exports = {
name: Events.GuildBanAdd,
async execute(member) {
const auditLogs = await member.guild.fetchAuditLogs({ type: 22 });
const banEntry = auditLogs.entries.first();
try {
if (banEntry) {
const { reason, executor, target, createdAt } = banEntry;
const guildID = member.guild.id;
const guildName = member.guild.name;
const userID = target.id;
const userName = target.username;
const userTag = target.tag;
const avatarURL = target.displayAvatarURL({ dynamic: true });
const banDate = createdAt.toISOString();
const banReason = reason || "No reason provided";
const banExecutor = executor.tag;
await db.query(
"INSERT INTO bans (guild_ID, guild_Name, user_ID, username, user_Tag, avatar_URL, ban_Date, ban_Reason, ban_Executor) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
[
guildID,
guildName,
userID,
userName,
userTag,
avatarURL,
banDate,
banReason,
banExecutor,
]
);
}
} catch (error) {
console.error("There was an error", error);
}
},
};