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.

54 lines
1.3 KiB
Ruby

#!/usr/bin/env ruby
3 years ago
# ./Emery.rb
# pkill Emery
require 'discordrb'
require 'tmpdir'
3 years ago
puts "---\nEmery PID is #{Process.pid}\nTo kill Emery simply {kill #{Process.pid}}\n---"
def emery_loadModules()
$commands = {}
3 years ago
puts '---'
# 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|
# 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 in #{mod}!"
end
end
}
3 years ago
puts '---'
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|
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
$bot.run