# FrugalityBot # Copyright (C) 2026 Eri (csxkdv/nxkdv) nxkdv@thenight.club # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . require 'discordrb' require 'i18n' require_relative 'database' require_relative 'utils/locales_helper' class FrugalityBot def initialize I18n.config.enforce_available_locales = false locales_path = File.join(File.dirname(__dir__), 'locales') I18n.load_path += Dir["#{locales_path}/*.yml"] I18n.backend.load_translations I18n.default_locale = :en @bot = Discordrb::Bot.new( token: ENV['BOT_TOKEN'], intents: [:servers, :server_messages] ) @db = Database.new load_commands startup_bot end def run @bot.run end private def load_commands Dir["#{File.dirname(__FILE__)}/commands/**/*.rb"].each do |file| require file end Commands.constants.each do |const| cmd = Commands.const_get(const) if cmd.is_a?(Module) && cmd.respond_to?(:register) cmd.register(@bot, @db) puts "Loaded command: #{const}" sleep(1.5) end end end def startup_bot @bot.ready do puts "#{@bot.profile.username} is online" @bot.update_status("online", "Checking the economy...", nil, 0, false, 0) end end end