* Add reasons

* How could I forget

* Hopefully fix conflicts
This commit is contained in:
Pg Biel
2017-07-26 22:14:04 -03:00
committed by Crawl
parent 27196c2f9f
commit eef87e5d97
6 changed files with 78 additions and 50 deletions

View File

@@ -66,17 +66,18 @@ class TextChannel extends GuildChannel {
* Create a webhook for the channel.
* @param {string} name The name of the webhook
* @param {BufferResolvable|Base64Resolvable} avatar The avatar for the webhook
* @param {string} [reason] Reason for creating this webhook
* @returns {Promise<Webhook>} webhook The created webhook
* @example
* channel.createWebhook('Snek', 'http://snek.s3.amazonaws.com/topSnek.png')
* .then(webhook => console.log(`Created webhook ${webhook}`))
* .catch(console.error)
*/
createWebhook(name, avatar) {
createWebhook(name, avatar, reason) {
if (typeof avatar === 'string' && avatar.startsWith('data:')) {
return this.client.api.channels[this.id].webhooks.post({ data: {
name, avatar,
} }).then(data => new Webhook(this.client, data));
}, reason }).then(data => new Webhook(this.client, data));
} else {
return this.client.resolver.resolveBuffer(avatar).then(data =>
this.createWebhook(name, this.client.resolver.resolveBase64(data) || null));