mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-20 13:33:30 +01:00
fix(timestamps): account for timestamps of 0 when creating Dates (#7226)
This commit is contained in:
@@ -266,7 +266,10 @@ class GuildMemberManager extends CachedManager {
|
|||||||
_data.roles &&= _data.roles.map(role => (role instanceof Role ? role.id : role));
|
_data.roles &&= _data.roles.map(role => (role instanceof Role ? role.id : role));
|
||||||
|
|
||||||
_data.communication_disabled_until =
|
_data.communication_disabled_until =
|
||||||
_data.communicationDisabledUntil && new Date(_data.communicationDisabledUntil).toISOString();
|
// eslint-disable-next-line eqeqeq
|
||||||
|
_data.communicationDisabledUntil != null
|
||||||
|
? new Date(_data.communicationDisabledUntil).toISOString()
|
||||||
|
: _data.communicationDisabledUntil;
|
||||||
|
|
||||||
let endpoint = this.client.api.guilds(this.guild.id);
|
let endpoint = this.client.api.guilds(this.guild.id);
|
||||||
if (id === this.client.user.id) {
|
if (id === this.client.user.id) {
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ class MessageEmbed {
|
|||||||
* @type {?number}
|
* @type {?number}
|
||||||
*/
|
*/
|
||||||
// Date.parse() cannot be used here because data.timestamp might be a number
|
// Date.parse() cannot be used here because data.timestamp might be a number
|
||||||
// Additionally, the nullish coalescing operator cannot be used here as we're checking for 0
|
// eslint-disable-next-line eqeqeq
|
||||||
this.timestamp = new Date(data.timestamp).getTime() || null;
|
this.timestamp = data.timestamp != null ? new Date(data.timestamp).getTime() : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a field of a MessageEmbed
|
* Represents a field of a MessageEmbed
|
||||||
@@ -242,7 +242,7 @@ class MessageEmbed {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get createdAt() {
|
get createdAt() {
|
||||||
return this.timestamp && new Date(this.timestamp);
|
return typeof this.timestamp === 'number' ? new Date(this.timestamp) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user