Simplified image resolving and used an options object when creating webhooks (#1843)

This commit is contained in:
SpaceEEC
2017-08-28 00:11:19 +02:00
committed by Crawl
parent 258fc4ecf3
commit c4fecf6609
4 changed files with 14 additions and 18 deletions

View File

@@ -254,10 +254,9 @@ class Webhook {
*/
edit({ name = this.name, avatar }, reason) {
if (avatar && (typeof avatar === 'string' && !avatar.startsWith('data:'))) {
return this.client.resolver.resolveFile(avatar).then(file => {
const dataURI = this.client.resolver.resolveBase64(file);
return this.edit({ name, avatar: dataURI }, reason);
});
return this.client.resolver.resolveImage(avatar).then(image =>
this.edit({ name, avatar: image }, reason)
);
}
return this.client.api.webhooks(this.id, this.token).patch({
data: { name, avatar },