aboutsummaryrefslogtreecommitdiff
path: root/src/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/updatePriceItemCache.ts31
-rw-r--r--src/tasks/updateSuperUsers.ts2
2 files changed, 32 insertions, 1 deletions
diff --git a/src/tasks/updatePriceItemCache.ts b/src/tasks/updatePriceItemCache.ts
new file mode 100644
index 0000000..096354b
--- /dev/null
+++ b/src/tasks/updatePriceItemCache.ts
@@ -0,0 +1,31 @@
+import { BushTask } from '#lib';
+import got from 'got';
+import PriceCommand, { AuctionAverages, Bazaar, LowestBIN } from '../commands/utilities/price.js';
+
+export default class UpdatePriceItemCache extends BushTask {
+ public constructor() {
+ super('updatePriceItemCache', {
+ delay: 600_000, // 10 minutes
+ runOnStart: true
+ });
+ }
+
+ public override async exec() {
+ //prettier-ignore
+ const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = (await Promise.all([
+ got.get('https://api.hypixel.net/skyblock/bazaar').json().catch(() => {}),
+ got.get('https://moulberry.codes/lowestbin.json').json().catch(() => {}),
+ got.get('https://moulberry.codes/auction_averages_lbin/3day.json').json().catch(() => {}),
+ got.get('https://moulberry.codes/auction_averages/3day.json').json().catch(() => {})
+ ])) as [Bazaar, LowestBIN, LowestBIN, AuctionAverages];
+
+ const itemNames = new Set([
+ ...Object.keys(averageLowestBIN ?? {}),
+ ...Object.keys(currentLowestBIN ?? {}),
+ ...Object.keys(auctionAverages ?? {}),
+ ...Object.keys(bazaar?.products ?? {})
+ ]);
+
+ PriceCommand.cachedItemList = [...itemNames];
+ }
+}
diff --git a/src/tasks/updateSuperUsers.ts b/src/tasks/updateSuperUsers.ts
index c0937dd..db8ff0a 100644
--- a/src/tasks/updateSuperUsers.ts
+++ b/src/tasks/updateSuperUsers.ts
@@ -4,7 +4,7 @@ import { Global } from '../lib/models/Global.js';
export default class UpdateSuperUsersTask extends BushTask {
public constructor() {
super('updateSuperUsers', {
- delay: 10_000,
+ delay: 10_000, // 10 seconds
runOnStart: true
});
}