mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Reasons (#1715)
* Add reasons * How could I forget * Hopefully fix conflicts
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user