From 767c17c494b2302ac10f0657ad280832350413db Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 18:12:51 +0000 Subject: add auctionitems endpoint --- src/cleaners/skyblock/auctions.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/cleaners/skyblock/auctions.ts (limited to 'src/cleaners/skyblock') 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 { + 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 -- cgit