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

@@ -68,41 +68,59 @@ class MessageAttachment {
*/
this.id = data.id;
/**
* The size of this attachment in bytes
* @type {number}
*/
this.size = data.size;
if ('size' in data) {
/**
* The size of this attachment in bytes
* @type {number}
*/
this.size = data.size;
}
/**
* The URL to this attachment
* @type {string}
*/
this.url = data.url;
if ('url' in data) {
/**
* The URL to this attachment
* @type {string}
*/
this.url = data.url;
}
/**
* The Proxy URL to this attachment
* @type {string}
*/
this.proxyURL = data.proxy_url;
if ('proxy_url' in data) {
/**
* The Proxy URL to this attachment
* @type {string}
*/
this.proxyURL = data.proxy_url;
}
/**
* The height of this attachment (if an image or video)
* @type {?number}
*/
this.height = data.height ?? null;
if ('height' in data) {
/**
* The height of this attachment (if an image or video)
* @type {?number}
*/
this.height = data.height;
} else {
this.height ??= null;
}
/**
* The width of this attachment (if an image or video)
* @type {?number}
*/
this.width = data.width ?? null;
if ('width' in data) {
/**
* The width of this attachment (if an image or video)
* @type {?number}
*/
this.width = data.width;
} else {
this.width ??= null;
}
/**
* This media type of this attachment
* @type {?string}
*/
this.contentType = data.content_type ?? null;
if ('content_type' in data) {
/**
* This media type of this attachment
* @type {?string}
*/
this.contentType = data.content_type;
} else {
this.contentType ??= null;
}
/**
* Whether this attachment is ephemeral