use message method instead of REST API

This commit is contained in:
mud mud 2022-10-26 12:27:34 +02:00
parent 1e6289872d
commit 39443ef5ef
Signed by untrusted user: mud
GPG Key ID: D29C9385CC54F61C

8
bot.rb
View File

@ -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