From f6c744cdcfaf63c2a0a180750d5a0c898fcf17cd Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 7 Jun 2024 18:11:27 +0100 Subject: [PATCH] Update the give currency timer to only give currency to those with less than 1000 currency --- src/timers/GiveCurrency.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/timers/GiveCurrency.ts b/src/timers/GiveCurrency.ts index c292025..93e48d1 100644 --- a/src/timers/GiveCurrency.ts +++ b/src/timers/GiveCurrency.ts @@ -3,15 +3,17 @@ import CardConstants from "../constants/CardConstants"; import User from "../database/entities/app/User"; export default async function GiveCurrency() { - AppLogger.LogInfo("Timers/GiveCurrency", "Giving currency to every known user"); + AppLogger.LogDebug("Timers/GiveCurrency", "Giving currency to every known user"); const users = await User.FetchAll(User); - for (const user of users) { + const usersFiltered = users.filter(x => x.Currency < 1000); + + for (const user of usersFiltered) { user.AddCurrency(CardConstants.TimerGiveAmount); } User.SaveAll(User, users); - AppLogger.LogInfo("Timers/GiveCurrency", `Successfully gave +${CardConstants.TimerGiveAmount} currency to ${users.length} users`); + AppLogger.LogDebug("Timers/GiveCurrency", `Successfully gave +${CardConstants.TimerGiveAmount} currency to ${usersFiltered.length} users`); } \ No newline at end of file