aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-17 18:26:14 +0000
committermat <github@matdoes.dev>2022-05-17 18:26:14 +0000
commit8e0c3cb608041c8f3d28d1bcaf6f0d4e159e688f (patch)
treee131411bbfe8e6b90ab411dd1549cb6ce7f912e1
parent767c17c494b2302ac10f0657ad280832350413db (diff)
downloadskyblock-api-8e0c3cb608041c8f3d28d1bcaf6f0d4e159e688f.tar.gz
skyblock-api-8e0c3cb608041c8f3d28d1bcaf6f0d4e159e688f.tar.bz2
skyblock-api-8e0c3cb608041c8f3d28d1bcaf6f0d4e159e688f.zip
fix auctionitems returning an empty object sometimes
-rw-r--r--src/database.ts3
-rw-r--r--src/hypixel.ts2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/database.ts b/src/database.ts
index a8dd1a4..2b73c77 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -1113,7 +1113,8 @@ export async function updateItemAuction(auction: ItemAuctionsSchema) {
/**
* Fetches the SkyBlock ids of all the items in the auctions database. This method is slow and should be cached!
*/
-export async function fetchItemsAuctionsIds(): Promise<string[]> {
+export async function fetchItemsAuctionsIds(): Promise<string[] | undefined> {
+ if (!itemAuctionsCollection) return undefined
const docs = await itemAuctionsCollection?.aggregate([
// this removes everything except the _id
{ $project: { _id: true } }
diff --git a/src/hypixel.ts b/src/hypixel.ts
index 5865878..ef16810 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -477,6 +477,7 @@ export async function fetchAuctionItems() {
isFetchingAuctionItemList = true
const itemList = await fetchAuctionItemsUncached()
+ if (!itemList) return undefined
isFetchingAuctionItemList = false
cachedAuctionItemListData = itemList
@@ -487,6 +488,7 @@ export async function fetchAuctionItems() {
async function fetchAuctionItemsUncached() {
const auctionItemIds = await fetchItemsAuctionsIds()
+ if (!auctionItemIds) return undefined
const itemList = await fetchItemList()
const idsToNames: Map<string, string> = new Map()
for (const item of itemList.list)