From 81e1b562e8aa9479fad71c0d9b745cfedc51041b Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Tue, 4 Apr 2023 16:28:07 -0500 Subject: [PATCH] Add check to make sure response is under 2000 characters --- main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index b0d9078..af348a9 100644 --- a/main.ts +++ b/main.ts @@ -94,12 +94,17 @@ function matchAbbr(abbrTarget) { function replyMessage(message, correctedMessage, abbrsUsed) { var plural = ""; + var replyString = "Your message contains " + plural + "! Let me fix that for you: \n > " + correctedMessage + "\n \n \|\|btw I was written by Caleb Fontenot\|\|" + var stringLength = replyString.length; if (abbrsUsed == 1) { plural = "an acronym"; } else { plural = abbrsUsed + " acronyms" } - message.reply({content: "Your message contains " + plural + "! Let me fix that for you: \n > " + correctedMessage + "\n \n \|\|btw I was written by Caleb Fontenot\|\|", allowedMentions: { repliedUser: false }}); + if (stringLength > 2000) { + replyString = "Sorry, I detected " + plural + "but the resultant response was " + stringLength + " characters long, and Discord only allows a maximum of 2000." + } + message.reply({content: replyString, allowedMentions: { repliedUser: false }}); }