Refactor scripts
This commit is contained in:
19
scripts/User.ts
Normal file
19
scripts/User.ts
Normal file
@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user