From 943767dc8345964e99d00a0bb4e7b0a9cd2bdb6b Mon Sep 17 00:00:00 2001 From: HyperCoder Date: Mon, 5 Sep 2016 10:59:27 -0400 Subject: [PATCH] Add .createdAt (#620) * Add Role.createdAt * Add Channel.createdAt * Add Guild.createdAt * Add User.createdAt * Change createdAt to Unix Timestamp * Add createdAt to Emojis * Change createdAt to Unix Timestamp --- src/structures/Channel.js | 9 +++++++++ src/structures/Emoji.js | 9 +++++++++ src/structures/Guild.js | 9 +++++++++ src/structures/Role.js | 9 +++++++++ src/structures/User.js | 9 +++++++++ 5 files changed, 45 insertions(+) diff --git a/src/structures/Channel.js b/src/structures/Channel.js index ae36545ac..848336ced 100644 --- a/src/structures/Channel.js +++ b/src/structures/Channel.js @@ -31,6 +31,15 @@ class Channel { this.id = data.id; } + /** + * The unix timestamp the channel was created + * @readonly + * @type {Date} + */ + get createdAt() { + return new Date((+this.id / 4194304) + 1420070400000).getTime(); + } + /** * Deletes the channel * @returns {Promise} diff --git a/src/structures/Emoji.js b/src/structures/Emoji.js index 28c93bb98..988beb463 100644 --- a/src/structures/Emoji.js +++ b/src/structures/Emoji.js @@ -43,6 +43,15 @@ class Emoji { this.managed = data.managed; } + /** + * The unix timestamp the emoji was created + * @readonly + * @type {Date} + */ + get createdAt() { + return new Date((+this.id / 4194304) + 1420070400000).getTime(); + } + /** * A collection of roles this emoji is active for (empty if all), mapped by role ID. * @type {Collection} diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 59d1fb5e7..b24a65450 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -332,6 +332,15 @@ class Guild { } } + /** + * The unix timestamp the guild was created + * @readonly + * @type {Date} + */ + get createdAt() { + return new Date((+this.id / 4194304) + 1420070400000).getTime(); + } + /** * The date at which the logged-in client joined the guild. * @type {Date} diff --git a/src/structures/Role.js b/src/structures/Role.js index febe970b9..80caa3281 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -67,6 +67,15 @@ class Role { this.managed = data.managed; } + /** + * The unix timestamp the role was created + * @readonly + * @type {Date} + */ + get createdAt() { + return new Date((+this.id / 4194304) + 1420070400000).getTime(); + } + /** * Deletes the role * @returns {Promise} diff --git a/src/structures/User.js b/src/structures/User.js index 53a0926c8..644110533 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -53,6 +53,15 @@ class User { this.game = data.game || this.game; } + /** + * The unix timestamp the user was created + * @readonly + * @type {Date} + */ + get createdAt() { + return new Date((+this.id / 4194304) + 1420070400000).getTime(); + } + /** * When concatenated with a string, this automatically concatenates the User's mention instead of the User object. * @returns {string}