diff --git a/src/modules/sendAiResponse.ts b/src/modules/sendAiResponse.ts index a3c627f..4a9369a 100644 --- a/src/modules/sendAiResponse.ts +++ b/src/modules/sendAiResponse.ts @@ -19,9 +19,17 @@ export const sendAiResponse = async( send: GuildTextBasedChannel["send"] | DMChannel["send"] | Message["reply"], type: GuildTextBasedChannel["sendTyping"], ): Promise => { - for (const line of content) { - await send(line); - await type(); - await sleep(2500); + const joined = content.join("\n\n"); + if (joined.length < 4000) { + await send(joined); + return; + } + const chunks = joined.match(/[\S\s]{1,4000}/g); + if (chunks) { + for (const chunk of chunks) { + await send(chunk); + await type(); + await sleep(2500); + } } };