Clean up a bunch of promise stuff

This commit is contained in:
Schuyler Cebulskie
2016-10-30 12:47:09 -04:00
parent c42e7a15aa
commit 8306d50bd8
12 changed files with 112 additions and 161 deletions

View File

@@ -145,11 +145,11 @@ class Webhook {
}
return new Promise((resolve, reject) => {
this.client.resolver.resolveFile(attachment).then(file => {
this.client.rest.methods.sendWebhookMessage(this, content, options, {
resolve(this.client.rest.methods.sendWebhookMessage(this, content, options, {
file,
name: fileName,
}).then(resolve).catch(reject);
}).catch(reject);
}));
}, reject);
});
}
@@ -181,14 +181,13 @@ class Webhook {
if (avatar) {
this.client.resolver.resolveFile(avatar).then(file => {
const dataURI = this.client.resolver.resolveBase64(file);
this.client.rest.methods.editWebhook(this, name, dataURI)
.then(resolve).catch(reject);
}).catch(reject);
resolve(this.client.rest.methods.editWebhook(this, name, dataURI));
}, reject);
} else {
this.client.rest.methods.editWebhook(this, name)
.then(data => {
this.client.rest.methods.editWebhook(this, name).then(data => {
this.setup(data);
}).catch(reject);
resolve(this);
}, reject);
}
});
}