From 42f6e79df80716092c15b779eb3791f37498b682 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Wed, 21 Oct 2020 21:00:45 +0300 Subject: [PATCH] Remove faulty message chunking logic in user DMs The logic could cause things like code blocks get cut in the middle without being handled gracefully. With this change, messages sent to the user can take, at most, 1 message. This does not affect messages in the thread channel. --- src/data/Thread.js | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/data/Thread.js b/src/data/Thread.js index a84734e..fdb789a 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -73,29 +73,7 @@ class Thread { throw new Error("Could not open DMs with the user. They may have blocked the bot or set their privacy settings higher."); } - let firstMessage; - - if (typeof content === "string") { - // Content is a string, chunk it and send it as individual messages. - // Files (attachments) are only sent with the last message. - const chunks = utils.chunk(content, 2000); - for (const [i, chunk] of chunks.entries()) { - let msg; - if (i === chunks.length - 1) { - // Only send embeds, files, etc. with the last message - msg = await dmChannel.createMessage(chunk, file); - } else { - msg = await dmChannel.createMessage(chunk); - } - - firstMessage = firstMessage || msg; - } - } else { - // Content is a full message content object, send it as-is with the files (if any) - firstMessage = await dmChannel.createMessage(content, file); - } - - return firstMessage; + return dmChannel.createMessage(content, file); } /**