From c064d36128b411e3822cd8d6112c272674db5655 Mon Sep 17 00:00:00 2001 From: Nikolassparrow Date: Tue, 15 Oct 2024 16:32:02 -0500 Subject: [PATCH 1/2] add checkForBroadcast --- src/structures/Time.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/structures/Time.js b/src/structures/Time.js index 92dc4c6e7..abef29a37 100644 --- a/src/structures/Time.js +++ b/src/structures/Time.js @@ -97,6 +97,24 @@ class Time { this.sunrise = time.sunrise; this.sunset = time.sunset; this.time = time.time; + this.checkForBroadcast(); + } + + checkForBroadcast() { + if (!this.timeTillActive) { + return null; + } + + const timeRemainingString = this.getTimeTillDayOrNight(); + const timeRemainingSeconds = TimeLib.getSecondsFromStringTime(timeRemainingString); + + if (timeRemainingSeconds === 300) { // 5 minutes + const locString = this.isDay() ? 'timeTillNightfall' : 'timeTillDaylight'; + const timeTilltransition = this._client.intlGet(this.guildId, locString, { time: timeRemainingString }); + + this._rustplus.sendInGameMessage(`${timeTilltransition}`) + } + } getTimeTillDayOrNight(ignore = '') { From f1a823af222fe675725f6b3734ec9589ecef1279 Mon Sep 17 00:00:00 2001 From: Nikolassparrow Date: Wed, 16 Oct 2024 13:07:38 -0500 Subject: [PATCH 2/2] small fix --- src/structures/Time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Time.js b/src/structures/Time.js index abef29a37..1dc8f6598 100644 --- a/src/structures/Time.js +++ b/src/structures/Time.js @@ -112,7 +112,7 @@ class Time { const locString = this.isDay() ? 'timeTillNightfall' : 'timeTillDaylight'; const timeTilltransition = this._client.intlGet(this.guildId, locString, { time: timeRemainingString }); - this._rustplus.sendInGameMessage(`${timeTilltransition}`) + this.rustplus.sendInGameMessage(`${timeTilltransition}`) } }