You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.0 KiB
Ruby

#!/usr/bin/env ruby
require 'discordrb'
require 'tmpdir'
token = File.read("token.txt")
$bot = Discordrb::Bot.new token: "#{token}"
bang = '!'
def emery_loadModules()
$commands = {}
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")
$commands[name] = command
else
puts "Load error!"
end
end
}
end
$queue = {}
$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