add starboard

This commit is contained in:
fzorb 2024-10-06 14:12:09 +03:00
parent 1d33f6d468
commit 6da8b6bf10
3 changed files with 30 additions and 0 deletions

View File

@ -4,3 +4,6 @@ PREFIX=;
ADMIN= ADMIN=
BOT_ID= BOT_ID=
FORBIDDEN_WORDS=word1,word2 FORBIDDEN_WORDS=word1,word2
STARBOARD=
MINSTARS=3

1
bot.rb
View File

@ -30,4 +30,5 @@ systems.each { |i| require_relative "#{i}" }
bot.include! QuoteSystem bot.include! QuoteSystem
bot.include! NetworkModule bot.include! NetworkModule
bot.include! TriggerSystem bot.include! TriggerSystem
bot.include! StarboardSystem
bot.run bot.run

26
systems/starboard.rb Normal file
View File

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