From 37ce41a3841d0b484594b0a1f7aa9a17967dbffb Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 23 May 2024 17:23:20 +0100 Subject: [PATCH 1/2] Fix crontab running every 30 seconds instead of every 30 minutes --- src/client/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/client.ts b/src/client/client.ts index 2dd9a29..5a46a5d 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -79,7 +79,7 @@ export class CoreClient extends Client { .then(() => { AppLogger.LogInfo("Client", "App Data Source Initialised"); - const timerId = this._timerHelper.AddTimer("*/30 * * * * *", "Europe/London", GiveCurrency, false); + const timerId = this._timerHelper.AddTimer("*/30 * * * *", "Europe/London", GiveCurrency, false); this._timerHelper.StartTimer(timerId); }) .catch(err => { -- 2.43.4 From 981acefcf638e6ce797aaac68f13621030577eaf Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 23 May 2024 17:28:43 +0100 Subject: [PATCH 2/2] Update currency timer to give 10 coins every 20 minutes --- src/client/client.ts | 2 +- src/constants/CardConstants.ts | 3 +++ src/timers/GiveCurrency.ts | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 src/constants/CardConstants.ts diff --git a/src/client/client.ts b/src/client/client.ts index 5a46a5d..384843d 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -79,7 +79,7 @@ export class CoreClient extends Client { .then(() => { AppLogger.LogInfo("Client", "App Data Source Initialised"); - const timerId = this._timerHelper.AddTimer("*/30 * * * *", "Europe/London", GiveCurrency, false); + const timerId = this._timerHelper.AddTimer("*/20 * * * *", "Europe/London", GiveCurrency, false); this._timerHelper.StartTimer(timerId); }) .catch(err => { diff --git a/src/constants/CardConstants.ts b/src/constants/CardConstants.ts new file mode 100644 index 0000000..f23fd8c --- /dev/null +++ b/src/constants/CardConstants.ts @@ -0,0 +1,3 @@ +export default class CardConstants { + public static readonly TimerGiveAmount = 10; +} \ No newline at end of file diff --git a/src/timers/GiveCurrency.ts b/src/timers/GiveCurrency.ts index ad1a21a..c292025 100644 --- a/src/timers/GiveCurrency.ts +++ b/src/timers/GiveCurrency.ts @@ -1,4 +1,5 @@ import AppLogger from "../client/appLogger"; +import CardConstants from "../constants/CardConstants"; import User from "../database/entities/app/User"; export default async function GiveCurrency() { @@ -7,10 +8,10 @@ export default async function GiveCurrency() { const users = await User.FetchAll(User); for (const user of users) { - user.AddCurrency(5); + user.AddCurrency(CardConstants.TimerGiveAmount); } User.SaveAll(User, users); - AppLogger.LogInfo("Timers/GiveCurrency", `Successfully gave +5 currency to ${users.length} users`); + AppLogger.LogInfo("Timers/GiveCurrency", `Successfully gave +${CardConstants.TimerGiveAmount} currency to ${users.length} users`); } \ No newline at end of file -- 2.43.4