59 lines
2.3 KiB
JavaScript
59 lines
2.3 KiB
JavaScript
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require('discord.js');
|
|
const { getAllLinks } = require('../../database.js');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('check-linked')
|
|
.setDescription('Afficher tous les comptes liés (Admin uniquement)')
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
|
|
|
|
async execute(interaction) {
|
|
try {
|
|
await interaction.deferReply({ ephemeral: true });
|
|
|
|
const links = await getAllLinks();
|
|
|
|
if (links.length === 0) {
|
|
return interaction.editReply({
|
|
content: '📝 Aucun compte lié pour le moment.',
|
|
ephemeral: true
|
|
});
|
|
}
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor(0x0099FF)
|
|
.setTitle('🔗 Liste des comptes liés')
|
|
.setDescription(`Total: **${links.length}** compte(s) lié(s)`)
|
|
.setTimestamp();
|
|
|
|
// Diviser en plusieurs embeds si nécessaire (limite de 25 fields)
|
|
const chunks = [];
|
|
for (let i = 0; i < links.length; i += 10) {
|
|
chunks.push(links.slice(i, i + 10));
|
|
}
|
|
|
|
for (const chunk of chunks) {
|
|
for (const link of chunk) {
|
|
const user = await interaction.client.users.fetch(link.discord_id).catch(() => null);
|
|
const discordName = user ? user.tag : link.discord_username;
|
|
|
|
embed.addFields({
|
|
name: `👤 ${discordName}`,
|
|
value: `🎮 Palworld: **${link.palworld_username}**\n🆔 Steam ID: \`${link.steam_id}\`\n🎯 Player ID: \`${link.player_id || 'N/A'}\`\n📅 Lié le: ${new Date(link.linked_at).toLocaleDateString('fr-FR')}`,
|
|
inline: false
|
|
});
|
|
}
|
|
}
|
|
|
|
await interaction.editReply({ embeds: [embed], ephemeral: true });
|
|
|
|
} catch (error) {
|
|
console.error('Erreur lors de la récupération des liaisons:', error);
|
|
await interaction.editReply({
|
|
content: '❌ Une erreur est survenue lors de la récupération des liaisons.',
|
|
ephemeral: true
|
|
});
|
|
}
|
|
},
|
|
};
|