mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: ES2021 features (#6540)
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Voltrex <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
@@ -67,8 +67,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.parentId = data.parent_id;
|
||||
} else if (!this.parentId) {
|
||||
this.parentId = null;
|
||||
} else {
|
||||
this.parentId ??= null;
|
||||
}
|
||||
|
||||
if ('thread_metadata' in data) {
|
||||
@@ -105,18 +105,10 @@ class ThreadChannel extends Channel {
|
||||
*/
|
||||
this.archiveTimestamp = new Date(data.thread_metadata.archive_timestamp).getTime();
|
||||
} else {
|
||||
if (!this.locked) {
|
||||
this.locked = null;
|
||||
}
|
||||
if (!this.archived) {
|
||||
this.archived = null;
|
||||
}
|
||||
if (!this.autoArchiveDuration) {
|
||||
this.autoArchiveDuration = null;
|
||||
}
|
||||
if (!this.archiveTimestamp) {
|
||||
this.archiveTimestamp = null;
|
||||
}
|
||||
this.locked ??= null;
|
||||
this.archived ??= null;
|
||||
this.autoArchiveDuration ??= null;
|
||||
this.archiveTimestamp ??= null;
|
||||
this.invitable ??= null;
|
||||
}
|
||||
|
||||
@@ -126,8 +118,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.ownerId = data.owner_id;
|
||||
} else if (!this.ownerId) {
|
||||
this.ownerId = null;
|
||||
} else {
|
||||
this.ownerId ??= null;
|
||||
}
|
||||
|
||||
if ('last_message_id' in data) {
|
||||
@@ -136,8 +128,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.lastMessageId = data.last_message_id;
|
||||
} else if (!this.lastMessageId) {
|
||||
this.lastMessageId = null;
|
||||
} else {
|
||||
this.lastMessageId ??= null;
|
||||
}
|
||||
|
||||
if ('last_pin_timestamp' in data) {
|
||||
@@ -146,8 +138,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?number}
|
||||
*/
|
||||
this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
|
||||
} else if (!this.lastPinTimestamp) {
|
||||
this.lastPinTimestamp = null;
|
||||
} else {
|
||||
this.lastPinTimestamp ??= null;
|
||||
}
|
||||
|
||||
if ('rate_limit_per_user' in data || !partial) {
|
||||
@@ -156,8 +148,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?number}
|
||||
*/
|
||||
this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
|
||||
} else if (!this.rateLimitPerUser) {
|
||||
this.rateLimitPerUser = null;
|
||||
} else {
|
||||
this.rateLimitPerUser ??= null;
|
||||
}
|
||||
|
||||
if ('message_count' in data) {
|
||||
@@ -168,8 +160,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?number}
|
||||
*/
|
||||
this.messageCount = data.message_count;
|
||||
} else if (!this.messageCount) {
|
||||
this.messageCount = null;
|
||||
} else {
|
||||
this.messageCount ??= null;
|
||||
}
|
||||
|
||||
if ('member_count' in data) {
|
||||
@@ -180,8 +172,8 @@ class ThreadChannel extends Channel {
|
||||
* @type {?number}
|
||||
*/
|
||||
this.memberCount = data.member_count;
|
||||
} else if (!this.memberCount) {
|
||||
this.memberCount = null;
|
||||
} else {
|
||||
this.memberCount ??= null;
|
||||
}
|
||||
|
||||
if (data.member && this.client.user) this.members._add({ user_id: this.client.user.id, ...data.member });
|
||||
|
||||
Reference in New Issue
Block a user