1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { BotTask, Time } from '#lib';
import PriceCommand, { AuctionAverages, Bazaar, LowestBIN } from '../../commands/utilities/price.js';
export default class UpdatePriceItemCache extends BotTask {
public constructor() {
super('updatePriceItemCache', {
delay: 10 * Time.Minute,
runOnStart: true
});
}
public async exec() {
const [bazaar, currentLowestBIN, averageLowestBIN, auctionAverages] = (await Promise.all(
PriceCommand.urls.map(({ url }) =>
fetch(url)
.then((p) => (p.ok ? p.json() : undefined))
.catch(() => undefined)
)
)) 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];
}
}
|