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

@@ -34,48 +34,61 @@ class Role extends Base {
* @type {Snowflake}
*/
this.id = data.id;
if ('name' in data) {
/**
* The name of the role
* @type {string}
*/
this.name = data.name;
}
/**
* The name of the role
* @type {string}
*/
this.name = data.name;
if ('color' in data) {
/**
* The base 10 color of the role
* @type {number}
*/
this.color = data.color;
}
/**
* The base 10 color of the role
* @type {number}
*/
this.color = data.color;
if ('hoist' in data) {
/**
* If true, users that are part of this role will appear in a separate category in the users list
* @type {boolean}
*/
this.hoist = data.hoist;
}
/**
* If true, users that are part of this role will appear in a separate category in the users list
* @type {boolean}
*/
this.hoist = data.hoist;
if ('position' in data) {
/**
* The raw position of the role from the API
* @type {number}
*/
this.rawPosition = data.position;
}
/**
* The raw position of the role from the API
* @type {number}
*/
this.rawPosition = data.position;
if ('permissions' in data) {
/**
* The permissions of the role
* @type {Readonly<Permissions>}
*/
this.permissions = new Permissions(BigInt(data.permissions)).freeze();
}
/**
* The permissions of the role
* @type {Readonly<Permissions>}
*/
this.permissions = new Permissions(BigInt(data.permissions)).freeze();
if ('managed' in data) {
/**
* Whether or not the role is managed by an external service
* @type {boolean}
*/
this.managed = data.managed;
}
/**
* Whether or not the role is managed by an external service
* @type {boolean}
*/
this.managed = data.managed;
/**
* Whether or not the role can be mentioned by anyone
* @type {boolean}
*/
this.mentionable = data.mentionable;
if ('mentionable' in data) {
/**
* Whether or not the role can be mentioned by anyone
* @type {boolean}
*/
this.mentionable = data.mentionable;
}
/**
* Whether the role has been deleted