diff --git a/API/tools.lua b/API/tools.lua index 528de00..5e15c77 100644 --- a/API/tools.lua +++ b/API/tools.lua @@ -32,10 +32,11 @@ end --Reads testmode.lua function tools.testModeDetection() - return dofile("./docs/testmode.lua") + local mode = dofile("./docs/mode.lua") + if mode == "normal" then return false end + if mode == "test" then return true end end --- --Reads an entire file, outputs as string. function tools.printFile(file) diff --git a/bot.lua b/bot.lua index 5e5d328..b91dfca 100644 --- a/bot.lua +++ b/bot.lua @@ -9,7 +9,7 @@ client:once("ready", function() print('Logged in as '.. client.user.username) Commands = Tools.initialize() if Tools.testModeDetection() == true then - mode = "testMode" + mode = "test" else mode = "normal" end @@ -20,20 +20,24 @@ client:on('messageCreate', function(message) if message.author.bot then return end local shouldReinit = false if Tools.testModeDetection() == true and mode == "normal" then - mode = "testMode" + mode = "test" shouldReinit = true - elseif Tools.testModeDetection() == false and mode == "testMode" then + elseif Tools.testModeDetection() == false and mode == "test" then mode = "normal" shouldReinit = false end - if mode == "testMode" then + if mode == "test" then shouldReinit = true end + if dofile("./docs/reinitialize.lua") == true then + Commands = Tools.initialize() + Tools = dofile("./API/tools.lua") + end if mode == "normal" and Tools.messageDectection(message, "reinitialize") == true then p("reinitd at "..os.time()) reinitialize(message) - elseif mode == "testMode" and Tools.messageDectection(message, "reinitialize") == true then - message:reply("You cannot preform this command because testMode is on!") + elseif mode == "test" and Tools.messageDectection(message, "reinitialize") == true then + message:reply("You cannot preform this command because test is on!") p("Not reinitd at "..os.time()) end local args = message.content:split(" ") diff --git a/commands/complexCommands.lua b/commands/complexCommands.lua index 24fb405..7789114 100644 --- a/commands/complexCommands.lua +++ b/commands/complexCommands.lua @@ -72,6 +72,49 @@ end end }; +[prefix..'mode'] = { -- Echo's what you said back out, in a fix codeblock. Could be against TOS. + exec = function (message, arg) + local user = message.guild:getMember(message.author.id) + if not user:hasPermission("administrator") then + message:reply("You cannot change the mode of this bot!") + else + file = io.open("./docs/mode.lua", "r+") + io.input(file) + io.output(file) + if tools.testModeDetection() == true then + mode = "test" + else + mode = "normal" + end + if not arg[2] then message.channel:send("```fix\nNo argument. Get or Set?```") return end + if arg[2] ~= "get" and arg[2] ~= "set" then message.channel:send("```fix\nMalformed input, you put in '"..arg[2].."' not get or set.```") return end + if arg[2] == "get" then message.channel:send("```fix\nCurrent mode is '"..mode.."'```") return end + if arg[2] == "set" then + if arg[3] == "normal" then + message.channel:send("```fix\nSet mode 'normal'```") + file:seek("set", 0) + file:write("return 'normal'") + elseif arg[3] == "test" then + message.channel:send("```fix\nset mode 'test'```") + file:seek("set", 0) + file:write("return 'test' \n") + elseif arg[3] ~= "normal" or "test" then + message.channel:send("```fix\nIncorrect mode, please enter 'normal' or 'test'```") + end + io.close() + file = io.open("./docs/reinitialize.lua", "r+") + io.input(file) + io.output(file) + file:seek("set", 0) + file:write("return true ") + end + io.close() + --message.channel:send() + --message:delete() + end +end +}; + } function complexCommands.initialize() diff --git a/docs/mode.lua b/docs/mode.lua new file mode 100644 index 0000000..8550db4 --- /dev/null +++ b/docs/mode.lua @@ -0,0 +1,2 @@ +return 'normal' +--normal or test \ No newline at end of file diff --git a/docs/reinitialize.lua b/docs/reinitialize.lua new file mode 100644 index 0000000..5ecbcf7 --- /dev/null +++ b/docs/reinitialize.lua @@ -0,0 +1 @@ +return true \ No newline at end of file diff --git a/docs/testmode.lua b/docs/testmode.lua deleted file mode 100644 index 1bae4d4..0000000 --- a/docs/testmode.lua +++ /dev/null @@ -1 +0,0 @@ -return false \ No newline at end of file