2020-10-23 16:11:00 +00:00
|
|
|
import { Client } from '../models/client.ts'
|
2020-10-31 12:33:34 +00:00
|
|
|
import { GuildTextChannelPayload, Overwrite } from '../types/channel.ts'
|
2020-10-30 14:51:40 +00:00
|
|
|
import { TextChannel } from './textChannel.ts'
|
2020-11-08 07:57:24 +00:00
|
|
|
import { Guild } from './guild.ts'
|
2020-10-23 16:11:00 +00:00
|
|
|
|
2020-10-30 14:51:40 +00:00
|
|
|
export class GuildTextChannel extends TextChannel {
|
|
|
|
guildID: string
|
|
|
|
name: string
|
|
|
|
position: number
|
|
|
|
permissionOverwrites: Overwrite[]
|
|
|
|
nsfw: boolean
|
|
|
|
parentID?: string
|
2020-10-23 16:11:00 +00:00
|
|
|
rateLimit: number
|
|
|
|
topic?: string
|
2020-11-01 13:42:00 +00:00
|
|
|
guild: Guild
|
2020-10-23 16:11:00 +00:00
|
|
|
|
2020-10-25 17:03:53 +00:00
|
|
|
get mention (): string {
|
2020-10-23 16:11:00 +00:00
|
|
|
return `<#${this.id}>`
|
|
|
|
}
|
|
|
|
|
2020-11-01 13:42:00 +00:00
|
|
|
constructor (client: Client, data: GuildTextChannelPayload, guild: Guild) {
|
2020-10-23 16:11:00 +00:00
|
|
|
super(client, data)
|
2020-10-30 14:51:40 +00:00
|
|
|
this.guildID = data.guild_id
|
|
|
|
this.name = data.name
|
2020-11-01 13:42:00 +00:00
|
|
|
this.guild = guild
|
2020-10-30 14:51:40 +00:00
|
|
|
this.position = data.position
|
|
|
|
this.permissionOverwrites = data.permission_overwrites
|
|
|
|
this.nsfw = data.nsfw
|
|
|
|
this.parentID = data.parent_id
|
2020-10-23 16:11:00 +00:00
|
|
|
this.topic = data.topic
|
|
|
|
this.rateLimit = data.rate_limit_per_user
|
2020-11-01 11:22:09 +00:00
|
|
|
// TODO: Cache in Gateway Event Code
|
|
|
|
// cache.set('guildtextchannel', this.id, this)
|
2020-10-29 14:43:27 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 14:51:40 +00:00
|
|
|
protected readFromData (data: GuildTextChannelPayload): void {
|
2020-10-29 14:43:27 +00:00
|
|
|
super.readFromData(data)
|
2020-10-30 14:51:40 +00:00
|
|
|
this.guildID = data.guild_id ?? this.guildID
|
|
|
|
this.name = data.name ?? this.name
|
|
|
|
this.position = data.position ?? this.position
|
|
|
|
this.permissionOverwrites =
|
|
|
|
data.permission_overwrites ?? this.permissionOverwrites
|
|
|
|
this.nsfw = data.nsfw ?? this.nsfw
|
|
|
|
this.parentID = data.parent_id ?? this.parentID
|
2020-10-29 14:43:27 +00:00
|
|
|
this.topic = data.topic ?? this.topic
|
|
|
|
this.rateLimit = data.rate_limit_per_user ?? this.rateLimit
|
2020-10-23 16:11:00 +00:00
|
|
|
}
|
|
|
|
}
|