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

@@ -438,13 +438,15 @@ class Message {
* .catch(console.error);
*/
delete(timeout = 0) {
return new Promise((resolve, reject) => {
this.client.setTimeout(() => {
this.client.rest.methods.deleteMessage(this)
.then(resolve)
.catch(reject);
}, timeout);
});
if (timeout <= 0) {
return this.client.rest.methods.deleteMessage(this);
} else {
return new Promise(resolve => {
this.client.setTimeout(() => {
resolve(this.delete());
}, timeout);
});
}
}
/**