Skip to content

Commit

Permalink
feat(Client): make use of with_expiration in #fetchInvite (#5764)
Browse files Browse the repository at this point in the history
  • Loading branch information
almostSouji committed Jun 7, 2021
1 parent 4567cd4 commit bf191df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/Client.js
Expand Up @@ -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));
}

Expand Down
7 changes: 6 additions & 1 deletion src/structures/Invite.js
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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)
);
}

/**
Expand Down

0 comments on commit bf191df

Please sign in to comment.