Minor refractoring, allows hot-refreshing.

pull/1/head
Astoria Floyd 3 years ago
parent 28cb7cf447
commit 1a897507c4

@ -3,18 +3,11 @@ local client = discordia.Client()
local tools = require("./tools.lua")
discordia.extensions()
local simpleCommands = require("./simpleCommands.lua")
local complexCommands = require("./complexCommands.lua")
--Initialize commands, CLEAN THIS UP, MAKE IT DO MORE THEN TWO, CURRENTLY WE NEED TO JUST DO THIS OVER AND OVER
local complexCommands = complexCommands.initialize()
local simpleCommands = simpleCommands.initialize()
local commands = tools.tableMerge(simpleCommands, complexCommands)
--Setup bot here, initializes bot
client:once("ready", function()
client:setGame("Astoria's bot, very sad!")
print('Logged in as '.. client.user.username)
commands = tools.initialize()
end)
--Command handler
@ -28,6 +21,13 @@ client:on('messageCreate', function(message)
end
end)
client:on('messageCreate', function(message)
if tools.messageDectection(message, "reinitialize") == true then
commands = tools.initialize()
message:reply("Re-Initialized!")
end
end)
--When a user is banned, post a lenney.
client:on('userBan', function()
local banChannel, err = client:getChannel("872283716486066200")

@ -1,8 +1,8 @@
local tools = require("./tools.lua")
local rng = require("./rng.lua")
local tools = dofile("./tools.lua")
local rng = dofile("./rng.lua")
local complexCommands = {}
local prefix = require("./settings.lua")
local prefix = dofile("./settings.lua")
local commands = { -- Define commands its a table that will contain our commands
[prefix..'helpme'] = { -- Dumps docs/help to chat, took me forever to figure out.

@ -1,5 +1,5 @@
local rng = {}
local tools = require("./tools.lua")
local tools = dofile("./tools.lua")
--Rolls a d20, if output is 1, Critical miss(or Shit), if output is 20, critical hit.
function rng.d20()

@ -1,5 +1,5 @@
local basicCommands = {}
local prefix = require("./settings.lua")
local prefix = dofile("./settings.lua")
local commands = { -- Define commands its a table that will contain our commands
[prefix..'lenny'] = { -- Creates a lenny face
@ -34,17 +34,12 @@ local commands = { -- Define commands its a table that will contain our commands
p(message.attachments)
end
};
[prefix..'welsh'] = { --
[prefix..'welsh'] = { -- Welsh.
exec = function (message)
message.channel:send("https://cdn.discordapp.com/attachments/748713417489252503/770289379586867231/image0.gif")
message:delete()
end
};
[prefix..'testArgs'] = { --
exec = function (message, args)
message.channel:send(args[2])
end
};
}

@ -7,6 +7,16 @@ function tools.seed()
math.randomseed(seed)
end
--Initializes commands.
function tools.initialize()
local simpleCommands = dofile("./simpleCommands.lua")
local complexCommands = dofile("./complexCommands.lua")
local complexCommands = complexCommands.initialize()
local simpleCommands = simpleCommands.initialize()
local commands = tools.tableMerge(simpleCommands, complexCommands)
return commands
end
--Reads an entire file, outputs as string.
function tools.printFile(file)
local rawFile = io.open(file, r)

Loading…
Cancel
Save