Merge pull request #2 from AstoriaFloyd/experimental

Experimental
pull/5/head
Astoria Floyd 3 years ago committed by GitHub
commit e4eef194ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

@ -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(" ")

@ -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()

@ -0,0 +1,2 @@
return 'normal'
--normal or test

@ -0,0 +1 @@
return true

@ -1 +0,0 @@
return false
Loading…
Cancel
Save