MCPcopy
hub / github.com/discordjs/discord.js / Webhook

Class Webhook

packages/discord.js/src/structures/Webhook.js:16–487  ·  view source on GitHub ↗

* Represents a webhook.

Source from the content-addressed store, hash-verified

14 * Represents a webhook.
15 */
16class Webhook {
17 constructor(client, data) {
18 /**
19 * The client that instantiated the webhook
20 * @name Webhook#client
21 * @type {Client}
22 * @readonly
23 */
24 Object.defineProperty(this, 'client', { value: client });
25 this._patch(data);
26 }
27
28 _patch(data) {
29 if ('name' in data) {
30 /**
31 * The name of the webhook
32 * @type {string}
33 */
34 this.name = data.name;
35 }
36
37 /**
38 * The token for the webhook, unavailable for follower webhooks and webhooks owned by another application.
39 * @name Webhook#token
40 * @type {?string}
41 */
42 Object.defineProperty(this, 'token', {
43 value: data.token ?? null,
44 writable: true,
45 configurable: true,
46 });
47
48 if ('avatar' in data) {
49 /**
50 * The avatar for the webhook
51 * @type {?string}
52 */
53 this.avatar = data.avatar;
54 }
55
56 /**
57 * The webhook's id
58 * @type {Snowflake}
59 */
60 this.id = data.id;
61
62 if ('type' in data) {
63 /**
64 * The type of the webhook
65 * @type {WebhookType}
66 */
67 this.type = data.type;
68 }
69
70 if ('guild_id' in data) {
71 /**
72 * The guild the webhook belongs to
73 * @type {Snowflake}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…