New command handler format. Less janky.

master
Astoria Floyd 2 years ago
parent f8a725b771
commit bea9003ea8

@ -3,33 +3,34 @@
require 'discordrb'
require 'tmpdir'
token = File.read("token.txt")
$bot = Discordrb::Bot.new token: "#{token}"
bang = '!'
def emery_loadModules()
$commands = {}
# Yes this gets redefined. Why? Because I like having all my variables in one place but it also needs to be cleared again
File.foreach("modules/modules.txt", chop: true) { |line|
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")
# For every line in the file, do below
modPath = "./modules/" + line.delete("\n") + "/main.rb"
mod = line.delete("\n")
if(File.exist?(modPath))
puts "Load success in #{mod}!"
load modPath
if eval("defined? " + "#{mod}_getCommand") == "method"
name, command = send("#{mod}_getCommand")
$commands[name] = command
else
puts "Load error!"
puts "Load error in #{mod}!"
end
end
}
end
token = File.read("token.txt")
$bot = Discordrb::Bot.new token: "#{token}"
$queue = {}
$voicebots = {}
$commands = {}
$bang = '!'
#find a way for this to be server-specific with a fallback option
emery_loadModules()
$bot.message() do |event|
@ -44,8 +45,4 @@ $bot.message() do |event|
end
end
#require './pingcommand.rb'
#main(bot)
#tomlTest()
$bot.run
Loading…
Cancel
Save