import { AbstractEntity } from '@src/api/entities/AbstractEntity' ; import { ChannelTypes } from '@src/constants' ; import { idToDate , idToTimestamp , attach } from '@src/utils' ; import { AbstractChannelData } from '@src/api/entities/channel/interfaces/AbstractChannelData' ; import { ToJsonProperties } from '@src/api/entities/interfaces/ToJsonProperties' ; import { Json } from '@src/api/entities/interfaces/Json' ; export abstract class AbstractChannel extends AbstractEntity { public id ! : string ; public type ! : ChannelTypes ; public deleted ! : boolean ; async init ( data ) { attach ( this , data , [ 'id' , 'type' ] ) ; this . deleted = ! ! data . deleted ; return this ; } delete ( reason ) { return this . client . channels . delete ( this . id , { reason , patchEntity : this } ) ; } get createdTimestamp ( ) : number { return idToTimestamp ( this . id ) ; } get createdDate ( ) : Date { return idToDate ( this . id ) ; } toString ( ) { return `<#${ this . id }>` ; } toJson ( properties = { } , obj ? ) { return super . toJson ( { ... properties , id : true , type : true , deleted : true } , obj ) ; } }