add support for pinning and unpinning #1
8
bot.rb
8
bot.rb
@ -8,10 +8,6 @@ PIN_EMOJI = '📌'
|
||||
|
||||
TRIM_MESSAGE_LENGTH = 500
|
||||
|
||||
def get_bot_token
|
||||
"Bot #{ENV['DISCORD_TOKEN']}"
|
||||
end
|
||||
|
||||
bot.reaction_add do |event|
|
||||
next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name
|
||||
|
||||
@ -39,7 +35,7 @@ bot.reaction_add do |event|
|
||||
end
|
||||
|
||||
if(event.emoji.name == PIN_EMOJI)
|
||||
Discordrb::API::Channel.pin_message(get_bot_token(), event.channel.id, event.message.id)
|
||||
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.
|
||||
@ -47,7 +43,7 @@ end
|
||||
|
||||
bot.reaction_remove do |event|
|
||||
next unless event.emoji.name == PIN_EMOJI
|
||||
Discordrb::API::Channel.unpin_message(get_bot_token(), event.channel.id, event.message.id)
|
||||
event.message.unpin
|
||||
nil
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user