From e9920a9c98ffb78bd7d0ae00d486476367296646 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Wed, 27 Jul 2022 11:09:18 +0100 Subject: [PATCH] docs(WebhookClient): Make constructor a union (#8370) Co-authored-by: muchnameless <12682826+muchnameless@users.noreply.github.com> --- .../discord.js/src/client/WebhookClient.js | 20 ++++++++++++++----- packages/discord.js/src/util/Util.js | 11 ++-------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/discord.js/src/client/WebhookClient.js b/packages/discord.js/src/client/WebhookClient.js index 9aff4b51f..5ac56d650 100644 --- a/packages/discord.js/src/client/WebhookClient.js +++ b/packages/discord.js/src/client/WebhookClient.js @@ -12,11 +12,21 @@ const { parseWebhookURL } = require('../util/Util'); */ class WebhookClient extends BaseClient { /** - * The data for the webhook client containing either an id and token or just a URL - * @typedef {Object} WebhookClientData - * @property {Snowflake} [id] The id of the webhook - * @property {string} [token] The token of the webhook - * @property {string} [url] The full URL for the webhook client + * Represents the credentials used for a webhook in the form of its id and token. + * @typedef {Object} WebhookClientDataIdWithToken + * @property {Snowflake} id The webhook's id + * @property {string} token The webhook's token + */ + + /** + * Represents the credentials used for a webhook in the form of a URL. + * @typedef {Object} WebhookClientDataURL + * @property {string} url The full URL for the webhook + */ + + /** + * Represents the credentials used for a webhook. + * @typedef {WebhookClientDataIdWithToken|WebhookClientDataURL} WebhookClientData */ /** diff --git a/packages/discord.js/src/util/Util.js b/packages/discord.js/src/util/Util.js index 9409dbcd3..41e06eb8b 100644 --- a/packages/discord.js/src/util/Util.js +++ b/packages/discord.js/src/util/Util.js @@ -520,16 +520,9 @@ function lazy(cb) { } /** - * Represents the credentials used for a given webhook - * @typedef {Object} WebhookCredentials - * @property {string} id The webhook's id - * @property {string} token The webhook's token - */ - -/** - * Parses a webhook URL for the id and token + * Parses a webhook URL for the id and token. * @param {string} url The URL to parse - * @returns {?WebhookCredentials} Null if the URL is invalid, otherwise the id and the token + * @returns {?WebhookClientDataIdWithToken} `null` if the URL is invalid, otherwise the id and the token */ function parseWebhookURL(url) { const matches = url.match(