Updatecommand

Discussion in 'Server and Client Scripting' started by Kase, Oct 19, 2014.

  1. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    So I'm trying to make a command that will update all files in "scripts/". /updateplugin doesn't work for all files in "scripts/", pretty sure its because not all the files in "/scripts/ are plugins, they are command files as well. And /updatecommands doesn't update them from the web, so I can't use that.
    So the code I have so far is:
    Code (text):
    1.    if (command == "updatescriptfiles") {
    2.         var scriptFiles = ["admincommands.js", "auto_smute.js", "battlefactory.js", "blackjack.js", "bot.js", "casino.js", "channelcommands.js", "channelfunctions.js", "channelmanager.js", "commands.js", "crc32.js", "globalfunctions.js", "hangman.js", "kirby.js", "mafia.js", "mafiachecker.js", "mafiastats.js", "memoryhash.js", "modcommands.js", "newtourstats.js", "ownercommands.js", "pokedex.js", "pokerace.js", "suspectvoting.js", "tierchecks.js", "tournaments.js", "tours.js", "tourstats.js", "trivia.js", "usercommands.js", "userfunctions.js", "utilities.js", "wallet.js"];
    3.         scriptFiles.forEach(function(file) {
    4.             var updateURL = Config.base_url+scriptFiles;
    5.             var changescriptFile = function(resp) {
    6.                 if (resp === "") return;
    7.                 try {
    8.                     sys.writeToFile(scriptFiles, resp);
    9.                 } catch (err) {
    10.                     normalbot.sendAll('Updating failed, loaded old scripts!', staffchannel);
    11.                     sys.sendMessage(src, "ERROR: " + err + (err.lineNumber ? " on line: " + err.lineNumber : ""), channel_local);
    12.                     print(err);
    13.                 }
    14.             };
    15.             normalbot.sendMessage(src, "Fetching scripts from " + updateURL, channel);
    16.             sys.webCall(updateURL, changescriptFile);
    17.             return;
    18.         });
    19.     }
    The issue this the command is that instead of update each script one after the other, I try's to do it at the same time. Which means that updateURL is Config.Base_URL+all the scriptFiles. Is there a way I can make it select one of the scriptFiles, than the next one, and so on?