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

@@ -254,7 +254,7 @@ class Webhook {
*/
edit({ name = this.name, avatar }, reason) {
if (avatar && (typeof avatar === 'string' && !avatar.startsWith('data:'))) {
return this.client.resolver.resolveBuffer(avatar).then(file => {
return this.client.resolver.resolveFile(avatar).then(file => {
const dataURI = this.client.resolver.resolveBase64(file);
return this.edit({ name, avatar: dataURI }, reason);
});