Refactor pagination logic in index.js

This commit is contained in:
Christopher Cookman 2024-05-08 09:28:22 -06:00
parent e2a328e53b
commit 0733b37995
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -545,7 +545,7 @@ discord.on("interactionCreate", async (interaction) => {
} }
// Retruns raw text, paginate it into multiple embeds if needed // Retruns raw text, paginate it into multiple embeds if needed
res.text().then((text) => { res.text().then((text) => {
const pages = text.match(/[\s\S]{1,2000}(?=\s|$)/g); const pages = text.match(/[\s\S]{1,2000}(?=\n|$)/g);
const embeds = pages.map((page, ind) => ({ const embeds = pages.map((page, ind) => ({
title: `Product Text for ${product_id} Pg ${ind + 1}/${pages.length}`, title: `Product Text for ${product_id} Pg ${ind + 1}/${pages.length}`,
description: `\`\`\`${page}\`\`\``, description: `\`\`\`${page}\`\`\``,