diff --git a/bot.rb b/bot.rb index 94965f6..7489637 100644 --- a/bot.rb +++ b/bot.rb @@ -21,6 +21,9 @@ 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..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 + if trimmed_msg.empty? + trimmed_msg = "" + end original_msg_link = event.message.link pm = event.user.pm @@ -30,6 +33,12 @@ bot.reaction_add do |event| embed.url = original_msg_link embed.author = Discordrb::Webhooks::EmbedAuthor.new(icon_url: message_author_pfp, name: message_author_fname) embed << Discordrb::Webhooks::EmbedField.new(name: 'Message (trimmed)', value: trimmed_msg) + if !event.message.attachments.empty? + event.message.attachments.each_index do |idx| + attachment = event.message.attachments[idx] + embed << Discordrb::Webhooks::EmbedField.new(name: "Attachment \##{idx + 1}", value: attachment.url) + end + end embed.timestamp = event.message.timestamp end end