2020-11-02 06:58:23 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
|
|
|
import { User } from '../structures/user.ts'
|
|
|
|
import { USER } from '../types/endpoint.ts'
|
|
|
|
import { UserPayload } from '../types/user.ts'
|
2020-11-04 12:38:00 +00:00
|
|
|
import { BaseManager } from './base.ts'
|
2020-10-31 11:45:33 +00:00
|
|
|
|
|
|
|
export class UserManager extends BaseManager<UserPayload, User> {
|
2020-11-02 06:58:23 +00:00
|
|
|
constructor (client: Client) {
|
|
|
|
super(client, 'users', User)
|
2020-10-31 11:45:33 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 06:58:23 +00:00
|
|
|
async fetch (id: string): Promise<User> {
|
|
|
|
return await new Promise((resolve, reject) => {
|
|
|
|
this.client.rest
|
|
|
|
.get(USER(id))
|
|
|
|
.then(data => {
|
|
|
|
this.set(id, data as UserPayload)
|
|
|
|
resolve(new User(this.client, data as UserPayload))
|
|
|
|
})
|
|
|
|
.catch(e => reject(e))
|
2020-10-31 11:45:33 +00:00
|
|
|
})
|
|
|
|
}
|
2020-11-02 06:58:23 +00:00
|
|
|
}
|