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

@@ -30,53 +30,71 @@ class GuildPreview extends Base {
*/
this.id = data.id;
/**
* The name of this guild
* @type {string}
*/
this.name = data.name;
if ('name' in data) {
/**
* The name of this guild
* @type {string}
*/
this.name = data.name;
}
/**
* The icon of this guild
* @type {?string}
*/
this.icon = data.icon;
if ('icon' in data) {
/**
* The icon of this guild
* @type {?string}
*/
this.icon = data.icon;
}
/**
* The splash icon of this guild
* @type {?string}
*/
this.splash = data.splash;
if ('splash' in data) {
/**
* The splash icon of this guild
* @type {?string}
*/
this.splash = data.splash;
}
/**
* The discovery splash icon of this guild
* @type {?string}
*/
this.discoverySplash = data.discovery_splash;
if ('discovery_splash' in data) {
/**
* The discovery splash icon of this guild
* @type {?string}
*/
this.discoverySplash = data.discovery_splash;
}
/**
* An array of enabled guild features
* @type {Features[]}
*/
this.features = data.features;
if ('features' in data) {
/**
* An array of enabled guild features
* @type {Features[]}
*/
this.features = data.features;
}
/**
* The approximate count of members in this guild
* @type {number}
*/
this.approximateMemberCount = data.approximate_member_count;
if ('approximate_member_count' in data) {
/**
* The approximate count of members in this guild
* @type {number}
*/
this.approximateMemberCount = data.approximate_member_count;
}
/**
* The approximate count of online members in this guild
* @type {number}
*/
this.approximatePresenceCount = data.approximate_presence_count;
if ('approximate_presence_count' in data) {
/**
* The approximate count of online members in this guild
* @type {number}
*/
this.approximatePresenceCount = data.approximate_presence_count;
}
/**
* The description for this guild
* @type {?string}
*/
this.description = data.description ?? null;
if ('description' in data) {
/**
* The description for this guild
* @type {?string}
*/
this.description = data.description;
} else {
this.description ??= null;
}
if (!this.emojis) {
/**