Class

Webhook

Incoming webhook. Token is only present after create / `fromToken`; fetched webhooks use bot auth and cannot execute.

Extends Base

Constructor

new Webhook(client: Client, data: APIWebhook & { token?: string | null })
ParamTypeDescription
clientClient
dataAPIWebhook & { token?: string | null }

Properties

avatar: string | null

Webhook avatar hash (null = default).

channelId: string

Channel this webhook posts to.

client: Client (readonly)

Parent client instance.

guildId: string (readonly)

Guild this webhook belongs to.

id: string (readonly)

Webhook snowflake ID.

name: string

Webhook name.

token: string | null (readonly)

Present after create / `fromToken`; omitted when fetching by ID.

user: User (readonly)

The user that created this webhook.

Methods

avatarURL(options?: { size?: number; extension?: string; }): string | null
ParamTypeDescription
options?{ size?: number; extension?: string; }
delete(): Promise<void>

Delete this webhook (token auth when available, otherwise bot auth).

deleteMessage(messageId: string): Promise<void>

Delete a message sent by this webhook. Requires token.

ParamTypeDescription
messageIdstring
edit(options: WebhookEditOptions): Promise<this>

Edit name/avatar. With bot auth (no token), `channelId` may also be set.

ParamTypeDescription
optionsWebhookEditOptions
editMessage(messageId: string, options: WebhookMessageEditOptions): Promise<Message>

Edit a message previously sent by this webhook. Requires token.

ParamTypeDescription
messageIdstring
optionsWebhookMessageEditOptions
fetch(client: Client, webhookId: string): Promise<Webhook>

Fetch a webhook by ID (bot auth; no token).

ParamTypeDescription
clientClient
webhookIdstring
fetchMessage(messageId: string): Promise<Message>

Fetch a message sent by this webhook. Requires token.

ParamTypeDescription
messageIdstring
fromToken(client: Client, webhookId: string, token: string, options?: { channelId?: string; guildId?: string; name?: string; }): Webhook

Build a webhook from a stored id + token (e.g. webhook URL).

ParamTypeDescription
clientClient
webhookIdstring
tokenstring
options?{ channelId?: string; guildId?: string; name?: string; }
messageRoute(messageId: string): string
ParamTypeDescription
messageIdstring
requireToken(): string
send(options: string | WebhookSendOptions, wait: boolean): Promise<Message | undefined>

Execute the webhook. Requires token.

ParamTypeDescription
optionsstring | WebhookSendOptions
waitboolean

When true, appends `?wait=true` and returns the created `Message`.