forked from yagich/potomark-bot-rb
use message method instead of REST API
This commit is contained in:
parent
1e6289872d
commit
39443ef5ef
8
bot.rb
8
bot.rb
@ -8,10 +8,6 @@ PIN_EMOJI = '📌'
|
|||||||
|
|
||||||
TRIM_MESSAGE_LENGTH = 500
|
TRIM_MESSAGE_LENGTH = 500
|
||||||
|
|
||||||
def get_bot_token
|
|
||||||
"Bot #{ENV['DISCORD_TOKEN']}"
|
|
||||||
end
|
|
||||||
|
|
||||||
bot.reaction_add do |event|
|
bot.reaction_add do |event|
|
||||||
next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name
|
next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name
|
||||||
|
|
||||||
@ -39,7 +35,7 @@ bot.reaction_add do |event|
|
|||||||
end
|
end
|
||||||
|
|
||||||
if(event.emoji.name == PIN_EMOJI)
|
if(event.emoji.name == PIN_EMOJI)
|
||||||
Discordrb::API::Channel.pin_message(get_bot_token(), event.channel.id, event.message.id)
|
event.message.pin
|
||||||
end
|
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.
|
||||||
@ -47,7 +43,7 @@ end
|
|||||||
|
|
||||||
bot.reaction_remove do |event|
|
bot.reaction_remove do |event|
|
||||||
next unless event.emoji.name == PIN_EMOJI
|
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
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user