feat(Client): make use of with_expiration in #fetchInvite (#5764)

This commit is contained in:
Souji
2021-06-07 10:58:26 +02:00
committed by GitHub
parent 4567cd4ca2
commit bf191df9c0
2 changed files with 7 additions and 2 deletions

View File

@@ -255,7 +255,7 @@ class Client extends BaseClient {
const code = DataResolver.resolveInviteCode(invite); const code = DataResolver.resolveInviteCode(invite);
return this.api return this.api
.invites(code) .invites(code)
.get({ query: { with_counts: true } }) .get({ query: { with_counts: true, with_expiration: true } })
.then(data => new Invite(this, data)); .then(data => new Invite(this, data));
} }

View File

@@ -109,6 +109,8 @@ class Invite extends Base {
* @type {?number} * @type {?number}
*/ */
this.createdTimestamp = 'created_at' in data ? new Date(data.created_at).getTime() : null; 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 * @readonly
*/ */
get expiresTimestamp() { 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)
);
} }
/** /**