1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 08:20:58 -05:00

Add new switch for dailyMsgs operation

This commit is contained in:
AnxietyisReal 2023-08-14 18:33:49 +10:00
parent f59295d15a
commit cf0ae319bb
3 changed files with 3 additions and 1 deletions

View File

@ -16,6 +16,7 @@
"message": "1023699243183112192"
},
"botSwitches": {
"dailyMsgsBackup": true,
"registerCommands": true,
"commands": true,
"logs": true,

View File

@ -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<number>)=>x[0] === formattedDate)){
if (client.config.botSwitches.dailyMsgsBackup && !dailyMsgs.some((x:Array<number>)=>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<number>)=>x[0] === formattedDate - 1);
if (total < yesterday) total = yesterday // messages went down.

View File

@ -141,6 +141,7 @@ export interface Config {
message: string
},
botSwitches: {
dailyMsgsBackup: boolean,
registerCommands: boolean,
commands: boolean,
logs: boolean,