mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 12:33:30 +01:00
Fix TextChannel#createWebhook
This commit is contained in:
@@ -60,14 +60,13 @@ class TextChannel extends GuildChannel {
|
|||||||
* .then(webhook => console.log(`Created webhook ${webhook}`))
|
* .then(webhook => console.log(`Created webhook ${webhook}`))
|
||||||
* .catch(console.error)
|
* .catch(console.error)
|
||||||
*/
|
*/
|
||||||
createWebhook(name, { avatar, reason } = {}) {
|
async createWebhook(name, { avatar, reason } = {}) {
|
||||||
if (typeof avatar === 'string' && avatar.startsWith('data:')) {
|
if (typeof avatar === 'string' && !avatar.startsWith('data:')) {
|
||||||
return this.client.api.channels[this.id].webhooks.post({ data: {
|
avatar = await this.client.resolver.resolveImage(avatar);
|
||||||
name, avatar,
|
|
||||||
}, reason }).then(data => new Webhook(this.client, data));
|
|
||||||
}
|
}
|
||||||
return this.client.resolver.resolveImage(avatar).then(image =>
|
return this.client.api.channels[this.id].webhooks.post({ data: {
|
||||||
this.createWebhook(name, { avatar: image, reason }));
|
name, avatar,
|
||||||
|
}, reason }).then(data => new Webhook(this.client, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
// These are here only for documentation purposes - they are implemented by TextBasedChannel
|
||||||
|
|||||||
Reference in New Issue
Block a user