diff --git a/index.js b/index.js index d7883c3..85ee9d9 100644 --- a/index.js +++ b/index.js @@ -4,24 +4,11 @@ const path = require('path') var LdapAuth = require('ldapauth-fork'); var prankPath = "prankdata.txt"; -if (!fs.existsSync(prankPath)) { - fs.writeFileSync(prankPath, "{}"); -} - var activityPath = "activitydata.txt"; -if (!fs.existsSync(activityPath)) { - fs.writeFileSync(activityPath, "{}"); -} - var treasurePath = "treasuredata.txt"; -if (!fs.existsSync(treasurePath)) { - fs.writeFileSync(treasurePath, "{}"); -} - var goldenUsersPath = "goldenusers.txt"; -if (!fs.existsSync(goldenUsersPath)) { - fs.writeFileSync(goldenUsersPath, "{}"); -} + +initFs(); let PrankData = JSON.parse(fs.readFileSync(prankPath)); let ActivityData = JSON.parse(fs.readFileSync(activityPath)); @@ -671,6 +658,21 @@ function checkManage(content, input, data) { } } +function initFs() { + if (!fs.existsSync(prankPath)) { + fs.writeFileSync(prankPath, "{}"); + } + if (!fs.existsSync(activityPath)) { + fs.writeFileSync(activityPath, "{}"); + } + if (!fs.existsSync(treasurePath)) { + fs.writeFileSync(treasurePath, "{}"); + } + if (!fs.existsSync(goldenUsersPath)) { + fs.writeFileSync(goldenUsersPath, "{}"); + } +} + function makeid(length) { var result = ''; var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';