mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
feat(Client): make use of with_expiration in #fetchInvite (#5764)
This commit is contained in:
@@ -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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user