From 14fa3b06ffb84339a1f8b48ed41d7c4f5d35ea65 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 8 May 2023 15:45:05 +0200 Subject: [PATCH] Remove the abuse of looping functions --- llamabot.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llamabot.js b/llamabot.js index e70536b..22200a5 100644 --- a/llamabot.js +++ b/llamabot.js @@ -153,7 +153,12 @@ client.on('messageCreate', async (message) => { // if we are over the discord char limit we need chunks... if (response.length > limit) { + + const chunks = response.match(new RegExp(`.{1,${limit}}`, "g")); + if (chunks.length >= 15) return await message.channel.send("Response chunks too large. Try again"); + + for (let i = 0; i < chunks.length; i++) { setTimeout(() => { message.channel.send(chunks[i]);