From fa29267445f3b3fa6110cb6022570185af5ae347 Mon Sep 17 00:00:00 2001 From: VortrexFTW Date: Wed, 9 Sep 2020 03:52:47 -0500 Subject: [PATCH] Fix dev script from loading db funcs by mistake --- scripts/server/developer.js | 86 ++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/scripts/server/developer.js b/scripts/server/developer.js index ca48899e..874df152 100644 --- a/scripts/server/developer.js +++ b/scripts/server/developer.js @@ -19,7 +19,7 @@ function initDeveloperScript() { function addDeveloperCommandHandlers() { console.log("[Asshat.Developer]: Adding developer command handlers ..."); - let developerCommands = serverCommands.database; + let developerCommands = serverCommands.developer; for(let i in developerCommands) { addCommandHandler(developerCommands[i].command, developerCommands[i].handlerFunction); } @@ -102,12 +102,7 @@ function executeClientCodeCommand(command, params, client) { // --------------------------------------------------------------------------- -function restartGameModeCommand(command, params, client) { - if(client.administrator) { - consoleCommand("/refresh"); - thisResource.restart(); - } - +function saveAllServerDataCommand(command, params, client) { if(getCommand(command).requireLogin) { if(!isClientLoggedIn(client)) { messageClientError(client, "You must be logged in to use this command!"); @@ -115,54 +110,49 @@ function restartGameModeCommand(command, params, client) { } } + if(isClientFromDiscord(client)) { + if(!isCommandAllowedOnDiscord(command)) { + messageClientError(client, "That command isn't available on discord!"); + return false; + } + } + if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) { messageClientError(client, "You do not have permission to use this command!"); return false; } + messageClientInfo(client, `[#FF9900]Saving all server data to database ...`); + saveAllServerDataToDatabase(); + messageClientSuccess(client, `[#FF9900]All server data saved to database!`); + return true; +} + +// --------------------------------------------------------------------------- + +function restartGameModeCommand(command, params, client) { + if(getCommand(command).requireLogin) { + if(!isClientLoggedIn(client)) { + messageClientError(client, "You must be logged in to use this command!"); + return false; + } + } + + if(isClientFromDiscord(client)) { + if(!isCommandAllowedOnDiscord(command)) { + messageClientError(client, "That command isn't available on discord!"); + return false; + } + } + + if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) { + messageClientError(client, "You do not have permission to use this command!"); + return false; + } + + consoleCommand("refresh"); thisResource.restart(); return true; } -// --------------------------------------------------------------------------- - -function developerAnnounceCommand(command, params, client) { - if(getCommand(command).requireLogin) { - if(!isClientLoggedIn(client)) { - messageClientError(client, "You must be logged in to use this command!"); - return false; - } - } - - if(!doesClientHaveStaffPermission(client, getCommandRequiredPermissions(command))) { - messageClientError(client, "You do not have permission to use this command!"); - return false; - } - - developerAnnouncement(client, params); - return true; -} - -// --------------------------------------------------------------------------- - -function queryDatabaseCommand(command, params, client) { - //if(client == consoleClient) { - let databaseConnection = connectToDatabase(); - if(databaseConnection.error) { - console.error("Database error: " + databaseConnection.error); - return false; - } - - let query = databaseConnection.query(params); - if(databaseConnection.error) { - console.error("Query error: " + databaseConnection.error); - return false; - } - console.log("Query executed!"); - console.log(query.fetchRow()[0]); - //} -} -addCommandHandler("query", queryDatabaseCommand); - - // --------------------------------------------------------------------------- \ No newline at end of file