Skip to content

Commit

Permalink
fix: Prevent NaN for nullable timestamps (#7750)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Jiralite and almeidx committed Apr 12, 2022
1 parent 3037fca commit 8625d81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/discord.js/src/structures/Invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/VoiceState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8625d81

Please sign in to comment.