2020-10-29 14:43:27 +00:00
|
|
|
import cache from '../models/cache.ts'
|
2020-10-22 15:50:47 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-10-25 17:03:53 +00:00
|
|
|
import { ChannelPayload, ChannelTypes } from '../types/channelTypes.ts'
|
2020-10-22 15:50:47 +00:00
|
|
|
import { Base } from './base.ts'
|
|
|
|
|
|
|
|
export class Channel extends Base {
|
|
|
|
type: ChannelTypes
|
|
|
|
id: string
|
2020-10-24 15:00:42 +00:00
|
|
|
static cacheName = 'channel'
|
2020-10-25 17:03:53 +00:00
|
|
|
get mention (): string {
|
|
|
|
return `<#${this.id}>`
|
|
|
|
}
|
2020-10-22 15:50:47 +00:00
|
|
|
|
|
|
|
constructor (client: Client, data: ChannelPayload) {
|
2020-10-25 06:50:32 +00:00
|
|
|
super(client, data)
|
2020-10-22 15:50:47 +00:00
|
|
|
this.type = data.type
|
|
|
|
this.id = data.id
|
2020-11-01 06:38:45 +00:00
|
|
|
this.client.channels.set(this.id, data)
|
2020-10-29 14:43:27 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 14:51:40 +00:00
|
|
|
protected readFromData (data: ChannelPayload): void {
|
2020-10-29 14:43:27 +00:00
|
|
|
super.readFromData(data)
|
|
|
|
this.type = data.type ?? this.type
|
|
|
|
this.id = data.id ?? this.id
|
2020-10-22 15:50:47 +00:00
|
|
|
}
|
|
|
|
}
|