Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(GuildPreview): add createdAt & createdTimestamp #6130

Merged
merged 3 commits into from Jul 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 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,24 @@ class GuildPreview extends Base {
this.emojis.set(emoji.id, new GuildPreviewEmoji(this.client, emoji, this));
}
}

GoldenAngel2 marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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 @@ -711,6 +711,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