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

It's like trying to repair a hole in a car tire.

This commit is contained in:
toast-ts 2024-03-18 12:15:16 +11:00
parent 389c66c26b
commit aabef982e5

View File

@ -66,7 +66,10 @@ setInterval(async()=>{
if (!dailyMsgs.find(x=>x.dataValues.day === formattedDate)) {
let total = (await client.userLevels.fetchEveryone()).reduce((a,b)=>a + b.messages, 0); // Sum of all users
const yesterday = dailyMsgs.find(x=>x.day === formattedDate - 1)
if (total < yesterday?.total) total = yesterday.total; // Messages went down.
if (yesterday && total < yesterday.total) Logger.console('log', 'DailyMsgs', `Total messages for day ${formattedDate} is less than total messages for day ${formattedDate - 1}.`);
// Update total if it's the same as yesterday's total
if (yesterday && total === yesterday.total) total = (await client.userLevels.fetchEveryone()).reduce((a,b)=>a + b.messages, 0); // Recalculate total
await client.dailyMsgs.newDay(formattedDate, total);
Logger.console('log', 'DailyMsgs', `Pushed [${formattedDate}, ${total}]`)