2020-10-22 15:50:47 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-10-31 12:33:34 +00:00
|
|
|
import { EmojiPayload } from '../types/emoji.ts'
|
2020-10-29 14:43:27 +00:00
|
|
|
import { USER } from '../types/endpoint.ts'
|
2020-10-22 15:50:47 +00:00
|
|
|
import { Base } from './base.ts'
|
2020-11-08 11:37:35 +00:00
|
|
|
import { Guild } from './guild.ts'
|
2020-10-25 17:03:53 +00:00
|
|
|
import { User } from './user.ts'
|
2020-10-22 15:50:47 +00:00
|
|
|
|
2020-10-23 16:11:00 +00:00
|
|
|
export class Emoji extends Base {
|
2020-10-22 15:50:47 +00:00
|
|
|
id: string
|
|
|
|
name: string
|
2020-10-29 14:43:27 +00:00
|
|
|
roles?: string[]
|
|
|
|
user?: User
|
2020-11-08 11:10:33 +00:00
|
|
|
guild?: Guild
|
2020-10-23 16:11:00 +00:00
|
|
|
requireColons?: boolean
|
2020-10-22 15:50:47 +00:00
|
|
|
managed?: boolean
|
|
|
|
animated?: boolean
|
|
|
|
available?: boolean
|
2020-10-23 03:19:40 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
get getEmojiString(): string {
|
2020-10-23 03:19:40 +00:00
|
|
|
if (this.animated === false) {
|
2020-10-23 16:11:00 +00:00
|
|
|
return `<:${this.name}:${this.id}>`
|
2020-10-23 03:19:40 +00:00
|
|
|
} else return `<a:${this.name}:${this.id}>`
|
|
|
|
}
|
|
|
|
|
2020-11-08 11:10:33 +00:00
|
|
|
toString(): string {
|
|
|
|
return this.getEmojiString
|
|
|
|
}
|
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
constructor(client: Client, data: EmojiPayload) {
|
2020-10-25 06:50:32 +00:00
|
|
|
super(client, data)
|
2020-10-22 15:50:47 +00:00
|
|
|
this.id = data.id
|
|
|
|
this.name = data.name
|
2020-11-08 11:36:30 +00:00
|
|
|
if (data.user !== undefined) this.user = new User(this.client, data.user)
|
2020-10-22 15:50:47 +00:00
|
|
|
this.roles = data.roles
|
2020-10-23 16:11:00 +00:00
|
|
|
this.requireColons = data.require_colons
|
2020-10-22 15:50:47 +00:00
|
|
|
this.managed = data.managed
|
|
|
|
this.animated = data.animated
|
|
|
|
this.available = data.available
|
|
|
|
}
|
2020-10-29 14:43:27 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
protected readFromData(data: EmojiPayload): void {
|
2020-10-29 14:43:27 +00:00
|
|
|
this.id = data.id ?? this.id
|
|
|
|
this.name = data.name ?? this.name
|
|
|
|
this.roles = data.roles ?? this.roles
|
|
|
|
this.requireColons = data.require_colons ?? this.requireColons
|
|
|
|
this.managed = data.managed ?? this.managed
|
|
|
|
this.animated = data.animated ?? this.animated
|
|
|
|
this.available = data.available ?? this.available
|
2020-12-03 04:06:41 +00:00
|
|
|
if (data.user !== undefined) this.user = new User(this.client, data.user)
|
2020-10-29 14:43:27 +00:00
|
|
|
}
|
2020-10-22 15:50:47 +00:00
|
|
|
}
|