mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
fix: don't patch missing properties from partial payloads (#5796)
* fix: don't patch missing properties from partial payloads * fix(GuildChannel): initialize permissionOverwrites in the constructor * refactor(GuildChannel): remove redundant if
This commit is contained in:
@@ -28,7 +28,6 @@ class TextChannel extends GuildChannel {
|
||||
/**
|
||||
* If the guild considers this channel NSFW
|
||||
* @type {boolean}
|
||||
* @readonly
|
||||
*/
|
||||
this.nsfw = Boolean(data.nsfw);
|
||||
this._typing = new Map();
|
||||
@@ -37,34 +36,46 @@ class TextChannel extends GuildChannel {
|
||||
_patch(data) {
|
||||
super._patch(data);
|
||||
|
||||
/**
|
||||
* The topic of the text channel
|
||||
* @type {?string}
|
||||
*/
|
||||
this.topic = data.topic;
|
||||
if ('topic' in data) {
|
||||
/**
|
||||
* The topic of the text channel
|
||||
* @type {?string}
|
||||
*/
|
||||
this.topic = data.topic;
|
||||
}
|
||||
|
||||
if (typeof data.nsfw !== 'undefined') this.nsfw = Boolean(data.nsfw);
|
||||
if ('nsfw' in data) {
|
||||
this.nsfw = Boolean(data.nsfw);
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the last message sent in this channel, if one was sent
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.lastMessageID = data.last_message_id;
|
||||
if ('last_message_id' in data) {
|
||||
/**
|
||||
* The ID of the last message sent in this channel, if one was sent
|
||||
* @type {?Snowflake}
|
||||
*/
|
||||
this.lastMessageID = data.last_message_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ratelimit per user for this channel in seconds
|
||||
* <warn>It is not currently possible to set a rate limit per user on a `NewsChannel`.</warn>
|
||||
* @type {number}
|
||||
*/
|
||||
this.rateLimitPerUser = data.rate_limit_per_user || 0;
|
||||
if ('rate_limit_per_user' in data) {
|
||||
/**
|
||||
* The ratelimit per user for this channel in seconds
|
||||
* <warn>It is not currently possible to set a rate limit per user on a `NewsChannel`.</warn>
|
||||
* @type {number}
|
||||
*/
|
||||
this.rateLimitPerUser = data.rate_limit_per_user;
|
||||
}
|
||||
|
||||
/**
|
||||
* The timestamp when the last pinned message was pinned, if there was one
|
||||
* @type {?number}
|
||||
*/
|
||||
this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
|
||||
if ('last_pin_timestamp' in data) {
|
||||
/**
|
||||
* The timestamp when the last pinned message was pinned, if there was one
|
||||
* @type {?number}
|
||||
*/
|
||||
this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
|
||||
}
|
||||
|
||||
if (data.messages) for (const message of data.messages) this.messages.add(message);
|
||||
if ('messages' in data) {
|
||||
for (const message of data.messages) this.messages.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user