harmony/src/structures/base.ts

25 lines
552 B
TypeScript
Raw Normal View History

2021-04-04 09:29:56 +00:00
import type { Client } from '../client/mod.ts'
import { Snowflake } from '../utils/snowflake.ts'
2020-10-24 18:11:27 +00:00
export class Base {
2021-02-12 11:37:38 +00:00
client!: Client
2020-12-02 12:29:52 +00:00
constructor(client: Client, _data?: any) {
2021-02-12 11:37:38 +00:00
Object.defineProperty(this, 'client', { value: client, enumerable: false })
}
}
export class SnowflakeBase extends Base {
id!: string
/** Get Snowflake Object */
get snowflake(): Snowflake {
return new Snowflake(this.id)
}
/** Timestamp of when resource was created */
get timestamp(): Date {
return new Date(this.snowflake.timestamp)
}
}