From 5f67f9b4ee8375b388a20d4cb55f11390b8dcf95 Mon Sep 17 00:00:00 2001 From: csxkdv Date: Mon, 12 Jan 2026 12:06:29 -0300 Subject: [PATCH] Created bot.rb file, which loads commands and starts the bot --- src/bot.rb | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/bot.rb diff --git a/src/bot.rb b/src/bot.rb new file mode 100644 index 0000000..c284735 --- /dev/null +++ b/src/bot.rb @@ -0,0 +1,58 @@ +# cheeseBot +# 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' + +class CheeseBot + def initialize + @bot = Discordrb::Bot.new( + token: ENV['BOT_TOKEN'], + intents: [] + ) + + load_commands + start_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) + puts "Loaded command: #{const}" + sleep(2) + end + end + end + + def start_bot + @bot.ready do + puts "#{@bot.profile.username} is online... GIVE ME THE CHEESE." + @bot.update_status("online", "We're so back.", nil, 0, false, 0) + end + end +end