From 7f867ee1b2547a1bd5aaaf8a69ee37a0bc37e247 Mon Sep 17 00:00:00 2001 From: izexi <43889168+izexi@users.noreply.github.com> Date: Thu, 4 Apr 2019 10:57:17 +0100 Subject: [PATCH 1/4] add Webhook#url --- src/structures/Webhook.js | 9 +++++++++ typings/index.d.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 472de07ea556..867c2ff2180f 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -213,6 +213,15 @@ class Webhook { return this.client.api.webhooks(this.id, this.token).delete({ reason }); } + /** + * The url of this webhook + * @type {string} + * @readonly + */ + get url() { + return `https://discordapp.com/api/webhooks/${this.id}/${this.token}`; + } + static applyToClass(structure) { for (const prop of [ 'send', diff --git a/typings/index.d.ts b/typings/index.d.ts index f1547c87662a..6f18867fc0a3 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1270,6 +1270,7 @@ declare module 'discord.js' { public guildID: Snowflake; public name: string; public owner: User | object; + public url: string; } export class WebhookClient extends WebhookMixin(BaseClient) { From 7905bb6dcf11684971bdabc57ff45dc29dfec1d0 Mon Sep 17 00:00:00 2001 From: izexi <43889168+izexi@users.noreply.github.com> Date: Thu, 4 Apr 2019 11:12:30 +0100 Subject: [PATCH 2/4] set typing as readonly --- typings/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typings/index.d.ts b/typings/index.d.ts index 6f18867fc0a3..53857b338ca7 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1270,7 +1270,7 @@ declare module 'discord.js' { public guildID: Snowflake; public name: string; public owner: User | object; - public url: string; + public readonly url: string; } export class WebhookClient extends WebhookMixin(BaseClient) { From 4f44f5851451e95124016b7ae867fd95a32efdeb Mon Sep 17 00:00:00 2001 From: izexi <43889168+izexi@users.noreply.github.com> Date: Thu, 4 Apr 2019 15:39:08 +0100 Subject: [PATCH 3/4] suggested change --- src/structures/Webhook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index 867c2ff2180f..bd20f188cb09 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -219,7 +219,7 @@ class Webhook { * @readonly */ get url() { - return `https://discordapp.com/api/webhooks/${this.id}/${this.token}`; + return this.client.options.http.api + this.client.api.webhooks[this.id][this.token]; } static applyToClass(structure) { From 4aaa25cca690e532f24ee1ab9aad473d469283d6 Mon Sep 17 00:00:00 2001 From: izexi <43889168+izexi@users.noreply.github.com> Date: Thu, 4 Apr 2019 17:38:06 +0100 Subject: [PATCH 4/4] another one --- src/structures/Webhook.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index bd20f188cb09..1ad7cba93765 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -219,7 +219,7 @@ class Webhook { * @readonly */ get url() { - return this.client.options.http.api + this.client.api.webhooks[this.id][this.token]; + return this.client.options.http.api + this.client.api.webhooks(this.id, this.token); } static applyToClass(structure) {