Skip to content

Commit

Permalink
Update fire data update frequency to every 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointerexceptionkek committed Jan 12, 2025
1 parent e6e6685 commit 0634240
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/events/ready/onFire.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// onFireUpdate.ts
import { Client, Message, TextChannel } from "discord.js";
import cron from "node-cron";
import axios from "axios";
Expand Down Expand Up @@ -47,7 +46,7 @@ async function fetchFireData(): Promise<string> {

let message =
"ACSL bot has been set up to report live fire containment. " +
"Updates are queried from https://www.fire.ca.gov/ every 3 hours.\n\n";
"Updates are queried from https://www.fire.ca.gov/ every 5 minutes.\n\n";

for (const incident of results) {
message += `${incident.placeName} ------- ${incident.containment} Containment ------- ${incident.acres} acres\n`;
Expand All @@ -61,10 +60,10 @@ async function fetchFireData(): Promise<string> {
}

/**
* Sets up a cron job to update the channel with latest fire data every 3 hours.
* Sets up a cron job to update the channel with the latest fire data every 5 minutes.
*/
export default function onFireUpdate(client: Client) {
cron.schedule("0 */3 * * *", async () => {
cron.schedule("*/5 * * * *", async () => {
try {
const data = await fetchFireData();
if (!data) return;
Expand Down Expand Up @@ -104,5 +103,5 @@ export default function onFireUpdate(client: Client) {
}
});

console.log("Scheduled job for fire updates is set to run every 3 hours.");
}
console.log("Scheduled job for fire updates is set to run every 5 minutes.");
}

0 comments on commit 0634240

Please sign in to comment.