Skip to content

Commit

Permalink
feat(GuildPreview): add createdAt & createdTimestamp (#6130)
Browse files Browse the repository at this point in the history
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
  • Loading branch information
GoldenAngel2 and SpaceEEC committed Jul 18, 2021
1 parent c40c0f9 commit 9f039a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/structures/GuildPreview.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Expand Up @@ -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>;
Expand Down

0 comments on commit 9f039a8

Please sign in to comment.