From 49e8bd9eddd204c357f3f4850767705b86233cba Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Tue, 12 Feb 2019 10:15:37 +0100 Subject: [PATCH] feat(RichEmbed): add timestamp support for setTimestamp (#3061) --- src/structures/RichEmbed.js | 5 +++-- typings/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/structures/RichEmbed.js b/src/structures/RichEmbed.js index b1cb0b7f0..d8e16ccea 100644 --- a/src/structures/RichEmbed.js +++ b/src/structures/RichEmbed.js @@ -140,10 +140,11 @@ class RichEmbed { /** * Sets the timestamp of this embed. - * @param {Date} [timestamp=new Date()] The timestamp + * @param {Date|number} [timestamp=Date.now()] The timestamp or date * @returns {RichEmbed} This embed */ - setTimestamp(timestamp = new Date()) { + 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 c4676847f..4db2ee0b7 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1030,7 +1030,7 @@ declare module 'discord.js' { public setFooter(text: StringResolvable, icon?: 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; }