fix: add Emoji#guild property back

This commit is contained in:
ayntee 2020-12-25 20:36:23 +04:00
parent c59d8f1639
commit 6c6334ee07
1 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import { Client } from '../models/client.ts'
import { EmojiPayload } from '../types/emoji.ts'
import { EMOJI } from '../types/endpoint.ts'
import { Base } from './base.ts'
import { Guild } from "./guild.ts"
import { User } from './user.ts'
export class Emoji extends Base {
@ -9,6 +10,7 @@ export class Emoji extends Base {
name: string
roles?: string[]
user?: User
guild?: Guild;
requireColons?: boolean
managed?: boolean
animated?: boolean
@ -37,14 +39,16 @@ export class Emoji extends Base {
}
/** Modify the given emoji. Requires the MANAGE_EMOJIS permission. Returns the updated emoji object on success. Fires a Guild Emojis Update Gateway event. */
async edit(guildID: string, data: ModifyGuildEmojiParams) {
const res = await this.client.rest.patch(EMOJI(guildID, this.id!))
async edit(data: ModifyGuildEmojiParams) {
if (!this.guild) throw new Error("Guild is undefined");
const res = await this.client.rest.patch(EMOJI(this.guild.id, this.id!), data)
return new Emoji(this.client, res)
}
/** Delete the given emoji. Requires the MANAGE_EMOJIS permission. Returns `true` on success. Fires a Guild Emojis Update Gateway event. */
async delete(guildID: string): Promise<boolean> {
await this.client.rest.patch(EMOJI(guildID, this.id!))
async delete(): Promise<boolean> {
if (!this.guild) throw new Error("Guild is undefined");
await this.client.rest.patch(EMOJI(this.guild.id, this.id!))
return true
}