From 330d5db5868ad61bbdae5ba0b2090d10d76ae9c9 Mon Sep 17 00:00:00 2001 From: Carter <45381083+Fyko@users.noreply.github.com> Date: Sun, 15 Dec 2019 12:20:15 -0700 Subject: [PATCH] feat(Webhook): addition of Webhook#avatarURL function (#3625) * feat: addition of Webhook#avatarURL * typings: added Webhook#avatarURL * fix: trailing space * docs: fixed jsdoc function description * fix: typo --- src/structures/Webhook.js | 10 ++++++++++ typings/index.d.ts | 1 + 2 files changed, 11 insertions(+) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 2ed6137b4..da7dcd12f 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -220,6 +220,16 @@ class Webhook { return this.client.options.http.api + this.client.api.webhooks(this.id, this.token); } + /** + * A link to the webhook's avatar. + * @param {ImageURLOptions} [options={}] Options for the Image URL + * @returns {?string} + */ + avatarURL({ format, size } = {}) { + if (!this.avatar) return null; + return this.client.rest.cdn.Avatar(this.id, this.avatar, format, size); + } + static applyToClass(structure) { for (const prop of [ 'send', diff --git a/typings/index.d.ts b/typings/index.d.ts index abab6b954..cb2ccda02 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1620,6 +1620,7 @@ declare module 'discord.js' { export class Webhook extends WebhookMixin() { constructor(client: Client, data?: object); public avatar: string; + public avatarURL(options?: AvatarOptions): string | null; public channelID: Snowflake; public guildID: Snowflake; public name: string;