@ -8,21 +8,50 @@ client:once("ready", function()
client : setGame ( " Astoria's bot, very sad! " )
print ( ' Logged in as ' .. client.user . username )
Commands = Tools.initialize ( )
if Tools.testModeDetection ( ) == true then
mode = " testMode "
else
mode = " normal "
end
end )
--Command handler
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 "
shouldReinit = true
elseif Tools.testModeDetection ( ) == false and mode == " testMode " then
mode = " normal "
shouldReinit = false
end
if mode == " testMode " then
shouldReinit = true
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! " )
p ( " Not reinitd at " .. os.time ( ) )
end
local args = message.content : split ( " " )
local lowerArgs = args [ 1 ] : lower ( )
local command = Commands [ lowerArgs ]
if command then
if shouldReinit == true then
Commands = Tools.initialize ( )
Tools = dofile ( " ./API/tools.lua " )
command = Commands [ lowerArgs ]
p ( " reinitd at " .. os.time ( ) )
shouldReinit = false
end
command.exec ( message , args )
end
end )
--Re-Init detector. Only command that itself cannot be fully re-initialized
client : on ( ' messageCreate ' , function ( message )
function reinitialize ( message )
local user = message.guild : getMember ( message.author . id )
if Tools.messageDectection ( message , " reinitialize " ) == true then
if not user : hasPermission ( " administrator " ) then
@ -33,7 +62,12 @@ client:on('messageCreate', function(message)
message : reply ( " Re-Initialized! " )
end
end
end )
end
function selfReinitialize ( )
Commands = Tools.initialize ( )
Tools = dofile ( " ./API/tools.lua " )
end
--When a user is banned, post a lenney.
client : on ( ' userBan ' , function ( )