diff options
Diffstat (limited to 'src/cleaners')
-rw-r--r-- | src/cleaners/skyblock/auctions.ts | 36 |
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 |