notify.moe/scripts/User.ts
2019-11-18 11:04:13 +09:00

20 lines
371 B
TypeScript

export default class User {
public id: string
private proExpires: string
public constructor(id: string) {
this.id = id
this.sync()
}
public IsPro(): boolean {
return new Date() > new Date(this.proExpires)
}
private async sync() {
const response = await fetch(`/api/user/${this.id}`)
const json = await response.json()
Object.assign(this, json)
}
}