Major refactor to main bot body, now not asinine, has globals. Still working on bangs :^)

master
Astoria Floyd 2 years ago
parent 9063495d4d
commit 391470c936

@ -4,25 +4,48 @@ require 'discordrb'
require 'tmpdir'
token = File.read("token.txt")
bot = Discordrb::Bot.new token: "#{token}"
$bot = Discordrb::Bot.new token: "#{token}"
bang = '!'
def loadCommands(bot, bang)
def emery_loadModules()
$commands = {}
File.foreach("modules/modules.txt", chop: true) { |line|
mod = "./modules/" + line + "/main.rb"
code = "defined? #{line.delete("\n")}_initialize"
if eval(code) == nil
load mod.delete("\n")
send("#{line.delete("\n")}_initialize", bot, bang)
else
mod = "./modules/" + line.delete("\n") + "/main.rb"
mod2 = line.delete("\n")
if(File.exist?(mod))
load mod.delete("\n")
if eval("defined? " + "#{mod2}_getName") == "method"
puts "Load success!"
name = send("#{mod2}_getName")
command = send("#{line.delete("\n")}_getCommand")
$commands[name] = command
else
puts "Load error!"
end
end
}
end
$queue = {}
loadCommands(bot, bang)
$voicebots = {}
$commands = {}
$bang = '!'
emery_loadModules()
$bot.message() do |event|
message = event.content
server = event.server
author = event.author
if message.start_with?('!')
message = message.sub("!", '')
if $commands.key?(message.split.first.downcase)
send("#{$commands[message.split.first.downcase]}", event)
end
end
end
#require './pingcommand.rb'
#main(bot)
#tomlTest()
bot.run
$bot.run
Loading…
Cancel
Save