2020-10-22 15:50:47 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
|
|
|
import { EmojiPayload } from '../types/emojiTypes.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-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-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-10-25 17:03:53 +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-10-22 15:50:47 +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
|
|
|
|
this.roles = data.roles
|
2020-10-29 14:43:27 +00:00
|
|
|
if (data.user !== undefined) {
|
|
|
|
User.autoInit(this.client, {
|
|
|
|
endpoint: USER,
|
|
|
|
restURLfuncArgs: [data.user.id]
|
|
|
|
}).then(user => (this.user = user))
|
|
|
|
}
|
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
|
|
|
|
|
|
|
readFromData (data: EmojiPayload): void {
|
|
|
|
super.readFromData(data)
|
|
|
|
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
|
|
|
|
if (data.user !== undefined && data.user.id !== this.user?.id) {
|
|
|
|
User.autoInit(this.client, {
|
|
|
|
endpoint: USER,
|
|
|
|
restURLfuncArgs: [data.user.id]
|
|
|
|
}).then(user => (this.user = user))
|
|
|
|
}
|
|
|
|
}
|
2020-10-22 15:50:47 +00:00
|
|
|
}
|