How to limit my fields (embed)

Hello, i explain my problem (sry im french)
6 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Snokxx
Snokxx10mo ago
const sanctions = [];


for (const warning of warnings) {
sanctions.push({
type: "⚠️ - Avertissement",
moderator: warning.moderateurID,
assistant: warning.assistant,
id: warning.warnID,
membreID: warning.membreID,
reason: warning.raison,
date: warning.date,
});
}

for (const ban of bans) {
sanctions.push({
type: "⛔️ - Bannissement",
moderator: ban.moderateurID,
id: ban.banID,
membreID: ban.membreID,
reason: ban.raison,
date: ban.date,
});
}

for (const note of notes) {
sanctions.push({
type: "📄 - Note",
moderator: note.moderateurID,
assistant: note.assistant,
id: note.noteID,
membreID: note.membreID,
reason: note.raison,
date: note.date,
});
}

sanctions.sort((a, b) => parseInt(a.date) - parseInt(b.date));
const sanctions = [];


for (const warning of warnings) {
sanctions.push({
type: "⚠️ - Avertissement",
moderator: warning.moderateurID,
assistant: warning.assistant,
id: warning.warnID,
membreID: warning.membreID,
reason: warning.raison,
date: warning.date,
});
}

for (const ban of bans) {
sanctions.push({
type: "⛔️ - Bannissement",
moderator: ban.moderateurID,
id: ban.banID,
membreID: ban.membreID,
reason: ban.raison,
date: ban.date,
});
}

for (const note of notes) {
sanctions.push({
type: "📄 - Note",
moderator: note.moderateurID,
assistant: note.assistant,
id: note.noteID,
membreID: note.membreID,
reason: note.raison,
date: note.date,
});
}

sanctions.sort((a, b) => parseInt(a.date) - parseInt(b.date));
for (const sanction of sanctions) {
embedstaffrecent.setColor("#FF8000")
embedstaffrecent.addFields({
name: `${sanction.type} - (${sanctions.indexOf(sanction) + 1})`,
value: `> **Modérateur** : <@!${sanction.moderator}>\n> **SanctionID** : \`${sanction.id}\` **Assistant** : \`${sanction.assistant}\`\n> **Membre** : \`${sanction.membreID}\`\n> **Raison** : \`${sanction.reason}\`\n> **Date** : <t:${Math.floor(parseInt(sanction.date) / 1000)}:F>`,
});
}


await message.followUp({ embeds: [embedstaffrecent] });
for (const sanction of sanctions) {
embedstaffrecent.setColor("#FF8000")
embedstaffrecent.addFields({
name: `${sanction.type} - (${sanctions.indexOf(sanction) + 1})`,
value: `> **Modérateur** : <@!${sanction.moderator}>\n> **SanctionID** : \`${sanction.id}\` **Assistant** : \`${sanction.assistant}\`\n> **Membre** : \`${sanction.membreID}\`\n> **Raison** : \`${sanction.reason}\`\n> **Date** : <t:${Math.floor(parseInt(sanction.date) / 1000)}:F>`,
});
}


await message.followUp({ embeds: [embedstaffrecent] });
But, 1 sanctions = 1 field if my sanctions are more than 25 sanctions, i have more than 25 field (but 25 field max in 1 embeds) My question is : how to limit my field in this code ? i try this
for (let i = 0; i < Math.min(sanctions.length, 25); i++) {
for (let i = 0; i < Math.min(sanctions.length, 25); i++) {
but doesnt work :/
royc
royc10mo ago
can you show the code where you included for (let i = 0; i < Math.min(sanctions.length, 25); i++) {
Snokxx
Snokxx10mo ago
royc
royc10mo ago
this isn't a #djs-questions . You have a conceptual programming problem. Please open a thread in #other-js-ts and I'll reply with an answer there
Snokxx
Snokxx10mo ago
ok #How to limit my fields (embed)