From bf191df9c033404da3e717f73306cdb3f659fafc Mon Sep 17 00:00:00 2001 From: Souji Date: Mon, 7 Jun 2021 10:58:26 +0200 Subject: [PATCH] feat(Client): make use of with_expiration in #fetchInvite (#5764) --- src/client/Client.js | 2 +- src/structures/Invite.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index e68da9ce4524..d522f2430c9e 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -255,7 +255,7 @@ class Client extends BaseClient { const code = DataResolver.resolveInviteCode(invite); return this.api .invites(code) - .get({ query: { with_counts: true } }) + .get({ query: { with_counts: true, with_expiration: true } }) .then(data => new Invite(this, data)); } diff --git a/src/structures/Invite.js b/src/structures/Invite.js index 50a5660aafdd..be7810afc8a0 100644 --- a/src/structures/Invite.js +++ b/src/structures/Invite.js @@ -109,6 +109,8 @@ class Invite extends Base { * @type {?number} */ this.createdTimestamp = 'created_at' in data ? new Date(data.created_at).getTime() : null; + + this._expiresTimestamp = 'expires_at' in data ? new Date(data.expires_at).getTime() : null; } /** @@ -141,7 +143,10 @@ class Invite extends Base { * @readonly */ get expiresTimestamp() { - return this.createdTimestamp && this.maxAge ? this.createdTimestamp + this.maxAge * 1000 : null; + return ( + this._expiresTimestamp ?? + (this.createdTimestamp && this.maxAge ? this.createdTimestamp + this.maxAge * 1000 : null) + ); } /**