fix: Prevent NaN for nullable timestamps (#7750)

* fix(VoiceState): don't show `NaN`

* fix(Invite): handle NaN

* refactor: `&&` usage

Co-authored-by: Almeida <almeidx@pm.me>

Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
Jiralite
2022-04-12 16:14:04 +01:00
committed by GitHub
parent 3037fca196
commit 8625d81714
2 changed files with 6 additions and 3 deletions

View File

@@ -188,8 +188,11 @@ class Invite extends Base {
this.createdTimestamp ??= null;
}
if ('expires_at' in data) this._expiresTimestamp = Date.parse(data.expires_at);
else this._expiresTimestamp ??= null;
if ('expires_at' in data) {
this._expiresTimestamp = data.expires_at && Date.parse(data.expires_at);
} else {
this._expiresTimestamp ??= null;
}
if ('stage_instance' in data) {
/**

View File

@@ -121,7 +121,7 @@ class VoiceState extends Base {
* The time at which the member requested to speak. This property is specific to stage channels only.
* @type {?number}
*/
this.requestToSpeakTimestamp = Date.parse(data.request_to_speak_timestamp);
this.requestToSpeakTimestamp = data.request_to_speak_timestamp && Date.parse(data.request_to_speak_timestamp);
} else {
this.requestToSpeakTimestamp ??= null;
}