diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2023-09-02 19:12:47 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2023-09-02 19:12:47 -0400 |
commit | e4450c8417624b71d779cb4f41692538f9165e10 (patch) | |
tree | b70826542223ecdf8a7a259f61b0a1abb8a217d8 /node_modules/discord.js/src/client/WebhookClient.js | |
download | sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.gz sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.bz2 sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.zip |
first commit
Diffstat (limited to 'node_modules/discord.js/src/client/WebhookClient.js')
-rw-r--r-- | node_modules/discord.js/src/client/WebhookClient.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/client/WebhookClient.js b/node_modules/discord.js/src/client/WebhookClient.js new file mode 100644 index 0000000..5bb6412 --- /dev/null +++ b/node_modules/discord.js/src/client/WebhookClient.js @@ -0,0 +1,103 @@ +'use strict'; + +const BaseClient = require('./BaseClient'); +const { DiscordjsError, ErrorCodes } = require('../errors'); +const Webhook = require('../structures/Webhook'); +const { parseWebhookURL } = require('../util/Util'); + +/** + * The webhook client. + * @implements {Webhook} + * @extends {BaseClient} + */ +class WebhookClient extends BaseClient { + /** + * 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 + */ + + /** + * Options for a webhook client. + * @typedef {Object} WebhookClientOptions + * @property {MessageMentionOptions} [allowedMentions] Default value for {@link BaseMessageOptions#allowedMentions} + * @property {RESTOptions} [rest] Options for the REST manager + */ + + /** + * @param {WebhookClientData} data The data of the webhook + * @param {WebhookClientOptions} [options] Options for the webhook client + */ + constructor(data, options) { + super(options); + Object.defineProperty(this, 'client', { value: this }); + let { id, token } = data; + + if ('url' in data) { + const parsed = parseWebhookURL(data.url); + if (!parsed) { + throw new DiscordjsError(ErrorCodes.WebhookURLInvalid); + } + + ({ id, token } = parsed); + } + + this.id = id; + Object.defineProperty(this, 'token', { value: token, writable: true, configurable: true }); + } + + /** + * The options the webhook client was instantiated with. + * @type {WebhookClientOptions} + * @name WebhookClient#options + */ + + // These are here only for documentation purposes - they are implemented by Webhook + /* eslint-disable no-empty-function, valid-jsdoc */ + /** + * Sends a message with this webhook. + * @param {string|MessagePayload|WebhookMessageCreateOptions} options The content for the reply + * @returns {Promise<APIMessage>} + */ + send() {} + + /** + * Gets a message that was sent by this webhook. + * @param {Snowflake} message The id of the message to fetch + * @param {WebhookFetchMessageOptions} [options={}] The options to provide to fetch the message. + * @returns {Promise<APIMessage>} Returns the message sent by this webhook + */ + fetchMessage() {} + + /** + * Edits a message that was sent by this webhook. + * @param {MessageResolvable} message The message to edit + * @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide + * @returns {Promise<APIMessage>} Returns the message edited by this webhook + */ + editMessage() {} + + sendSlackMessage() {} + edit() {} + delete() {} + deleteMessage() {} + get createdTimestamp() {} + get createdAt() {} + get url() {} +} + +Webhook.applyToClass(WebhookClient); + +module.exports = WebhookClient; |