aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/skyblock
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-17 18:12:51 +0000
committermat <github@matdoes.dev>2022-05-17 18:12:51 +0000
commit767c17c494b2302ac10f0657ad280832350413db (patch)
treeb6755f353fe5512fd8422d733c83402b2491c4aa /src/cleaners/skyblock
parent5101e436bd2acfb6efdffe5c8c723511ab735153 (diff)
downloadskyblock-api-767c17c494b2302ac10f0657ad280832350413db.tar.gz
skyblock-api-767c17c494b2302ac10f0657ad280832350413db.tar.bz2
skyblock-api-767c17c494b2302ac10f0657ad280832350413db.zip
add auctionitems endpoint
Diffstat (limited to 'src/cleaners/skyblock')
-rw-r--r--src/cleaners/skyblock/auctions.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cleaners/skyblock/auctions.ts b/src/cleaners/skyblock/auctions.ts
new file mode 100644
index 0000000..28e1958
--- /dev/null
+++ b/src/cleaners/skyblock/auctions.ts
@@ -0,0 +1,36 @@
+import typedHypixelApi from 'typed-hypixel-api'
+import { cleanInventory, headIdFromBase64, Item } from './inventory.js'
+
+
+export interface Auction {
+ id: string
+ sellerUuid: string
+ sellerProfileUuid: string
+ buyerUuid: string | null
+ creationTimestamp: number
+ boughtTimestamp: number
+ coins: number
+ bin: boolean
+ item: Item
+}
+
+export async function cleanAuctions(data: typedHypixelApi.SkyBlockRequestAuctionResponse): Promise<Auction[]> {
+ console.log(data)
+ const auctions: Auction[] = []
+ for (const auction of data.auctions) {
+ auctions.push({
+ id: auction.uuid,
+ sellerUuid: auction.auctioneer,
+ sellerProfileUuid: auction.profile_id,
+ creationTimestamp: auction.start,
+ buyerUuid: auction.end ? auction.bids[auction.bids.length - 1].bidder : null,
+ boughtTimestamp: auction.end,
+ coins: auction.highest_bid_amount,
+ bin: auction.bin ?? false,
+ item: (await cleanInventory(typeof auction.item_bytes === 'string' ? auction.item_bytes : auction.item_bytes.data))[0]
+ })
+ }
+
+ return auctions
+
+} \ No newline at end of file