Improve SFX list formatting and add smart markdown chunking
- Add smart chunking logic that respects markdown block boundaries - Prevent code blocks from being split across Discord messages - Update SFX list display to use improved README.md formatting - Ensure proper markdown rendering in Discord chat 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
**GENERAL**
|
**GENERAL**
|
||||||
|
|
||||||
```
|
```
|
||||||
2+2, ahhh, alert, aspen, auw, aww, bonk, bustin, chafe, chipotle, chomp, choochoo, correct, date, dong, duck, enjoy, ez, fakehands, fbrage, fine, flippers, funnyhow, gatekeepah, gcn, groovy, gyst, help, herewego, heyheyhey, heymf, highscore, hop, how, hype, idgaf, imawot, interesting, jacked, knob, lab, laugh, lisa, long, mad, massage, mayo, meme, mmmm, mouthfeel, mybody, neat, nevergiveup, obaeb, ohno, okusa, onejoint, onfire, ow, poopy, popup, porkchop, pour, ppump, qty, raffle, rawr, rentfree, respect, robotears, rpgfarm, sdgtw, sendit, sofast, sogood, stick, store, suh, swag, tasty, tea, thatthing, theline, tmm, tojesus, tootski, trash, triple, urf, wahwah, wanker, waow, wdied, wow, yahoo, yippee, yoshi, youguys
|
2+2, ahhh, alert, aspen, auw, aww, bonk, bustin, chafe, chipotle, chomp, choochoo, cooler, correct, date, dong, duck, enjoy, ez, fakehands, fbrage, fine, flippers, funnyhow, gatekeepah, gcn, groovy, gyst, help, herewego, heyheyhey, heymf, highscore, hop, how, hype, idgaf, imawot, interesting, jacked, knob, lab, laugh, lisa, long, mad, massage, mayo, meme, mmmm, mouthfeel, mybody, neat, nevergiveup, obaeb, ohno, okusa, onejoint, onfire, ow, poopy, popup, porkchop, pour, ppump, qty, raffle, rawr, rentfree, respect, robotears, rpgfarm, sdgtw, sendit, sofast, sogood, stick, store, suh, swag, tasty, tea, thatthing, theline, tmm, tojesus, tootski, trash, triple, urf, wahwah, wanker, waow, wdied, wow, yahoo, yippee, yoshi, youguys
|
||||||
```
|
```
|
||||||
|
|
||||||
**NERDS**
|
**NERDS**
|
||||||
@@ -112,8 +112,8 @@ algore, crush, cumin, dd, goldcaps
|
|||||||
bill
|
bill
|
||||||
```
|
```
|
||||||
|
|
||||||
**MISC**
|
**UTILITY**
|
||||||
|
|
||||||
```
|
```
|
||||||
cd, cooler, slowmo-in, slowmo-out
|
cd, slowmo-in, slowmo-out
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -7,6 +7,39 @@ module.exports = {
|
|||||||
name: 'sfx',
|
name: 'sfx',
|
||||||
description: 'Play a sound effect',
|
description: 'Play a sound effect',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smart chunking that respects markdown block boundaries
|
||||||
|
* @param {string} content
|
||||||
|
* @param {number} maxLength
|
||||||
|
* @returns {Array<string>}
|
||||||
|
*/
|
||||||
|
smartChunkMarkdown(content, maxLength) {
|
||||||
|
const chunks = [];
|
||||||
|
const sections = content.split(/(\*\*[^*]+\*\*)/); // Split on headers while keeping them
|
||||||
|
|
||||||
|
let currentChunk = '';
|
||||||
|
|
||||||
|
for (const section of sections) {
|
||||||
|
// If adding this section would exceed the limit
|
||||||
|
if (currentChunk.length + section.length > maxLength) {
|
||||||
|
// Save current chunk if it has content
|
||||||
|
if (currentChunk.trim()) {
|
||||||
|
chunks.push(currentChunk.trim());
|
||||||
|
}
|
||||||
|
currentChunk = section;
|
||||||
|
} else {
|
||||||
|
currentChunk += section;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the final chunk
|
||||||
|
if (currentChunk.trim()) {
|
||||||
|
chunks.push(currentChunk.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunks;
|
||||||
|
},
|
||||||
|
|
||||||
async execute(message, args, guildConfig) {
|
async execute(message, args, guildConfig) {
|
||||||
// Check if SFX is allowed in this channel
|
// Check if SFX is allowed in this channel
|
||||||
if (guildConfig.allowedSfxChannels) {
|
if (guildConfig.allowedSfxChannels) {
|
||||||
@@ -39,7 +72,8 @@ module.exports = {
|
|||||||
if (sfxListContent.length <= 2000) {
|
if (sfxListContent.length <= 2000) {
|
||||||
await message.channel.send(sfxListContent);
|
await message.channel.send(sfxListContent);
|
||||||
} else {
|
} else {
|
||||||
const chunks = chunkSubstr(sfxListContent, 1900); // Leave some buffer
|
// Smart chunking that respects markdown block boundaries
|
||||||
|
const chunks = this.smartChunkMarkdown(sfxListContent, 1900);
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
await message.channel.send(chunk);
|
await message.channel.send(chunk);
|
||||||
|
|||||||
Reference in New Issue
Block a user