From 6da8b6bf10780913567743ecb36f7828e54e9bf3 Mon Sep 17 00:00:00 2001 From: fzorb Date: Sun, 6 Oct 2024 14:12:09 +0300 Subject: [PATCH] add starboard --- .env.example | 3 +++ bot.rb | 1 + systems/starboard.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 systems/starboard.rb diff --git a/.env.example b/.env.example index b91b7c8..a508eee 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,6 @@ PREFIX=; ADMIN= BOT_ID= FORBIDDEN_WORDS=word1,word2 + +STARBOARD= +MINSTARS=3 \ No newline at end of file diff --git a/bot.rb b/bot.rb index cb6e432..3e728fc 100644 --- a/bot.rb +++ b/bot.rb @@ -30,4 +30,5 @@ systems.each { |i| require_relative "#{i}" } bot.include! QuoteSystem bot.include! NetworkModule bot.include! TriggerSystem +bot.include! StarboardSystem bot.run diff --git a/systems/starboard.rb b/systems/starboard.rb new file mode 100644 index 0000000..673123b --- /dev/null +++ b/systems/starboard.rb @@ -0,0 +1,26 @@ +require 'discordrb' +require 'dotenv' +Dotenv.load("#{__dir__}/../.env") + +module StarboardSystem + extend Discordrb::EventContainer + reaction_add do |event| + reactions = 0 + for reaction in event.message.reactions do + if reaction.name == "⭐" + reactions = reactions + 1 + end + end + attachments = "" + for attachment in event.message.attachments do + attachments += " #{attachment.url}" + end + if reactions == ENV['MINSTARS'].to_i + message = event.message.content.sub!("@", "[at]") + if message == nil + message = event.message.content + end + event.bot.channel(ENV['STARBOARD']).send_message("https://discord.com/channels/#{event.message.channel.server.id}/#{event.message.channel.id}/#{event.message.id} | **#{event.message.author.name} said**: #{message}#{attachments}") + end + end +end \ No newline at end of file