From 486aaf2fb1e40a5d3f7ca6b3ad2ef88b91fcaf98 Mon Sep 17 00:00:00 2001 From: Abheek Dhawan Date: Mon, 5 Apr 2021 23:55:38 -0500 Subject: [PATCH] =?UTF-8?q?Shorten=20k=C3=BClboard=20and=20message=20react?= =?UTF-8?q?ion=20log=20embed=20message=20if=20it's=20too=20long?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.js | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/bot.js b/bot.js index 7dbdd6b..de7e62a 100644 --- a/bot.js +++ b/bot.js @@ -865,10 +865,18 @@ client.on('messageReactionAdd', (messageReaction, user) => { .setTimestamp() .setColor('00aaff'); - if (message.content) { - messageReactionAddEmbed.addField("Message", message.content); + if (message.content) { + if (message.content.length > 25) { + messageReactionAddEmbed.addField("Message", message.content.substring(0, 25) + "...") + } else { + messageReactionAddEmbed.addField("Message", message.content); + } } + //if (message.content) { + // messageReactionAddEmbed.addField("Message", message.content); + //} + const kulboardEmbed = new Discord.MessageEmbed() .setTitle(`${coolness}`) .addField("Link", `[Click here!](${message.url})`, true) @@ -881,7 +889,11 @@ client.on('messageReactionAdd', (messageReaction, user) => { .setTimestamp(); if (message.content) { - kulboardEmbed.addField("Message", message.content); + if (message.content.length > 1024) { + kulboardEmbed.addField("Message", message.content.substring(0, 1020) + "...") + } else { + kulboardEmbed.addField("Message", message.content); + } } collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => { let kulboardChannel; @@ -952,10 +964,18 @@ client.on('messageReactionRemove', (messageReaction, user) => { .setTimestamp() .setColor('e7778b'); - if (message.content) { - messageReactionRemoveEmbed.addField("Message", message.content); + if (message.content) { + if (message.content.length > 25) { + messageReactionRemoveEmbed.addField("Message", message.content.substring(0, 25) + "...") + } else { + messageReactionRemoveEmbed.addField("Message", message.content); + } } + //if (message.content) { + // messageReactionRemoveEmbed.addField("Message", message.content); + //} + const kulboardEmbed = new Discord.MessageEmbed() .setTitle(`${coolness}`) .addField("Link", `[Click here!](${message.url})`, true) @@ -967,9 +987,17 @@ client.on('messageReactionRemove', (messageReaction, user) => { .setColor("00c5ff") .setTimestamp(); - if (message.content) { - kulboardEmbed.addField("Message", message.content) - } + if (message.content) { + if (message.content.length > 1024) { + kulboardEmbed.addField("Message", message.content.substring(0, 1020) + "...") + } else { + kulboardEmbed.addField("Message", message.content); + } + } + + // if (message.content) { + // kulboardEmbed.addField("Message", message.content) + // } collection.findOne({ guild_id: messageReaction.message.guild.id }, (error, result) => { let kulboardChannel;