fix attachment bookmarks

This commit is contained in:
Lera Elvoé 2022-12-14 07:21:20 +03:00
parent 6a10c6beb7
commit 8829c57dd7
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc

9
bot.rb
View File

@ -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 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 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 = "<empty>"
end
original_msg_link = event.message.link original_msg_link = event.message.link
pm = event.user.pm pm = event.user.pm
@ -30,6 +33,12 @@ bot.reaction_add do |event|
embed.url = original_msg_link embed.url = original_msg_link
embed.author = Discordrb::Webhooks::EmbedAuthor.new(icon_url: message_author_pfp, name: message_author_fname) 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) 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 embed.timestamp = event.message.timestamp
end end
end end