New command handler format. Less janky.

master
Astoria Floyd 3 years ago
parent f8a725b771
commit bea9003ea8

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