From c3adb66de8f29431920831bd219e686f274f3a4f Mon Sep 17 00:00:00 2001 From: Chris Ham <431647+greenham@users.noreply.github.com> Date: Sat, 16 Aug 2025 15:13:43 -0700 Subject: [PATCH] Improve SFX list formatting and add smart markdown chunking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- sfx/README.md | 6 +++--- src/commands/prefix/sfx.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/sfx/README.md b/sfx/README.md index 2827d4f..0bc6c37 100644 --- a/sfx/README.md +++ b/sfx/README.md @@ -1,7 +1,7 @@ **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** @@ -112,8 +112,8 @@ algore, crush, cumin, dd, goldcaps bill ``` -**MISC** +**UTILITY** ``` -cd, cooler, slowmo-in, slowmo-out +cd, slowmo-in, slowmo-out ``` diff --git a/src/commands/prefix/sfx.js b/src/commands/prefix/sfx.js index bdf22b0..ba052aa 100644 --- a/src/commands/prefix/sfx.js +++ b/src/commands/prefix/sfx.js @@ -6,6 +6,39 @@ const voiceService = require('../../services/voiceService'); module.exports = { name: 'sfx', description: 'Play a sound effect', + + /** + * Smart chunking that respects markdown block boundaries + * @param {string} content + * @param {number} maxLength + * @returns {Array} + */ + 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) { // Check if SFX is allowed in this channel @@ -39,7 +72,8 @@ module.exports = { if (sfxListContent.length <= 2000) { await message.channel.send(sfxListContent); } 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) { await message.channel.send(chunk);