2020-10-31 11:45:33 +00:00
|
|
|
import { Client } from "../models/client.ts";
|
|
|
|
import { Channel } from "../structures/channel.ts";
|
|
|
|
import { User } from "../structures/user.ts";
|
2020-11-01 12:05:22 +00:00
|
|
|
import { ChannelPayload } from "../types/channel.ts";
|
2020-10-31 11:45:33 +00:00
|
|
|
import { CHANNEL } from "../types/endpoint.ts";
|
|
|
|
import { BaseManager } from "./BaseManager.ts";
|
|
|
|
|
|
|
|
export class ChannelsManager extends BaseManager<ChannelPayload, Channel> {
|
|
|
|
constructor(client: Client) {
|
|
|
|
super(client, "channels", User)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Override get method as Generic
|
2020-11-01 11:22:09 +00:00
|
|
|
async get<T = Channel>(key: string): Promise<T> {
|
2020-10-31 11:45:33 +00:00
|
|
|
return new this.dataType(this.client, this._get(key)) as any
|
|
|
|
}
|
|
|
|
|
2020-11-01 11:22:09 +00:00
|
|
|
fetch(id: string): Promise<Channel> {
|
2020-10-31 11:45:33 +00:00
|
|
|
return new Promise((res, rej) => {
|
|
|
|
this.client.rest.get(CHANNEL(id)).then(data => {
|
|
|
|
this.set(id, data as ChannelPayload)
|
|
|
|
res(new Channel(this.client, data as ChannelPayload))
|
|
|
|
}).catch(e => rej(e))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|