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

Add new switch for dailyMsgs operation

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

View File

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

View File

@ -84,7 +84,7 @@ setInterval(async()=>{
const formattedDate = Math.floor((now - client.config.LRSstart)/1000/60/60/24); const formattedDate = Math.floor((now - client.config.LRSstart)/1000/60/60/24);
const dailyMsgs = JSON.parse(readFileSync('./src/database/dailyMsgs.json', {encoding: 'utf8'})) 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 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); const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1);
if (total < yesterday) total = yesterday // messages went down. if (total < yesterday) total = yesterday // messages went down.

View File

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