Compare commits

..

No commits in common. "89a36914dbbb615acc9639378087ef1bdd7da91f" and "96a4fe575173d07c5b9ee3ad1c604951504d8338" have entirely different histories.

20
bot.rb
View File

@ -3,15 +3,11 @@ require 'discordrb'
bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN'] bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN']
BOOKMARK_EMOJI = '🔖' EMOJI = '🔖'
PIN_EMOJI = '📌'
TRIM_MESSAGE_LENGTH = 500 TRIM_MESSAGE_LENGTH = 500
bot.reaction_add do |event| bot.reaction_add do |event|
next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name next unless event.emoji.name == EMOJI
if(event.emoji.name == BOOKMARK_EMOJI)
# extract data of the message's author # extract data of the message's author
message_author = event.message.author message_author = event.message.author
message_author_pfp = message_author.avatar_url 'png' message_author_pfp = message_author.avatar_url 'png'
@ -32,19 +28,7 @@ bot.reaction_add do |event|
embed << Discordrb::Webhooks::EmbedField.new(name: 'Message (trimmed)', value: trimmed_msg) embed << Discordrb::Webhooks::EmbedField.new(name: 'Message (trimmed)', value: trimmed_msg)
embed.timestamp = event.message.timestamp embed.timestamp = event.message.timestamp
end end
end
if(event.emoji.name == PIN_EMOJI)
event.message.pin
end
nil # `event` is of type Respondable, so the return line of the block needs to be nil to prevent the bot sending something in the chhannel the reaction occured. nil # `event` is of type Respondable, so the return line of the block needs to be nil to prevent the bot sending something in the chhannel the reaction occured.
end end
bot.reaction_remove do |event|
next unless event.emoji.name == PIN_EMOJI
event.message.unpin
nil
end
bot.run bot.run