Add files via upload

This commit is contained in:
2025-08-30 18:05:01 +02:00
committed by GitHub
commit f22d04aa81
15 changed files with 2066 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const db = require('../../functions/database/db.js'); // instance mysql2/promise
module.exports = {
category: 'moderation',
data: new SlashCommandBuilder()
.setName('casier')
.setDescription('Voir toutes les sanctions dun membre.')
.addUserOption(option =>
option.setName('membre')
.setDescription('Le membre dont tu veux voir le casier')
.setRequired(true)),
async execute(interaction) {
await interaction.deferReply({ ephemeral: true });
const member = interaction.options.getUser('membre');
try {
const [rows] = await db.query(
'SELECT * FROM logs WHERE userId = ? ORDER BY timestamp DESC',
[member.id]
);
if (!rows.length) return interaction.editReply(`${member.tag} na aucune sanction.`);
const embed = new EmbedBuilder()
.setTitle(`Casier de ${member.tag}`)
.setColor('Orange')
.setTimestamp();
rows.forEach((row, index) => {
const date = new Date(row.timestamp).toLocaleString();
const actionCapitalized = row.action.charAt(0).toUpperCase() + row.action.slice(1); // Ban/Unban
// Récupère le nom du serveur via l'ID si présent
const guildName = row.guildId
? interaction.client.guilds.cache.get(row.guildId)?.name || 'Unknown Server'
: 'Unknown Server';
embed.addFields({
name: `#${index + 1} - ${actionCapitalized}`,
value: `**Modérateur:** <@${row.modId}> (${row.modTag || 'N/A'})\n` +
`**Raison:** ${row.reason || 'N/A'}\n` +
`**Serveur:** ${guildName}\n` +
`**Date:** ${date}`,
inline: false
});
});
await interaction.editReply({ embeds: [embed] });
} catch (err) {
console.error(err);
await interaction.editReply('❌ Une erreur est survenue lors de la récupération du casier.');
}
},
};