From bb5ca3fd09001cfad375d052fa9c3eee24b61038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sun, 18 Sep 2022 03:01:54 +0300 Subject: [PATCH] make message trim length a constant --- bot.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot.rb b/bot.rb index 8d48591..41d17f2 100644 --- a/bot.rb +++ b/bot.rb @@ -4,6 +4,7 @@ require 'discordrb' bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN'] EMOJI = '🔖' +TRIM_MESSAGE_LENGTH = 500 bot.reaction_add do |event| return nil unless event.emoji.name == EMOJI @@ -15,7 +16,7 @@ bot.reaction_add do |event| message_author_fname = "#{message_author_nickname} (#{message_author_distinct})" # this is the 'author' field of the embed - trimmed_msg = "#{event.message.content[0..500]}#{'...' if event.message.content.length > 500}" # trim the string to 500 chars max to not make the embed too huge + trimmed_msg = "#{event.message.content[0..TRIM_MESSAGE_LENGTH]}#{'...' if event.message.content.length > TRIM_MESSAGE_LENGTH}" # trim the string to TRIM_MESSAGE_LENGTH chars max to not make the embed too huge original_msg_link = event.message.link pm = event.user.pm