aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hypixel.ts14
-rw-r--r--src/index.ts16
2 files changed, 28 insertions, 2 deletions
diff --git a/src/hypixel.ts b/src/hypixel.ts
index ba0b83c..944206d 100644
--- a/src/hypixel.ts
+++ b/src/hypixel.ts
@@ -33,7 +33,7 @@ import * as cached from './hypixelCached.js'
import { debug } from './index.js'
import { WithId } from 'mongodb'
import { cleanEndedAuctions } from './cleaners/skyblock/endedAuctions.js'
-import { cleanAuctions } from './cleaners/skyblock/auctions.js'
+import { Auction, cleanAuctions } from './cleaners/skyblock/auctions.js'
import { string } from 'prismarine-nbt'
import { withCache } from './util.js'
import { Item } from './cleaners/skyblock/inventory.js'
@@ -485,3 +485,15 @@ async function fetchAuctionItemsUncached() {
return idsToData
}
+export async function fetchPlayerAuctions(user: string): Promise<Auction[] | null> {
+ const playerUuid = await cached.uuidFromUser(user)
+ if (!playerUuid) return null
+
+ const playerAuctions = await sendCleanApiRequest(
+ 'skyblock/auction',
+ {
+ player: playerUuid
+ }
+ )
+ return playerAuctions
+}
diff --git a/src/index.ts b/src/index.ts
index 9de531f..4da37d7 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,5 @@
import { createSession, fetchAccountFromDiscord, fetchAllLeaderboardsCategorized, fetchLeaderboard, fetchMemberLeaderboardSpots, fetchSession, finishedCachingRawLeaderboards, leaderboardUpdateMemberQueue, leaderboardUpdateProfileQueue, updateAccount, deleteSession, fetchPaginatedItemsAuctions, fetchItemsAuctions } from './database.js'
-import { fetchAuctionItems, fetchAuctionUncached, fetchElection, fetchItemList, fetchMemberProfile, fetchUser } from './hypixel.js'
+import { fetchAuctionItems, fetchAuctionUncached, fetchElection, fetchItemList, fetchMemberProfile, fetchPlayerAuctions, fetchUser } from './hypixel.js'
import rateLimit from 'express-rate-limit'
import * as constants from './constants.js'
import * as discord from './discord.js'
@@ -206,6 +206,20 @@ app.get('/auction/:uuid', async (req, res) => {
}
})
+
+
+app.get('/playerauctions/:user', async (req, res) => {
+ try {
+ res.json(
+ await fetchPlayerAuctions(req.params.user)
+ )
+ } catch (err) {
+ console.error(err)
+ res.json({ ok: false })
+ }
+})
+
+
app.post('/accounts/createsession', async (req, res) => {
try {
const { code } = req.body