From 39443ef5ef1384d1786461050d5e8a1ff4589cd8 Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 26 Oct 2022 12:27:34 +0200 Subject: [PATCH] use message method instead of REST API --- bot.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bot.rb b/bot.rb index 21970ba..4cab6da 100644 --- a/bot.rb +++ b/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