mirror of
https://github.com/danbulant/discord.js
synced 2026-05-25 13:02:38 +00:00
Fix TextChannel#createWebhook
This commit is contained in:
parent
7b6190da01
commit
7f921883f4
1 changed files with 6 additions and 7 deletions
|
|
@ -60,14 +60,13 @@ class TextChannel extends GuildChannel {
|
|||
* .then(webhook => console.log(`Created webhook ${webhook}`))
|
||||
* .catch(console.error)
|
||||
*/
|
||||
createWebhook(name, { avatar, reason } = {}) {
|
||||
if (typeof avatar === 'string' && avatar.startsWith('data:')) {
|
||||
return this.client.api.channels[this.id].webhooks.post({ data: {
|
||||
name, avatar,
|
||||
}, reason }).then(data => new Webhook(this.client, data));
|
||||
async createWebhook(name, { avatar, reason } = {}) {
|
||||
if (typeof avatar === 'string' && !avatar.startsWith('data:')) {
|
||||
avatar = await this.client.resolver.resolveImage(avatar);
|
||||
}
|
||||
return this.client.resolver.resolveImage(avatar).then(image =>
|
||||
this.createWebhook(name, { avatar: image, reason }));
|
||||
return this.client.api.channels[this.id].webhooks.post({ data: {
|
||||
name, avatar,
|
||||
}, reason }).then(data => new Webhook(this.client, data));
|
||||
}
|
||||
|
||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||
|
|
|
|||
Loading…
Reference in a new issue