Skip to content

Commit

Permalink
Fixed edge case where embed is > 4096 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
coopw1 committed Jan 22, 2024
1 parent d0e07e5 commit 1eac1ba
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/commands/general/big.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = {
description: "Max number of listens to get! Caps at 5000 by default.",
type: ApplicationCommandOptionType.Integer,
required: false,
minValue: 1000,
},
],
},
Expand Down Expand Up @@ -117,8 +116,19 @@ module.exports = {

let embeds = [];
for (let i = 0; i < maxPages; i++) {
embeds[i] = new EmbedBuilder(baseEmbed).setDescription(descriptions[i]);
if (descriptions[i].length > 4096) {
embeds.push(
new EmbedBuilder(baseEmbed)
.setDescription(descriptions[i].slice(0, 4096))
.addFields({ name: "Overflow", value: descriptions[i].slice(4096) })
);
} else {
embeds.push(
new EmbedBuilder(baseEmbed).setDescription(descriptions[i])
);
}
}

pagination(
interaction,
embeds,
Expand Down

0 comments on commit 1eac1ba

Please sign in to comment.