Codex commited on
Commit ·
89e726d
1
Parent(s): 8a812eb
Shorten Circa pages to 15 props
Browse files- src/embeds.js +4 -20
src/embeds.js
CHANGED
|
@@ -515,27 +515,11 @@ function chunkLines(lines, maxLength = 1000) {
|
|
| 515 |
return chunks;
|
| 516 |
}
|
| 517 |
|
| 518 |
-
function chunkTextPages(lines,
|
| 519 |
const pages = [];
|
| 520 |
-
let
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
for (const line of lines) {
|
| 524 |
-
const nextLength = currentLength + line.length + (current.length > 0 ? 1 : 0);
|
| 525 |
-
if (current.length > 0 && nextLength > maxLength) {
|
| 526 |
-
pages.push(current.join('\n'));
|
| 527 |
-
current = [line];
|
| 528 |
-
currentLength = line.length;
|
| 529 |
-
} else {
|
| 530 |
-
current.push(line);
|
| 531 |
-
currentLength = nextLength;
|
| 532 |
-
}
|
| 533 |
-
}
|
| 534 |
-
|
| 535 |
-
if (current.length > 0) {
|
| 536 |
-
pages.push(current.join('\n'));
|
| 537 |
}
|
| 538 |
-
|
| 539 |
return pages;
|
| 540 |
}
|
| 541 |
|
|
@@ -557,7 +541,7 @@ export function buildCircaMarketEmbeds(snapshot, marketLabel, entries, options =
|
|
| 557 |
|
| 558 |
const footerBase = options.footerText ?? 'Latest parsed Circa market snapshot';
|
| 559 |
const pages = lines.length > 0
|
| 560 |
-
? chunkTextPages(lines,
|
| 561 |
: ['No parsed props were available for this market.'];
|
| 562 |
|
| 563 |
return pages.map((pageText, pageIndex) =>
|
|
|
|
| 515 |
return chunks;
|
| 516 |
}
|
| 517 |
|
| 518 |
+
function chunkTextPages(lines, pageSize = 15) {
|
| 519 |
const pages = [];
|
| 520 |
+
for (let index = 0; index < lines.length; index += pageSize) {
|
| 521 |
+
pages.push(lines.slice(index, index + pageSize).join('\n'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
}
|
|
|
|
| 523 |
return pages;
|
| 524 |
}
|
| 525 |
|
|
|
|
| 541 |
|
| 542 |
const footerBase = options.footerText ?? 'Latest parsed Circa market snapshot';
|
| 543 |
const pages = lines.length > 0
|
| 544 |
+
? chunkTextPages(lines, 15)
|
| 545 |
: ['No parsed props were available for this market.'];
|
| 546 |
|
| 547 |
return pages.map((pageText, pageIndex) =>
|