diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f89a20d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.json +node_modules/ diff --git a/auth.json b/auth.json deleted file mode 100755 index 5ed62ad..0000000 --- a/auth.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "token" : "NTcyNDkyODE5MDYzNjM1OTY5.XMdFhw.HgXSf-o65lxRYFAZbkoM3l_cxTM" -} diff --git a/main.js b/main.js index ca91f20..4a9d1db 100755 --- a/main.js +++ b/main.js @@ -2,6 +2,9 @@ var Discord = require("discord.js"); var logger = require("winston"); var auth = require("./auth.json"); +var counting = require("./counting.json") +var fs = require("fs") + //Logger settings logger.remove(logger.transports.Console); logger.add(new logger.transports.Console, { @@ -11,7 +14,8 @@ logger.level = "debug"; //Robot time var bot = new Discord.Client(); -prevInt = 76 + +prevInt = counting.prevInt function checkCounting(text) { var n = parseInt(text); @@ -19,7 +23,11 @@ function checkCounting(text) { return false; } if(n == prevInt+1) { - prevInt = n; + var newjson = { + "prevInt" : n+1 + } + fs.writeFile("counting.json",JSON.stringify(newjson),'utf-8',() => console.log("New count: " + (n+1))) + prevInt = n return true; } return false; @@ -43,3 +51,4 @@ bot.on("message",msg => { }); bot.login(auth.token) +