From 1fe36087d4a665fc61905a84e69f2257437a1a72 Mon Sep 17 00:00:00 2001 From: Isabella Date: Wed, 10 Oct 2018 02:57:13 -0500 Subject: [PATCH] feat(MessageEmbed): allow setTimestamp to take a timestamp (#2875) * feat: allow MessageEmbed#setTimestamp to take a timestamp * fix the dumb i did --- src/structures/MessageEmbed.js | 7 ++++--- typings/index.d.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index 2d0208b24..5d2b2066f 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -267,11 +267,12 @@ class MessageEmbed { /** * Sets the timestamp of this embed. - * @param {Date} [timestamp=current date] The timestamp + * @param {Date|number} [timestamp=Date.now()] The timestamp or date * @returns {MessageEmbed} */ - setTimestamp(timestamp = new Date()) { - this.timestamp = timestamp.getTime(); + setTimestamp(timestamp = Date.now()) { + if (timestamp instanceof Date) timestamp = timestamp.getTime(); + this.timestamp = timestamp; return this; } diff --git a/typings/index.d.ts b/typings/index.d.ts index ad9baa67e..8e66679b7 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -741,7 +741,7 @@ declare module 'discord.js' { public setFooter(text: StringResolvable, iconURL?: string): this; public setImage(url: string): this; public setThumbnail(url: string): this; - public setTimestamp(timestamp?: Date): this; + public setTimestamp(timestamp?: Date | number): this; public setTitle(title: StringResolvable): this; public setURL(url: string): this; public toJSON(): object;