From b5362110c43bf73473a17e0b211200b0c2f625ca Mon Sep 17 00:00:00 2001 From: asyncnomi Date: Thu, 15 Dec 2022 16:27:01 +0100 Subject: [PATCH] the end is near (Pergboard Nerd) --- index.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) 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';