Update Bot

This commit is contained in:
Syxpi
2025-09-07 17:02:01 +02:00
parent 207d4e8356
commit da3d85b6bc
4441 changed files with 646084 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const db = require('../../functions/database/db.js'); // instance mysql2/promise
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const db = require('../../functions/database/db.js');
module.exports = {
category: 'moderation',
@@ -24,31 +24,59 @@ module.exports = {
if (!rows.length) return interaction.editReply(`${member.tag} na aucune sanction.`);
const embed = new EmbedBuilder()
.setTitle(`Casier de ${member.tag}`)
.setColor('Orange')
.setTimestamp();
// Découpe les sanctions en pages de 25
const pages = [];
for (let i = 0; i < rows.length; i += 10) {
pages.push(rows.slice(i, i + 10));
}
rows.forEach((row, index) => {
const date = new Date(row.timestamp).toLocaleString();
const actionCapitalized = row.action.charAt(0).toUpperCase() + row.action.slice(1); // Ban/Unban
const embeds = pages.map((page, pageIndex) => {
const embed = new EmbedBuilder()
.setTitle(`Casier de ${member.tag} - Page ${pageIndex + 1}/${pages.length}`)
.setColor('Orange')
.setTimestamp();
// 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';
page.forEach((row, index) => {
const date = new Date(row.timestamp).toLocaleString();
const actionCapitalized = row.action.charAt(0).toUpperCase() + row.action.slice(1);
const action = row.action || 'N/A';
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
embed.addFields({
name: `#${index + 1 + pageIndex * 10} - ${actionCapitalized}`,
value: `**Modérateur:** <@${row.modId}> (${row.modTag || 'N/A'})\n` +
`**Raison:** ${row.reason || 'N/A'}\n` +
`**Serveur:** ${guildName}\n` +
`**Date:** ${date}\n` +
`**Type:** ${action}`,
inline: false
});
});
return embed;
});
await interaction.editReply({ embeds: [embed] });
// Composants pour naviguer
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId('prev').setLabel('⬅️').setStyle(ButtonStyle.Primary),
new ButtonBuilder().setCustomId('next').setLabel('➡️').setStyle(ButtonStyle.Primary)
);
let currentPage = 0;
const message = await interaction.editReply({ embeds: [embeds[currentPage]], components: [row] });
// Collecteur de boutons
const collector = message.createMessageComponentCollector({ time: 60_000 });
collector.on('collect', i => {
if (i.user.id !== interaction.user.id) return i.reply({ content: 'Ce nest pas ton menu !', ephemeral: true });
if (i.customId === 'next') currentPage = (currentPage + 1) % embeds.length;
if (i.customId === 'prev') currentPage = (currentPage - 1 + embeds.length) % embeds.length;
i.update({ embeds: [embeds[currentPage]] });
});
} catch (err) {
console.error(err);