guildinfo: split features based on field size

This commit is contained in:
Cynthia Foxwell 2025-04-18 10:46:51 -06:00
parent ef39082d43
commit 2167ae4725
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -369,17 +369,24 @@ guildinfo.callback = async function (msg, line, args, {nolocal, debug}) {
const features = formatGuildFeatures(guild.features); const features = formatGuildFeatures(guild.features);
embed.fields.push({ if (features.length > 0) {
name: `Features (${features.length})`, let featuresList = "";
value: features.length > 0 ? features.slice(0, Math.ceil(features.length / 2)).join("\n") : "None", let firstFeature = false;
inline: true, for (const index in features) {
}); const feature = features[index];
if (features.length > 1) if (featuresList.length + feature.length + 1 > 1024 || index === features.length - 1) {
embed.fields.push({ embed.fields.push({
name: "\u200b", name: firstFeature ? `Features (${features.length})` : "\u200b",
value: features.slice(Math.ceil(features.length / 2), features.length).join("\n"), value: featuresList.trim(),
inline: true, inline: true,
}); });
featuresList = "";
if (!firstFeature) firstFeature = true;
} else {
featuresList += feature + "\n";
}
}
}
const images = []; const images = [];
if (guild.icon) { if (guild.icon) {