fix: don't patch set data with undefined (#6694)

This commit is contained in:
Rodry
2021-10-03 13:59:52 +01:00
committed by GitHub
parent 8b4456e0aa
commit 9eb9591473
33 changed files with 1211 additions and 795 deletions

View File

@@ -25,65 +25,85 @@ class GuildTemplate extends Base {
* @private
*/
_patch(data) {
/**
* The unique code of this template
* @type {string}
*/
this.code = data.code;
if ('code' in data) {
/**
* The unique code of this template
* @type {string}
*/
this.code = data.code;
}
/**
* The name of this template
* @type {string}
*/
this.name = data.name;
if ('name' in data) {
/**
* The name of this template
* @type {string}
*/
this.name = data.name;
}
/**
* The description of this template
* @type {?string}
*/
this.description = data.description;
if ('description' in data) {
/**
* The description of this template
* @type {?string}
*/
this.description = data.description;
}
/**
* The amount of times this template has been used
* @type {number}
*/
this.usageCount = data.usage_count;
if ('usage_count' in data) {
/**
* The amount of times this template has been used
* @type {number}
*/
this.usageCount = data.usage_count;
}
/**
* The id of the user that created this template
* @type {Snowflake}
*/
this.creatorId = data.creator_id;
if ('creator_id' in data) {
/**
* The id of the user that created this template
* @type {Snowflake}
*/
this.creatorId = data.creator_id;
}
/**
* The user that created this template
* @type {User}
*/
this.creator = this.client.users._add(data.creator);
if ('creator' in data) {
/**
* The user that created this template
* @type {User}
*/
this.creator = this.client.users._add(data.creator);
}
/**
* The time of when this template was created at
* @type {Date}
*/
this.createdAt = new Date(data.created_at);
if ('created_at' in data) {
/**
* The time of when this template was created at
* @type {Date}
*/
this.createdAt = new Date(data.created_at);
}
/**
* The time of when this template was last synced to the guild
* @type {Date}
*/
this.updatedAt = new Date(data.updated_at);
if ('updated_at' in data) {
/**
* The time of when this template was last synced to the guild
* @type {Date}
*/
this.updatedAt = new Date(data.updated_at);
}
/**
* The id of the guild that this template belongs to
* @type {Snowflake}
*/
this.guildId = data.source_guild_id;
if ('source_guild_id' in data) {
/**
* The id of the guild that this template belongs to
* @type {Snowflake}
*/
this.guildId = data.source_guild_id;
}
/**
* The data of the guild that this template would create
* @type {APIGuild}
*/
this.serializedGuild = data.serialized_source_guild;
if ('serialized_source_guild' in data) {
/**
* The data of the guild that this template would create
* @type {APIGuild}
*/
this.serializedGuild = data.serialized_source_guild;
}
/**
* Whether this template has unsynced changes