diff --git a/commands/utility/afficher-lies.js b/commands/utility/afficher-lies.js index 6114b76..f699aa3 100644 --- a/commands/utility/afficher-lies.js +++ b/commands/utility/afficher-lies.js @@ -19,19 +19,19 @@ module.exports = { }); } - const embed = new EmbedBuilder() - .setColor(0x0099FF) - .setTitle('🔗 Liste des comptes liés') - .setDescription(`Total: **${links.length}** compte(s) lié(s)`) - .setTimestamp(); + const embeds = []; + const FIELDS_PER_EMBED = 24; // Maximum 25 fields par embed, on garde une marge - // 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)); - } + // Diviser les liens en chunks de 24 pour respecter la limite Discord + for (let i = 0; i < links.length; i += FIELDS_PER_EMBED) { + const chunk = links.slice(i, i + FIELDS_PER_EMBED); + + const embed = new EmbedBuilder() + .setColor(0x0099FF) + .setTitle(i === 0 ? '🔗 Liste des comptes liés' : `🔗 Liste des comptes liés (suite)`) + .setDescription(i === 0 ? `Total: **${links.length}** compte(s) lié(s)` : null) + .setTimestamp(); - 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.globalName ? user.globalName : user.username) : link.discord_username; @@ -44,9 +44,11 @@ module.exports = { inline: true }); } + + embeds.push(embed); } - await interaction.editReply({ embeds: [embed]}); + await interaction.editReply({ embeds }); } catch (error) { console.error('Erreur lors de la récupération des liaisons:', error);