Added resolveImage to reduce code duplication (#1820)

* add client#resolveImage

* oops

* resolveFile fix

* async is the future

* async

* update doc example

* build fix

* doc fix

* fix docs

* thx hydar
This commit is contained in:
Isabella
2017-08-25 15:17:38 -05:00
committed by Crawl
parent b8315b79c7
commit fbb1253b3f
6 changed files with 34 additions and 32 deletions

View File

@@ -157,18 +157,11 @@ class GroupDMChannel extends Channel {
/**
* Sets a new icon for this Group DM.
* @param {Base64Resolvable} icon The new icon of this Group DM
* @param {Base64Resolvable|BufferResolvable} icon The new icon of this Group DM
* @returns {Promise<GroupDMChannel>}
*/
setIcon(icon) {
if (typeof icon === 'string' && icon.startsWith('data:')) {
return this.edit({ icon });
} else if (!icon) {
return this.edit({ icon: null });
} else {
return this.client.resolver.resolveBuffer(icon)
.then(data => this.edit({ icon: this.client.resolver.resolveBase64(data) }));
}
async setIcon(icon) {
return this.edit({ icon: await this.client.resolver.resolveImage(icon) });
}
/**