2020-11-02 06:58:23 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
|
|
|
import { Emoji } from '../structures/emoji.ts'
|
2020-11-08 07:58:24 +00:00
|
|
|
import { Guild } from '../structures/guild.ts'
|
2020-11-02 06:58:23 +00:00
|
|
|
import { EmojiPayload } from '../types/emoji.ts'
|
2020-11-08 07:58:24 +00:00
|
|
|
import { GUILD_EMOJI } from '../types/endpoint.ts'
|
2020-11-04 12:38:00 +00:00
|
|
|
import { BaseManager } from './base.ts'
|
2020-10-31 11:45:33 +00:00
|
|
|
|
|
|
|
export class EmojisManager extends BaseManager<EmojiPayload, Emoji> {
|
2020-11-08 07:58:24 +00:00
|
|
|
guild: Guild
|
|
|
|
|
|
|
|
constructor (client: Client, guild: Guild) {
|
|
|
|
super(client, `emojis:${guild.id}`, Emoji)
|
|
|
|
this.guild = guild
|
2020-10-31 11:45:33 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 06:58:23 +00:00
|
|
|
async fetch (id: string): Promise<Emoji> {
|
|
|
|
return await new Promise((resolve, reject) => {
|
|
|
|
this.client.rest
|
2020-11-08 07:58:24 +00:00
|
|
|
.get(GUILD_EMOJI(this.guild.id, id))
|
2020-11-02 06:58:23 +00:00
|
|
|
.then(data => {
|
|
|
|
this.set(id, data as EmojiPayload)
|
|
|
|
resolve(new Emoji(this.client, data as EmojiPayload))
|
|
|
|
})
|
|
|
|
.catch(e => reject(e))
|
2020-10-31 11:45:33 +00:00
|
|
|
})
|
|
|
|
}
|
2020-11-02 06:58:23 +00:00
|
|
|
}
|