aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/skyblock/coopInvitation.ts
blob: 01887721b084827b47db2c4b7679b145247f34e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import typedHypixelApi from 'typed-hypixel-api'
import { CleanPlayer } from '../player'
import * as cached from '../../hypixelCached.js'


export interface CoopInvitation {
	invitedTimestamp: number
	invitedBy: CleanPlayer | null
	accepted: boolean
	acceptedTimestamp: number | null
}

export async function cleanCoopInvitation(data: typedHypixelApi.SkyBlockProfileMember, uuid: string): Promise<CoopInvitation | null> {
	if (!data.coop_invitation)
		return null

	return {
		invitedTimestamp: data.coop_invitation.timestamp,
		invitedBy: await cached.fetchBasicPlayer(data.coop_invitation.invited_by, false),
		accepted: data.coop_invitation.confirmed,
		acceptedTimestamp: data.coop_invitation.confirmed_timestamp ?? null
	}
}