feat(GuildPreview): add createdAt & createdTimestamp (#6130)

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
GoldenAngel
2021-07-18 11:18:53 -07:00
committed by GitHub
parent c40c0f934a
commit 9f039a8679
2 changed files with 20 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
const Base = require('./Base');
const GuildPreviewEmoji = require('./GuildPreviewEmoji');
const Collection = require('../util/Collection');
const SnowflakeUtil = require('../util/SnowflakeUtil');
/**
* Represents the data about the guild any bot can preview, connected to the specified guild.
@@ -90,6 +91,23 @@ class GuildPreview extends Base {
this.emojis.set(emoji.id, new GuildPreviewEmoji(this.client, emoji, this));
}
}
/**
* The timestamp this guild was created at
* @type {number}
* @readonly
*/
get createdTimestamp() {
return SnowflakeUtil.deconstruct(this.id).timestamp;
}
/**
* The time this guild was created at
* @type {Date}
* @readonly
*/
get createdAt() {
return new Date(this.createdTimestamp);
}
/**
* The URL to this guild's splash.

2
typings/index.d.ts vendored
View File

@@ -758,6 +758,8 @@ export class GuildPreview extends Base {
public constructor(client: Client, data: unknown);
public approximateMemberCount: number;
public approximatePresenceCount: number;
public readonly createdAt: Date;
public readonly createdTimestamp: number;
public description: string | null;
public discoverySplash: string | null;
public emojis: Collection<Snowflake, GuildPreviewEmoji>;