2020-10-31 11:45:33 +00:00
|
|
|
import { Client } from "../models/client.ts";
|
|
|
|
import { User } from "../structures/user.ts";
|
|
|
|
import { USER } from "../types/endpoint.ts";
|
2020-11-01 12:05:22 +00:00
|
|
|
import { UserPayload } from "../types/user.ts";
|
2020-10-31 11:45:33 +00:00
|
|
|
import { BaseManager } from "./BaseManager.ts";
|
|
|
|
|
|
|
|
export class UserManager extends BaseManager<UserPayload, User> {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client, "users", User)
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch(id: string) {
|
|
|
|
return new Promise((res, rej) => {
|
|
|
|
this.client.rest.get(USER(id)).then(data => {
|
|
|
|
this.set(id, data as UserPayload)
|
|
|
|
res(new User(this.client, data as UserPayload))
|
|
|
|
}).catch(e => rej(e))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|