make message trim length a constant

This commit is contained in:
Lera Elvoé 2022-09-18 03:01:54 +03:00
parent a548f460d0
commit bb5ca3fd09
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc

3
bot.rb
View File

@ -4,6 +4,7 @@ require 'discordrb'
bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN'] bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN']
EMOJI = '🔖' EMOJI = '🔖'
TRIM_MESSAGE_LENGTH = 500
bot.reaction_add do |event| bot.reaction_add do |event|
return nil unless event.emoji.name == EMOJI 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 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 original_msg_link = event.message.link
pm = event.user.pm pm = event.user.pm