From 066f769b55cd22d90731c7438be97f375aa5547e Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:33:49 +1000 Subject: [PATCH] Add new switch for dailyMsgs operation --- src/config.json | 1 + src/index.ts | 2 +- src/typings/interfaces.d.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config.json b/src/config.json index e5b9af1..f5e970c 100644 --- a/src/config.json +++ b/src/config.json @@ -16,6 +16,7 @@ "message": "1023699243183112192" }, "botSwitches": { + "dailyMsgsBackup": true, "registerCommands": true, "commands": true, "logs": true, diff --git a/src/index.ts b/src/index.ts index da1c307..db3eb15 100644 --- a/src/index.ts +++ b/src/index.ts @@ -84,7 +84,7 @@ setInterval(async()=>{ const formattedDate = Math.floor((now - client.config.LRSstart)/1000/60/60/24); const dailyMsgs = JSON.parse(readFileSync('./src/database/dailyMsgs.json', {encoding: 'utf8'})) - if (!dailyMsgs.some((x:Array)=>x[0] === formattedDate)){ + if (client.config.botSwitches.dailyMsgsBackup && !dailyMsgs.some((x:Array)=>x[0] === formattedDate)){ let total = (await client.userLevels._content.find({})).reduce((a,b)=>a + b.messages, 0); // sum of all users const yesterday = dailyMsgs.find((x:Array)=>x[0] === formattedDate - 1); if (total < yesterday) total = yesterday // messages went down. diff --git a/src/typings/interfaces.d.ts b/src/typings/interfaces.d.ts index 2979dbc..c59d698 100644 --- a/src/typings/interfaces.d.ts +++ b/src/typings/interfaces.d.ts @@ -141,6 +141,7 @@ export interface Config { message: string }, botSwitches: { + dailyMsgsBackup: boolean, registerCommands: boolean, commands: boolean, logs: boolean,