Webhook

class Webhook()

A Discord webhook that can send and manage messages without a gateway event. Token-backed incoming webhooks can execute without the bot being connected to the target guild; other operations still depend on Discord permissions.

exported from lib.weeble.d

Properties

Webhook.channelId

type: readonly string | null

Channel ID this webhook posts to, or null.

Webhook.createdAt

type: readonly Date

When this webhook was created, decoded from the webhook snowflake.

Webhook.guildId

type: readonly string | null

Guild ID this webhook belongs to, or null.

Webhook.id

type: readonly string

Webhook ID.

Webhook.name

type: readonly string | null

Webhook name, or null.

Webhook.token

type: readonly string | null

Webhook token (only available for incoming webhooks), or null. Treat it as a credential: do not log it or store it in KV.

Webhook.type

type: readonly WebhookType

Type of webhook.

Methods

async Webhook.delete(reason: string) Promise<void>

Delete this webhook.

Parameters:
  • reason — – Reason for deletion, shown in audit log.

async Webhook.deleteMessage(messageId: string) Promise<void>

Delete a message sent by this webhook.

Parameters:
  • messageId — – The ID of the message to delete.

async Webhook.edit(options: WebhookEditOptions) Promise<Webhook>

Edit webhook properties.

Parameters:
  • options — – Webhook properties to update.

Returns:

The updated webhook.

async Webhook.editMessage(messageId: string, body: EditMessageOptions) Promise<Message>

Edit a message sent by this webhook.

Parameters:
  • messageId — – The ID of the message to edit.

  • body — – The new message content and options.

Returns:

The updated message.

async Webhook.fetch() Promise<Webhook>

Refetch the latest webhook data from Discord.

Returns:

The updated webhook object.

async Webhook.getMessage(messageId: string) Promise<Message | null>

Fetch a message sent by this webhook.

Parameters:
  • messageId — – The ID of the message to fetch.

Returns:

The fetched message, or null if not found.

async Webhook.send(content: string | WebhookExecuteOptions) Promise<Message>

Execute the webhook to send a message.

Parameters:
  • content — – The message content or formatted options.

Returns:

The sent message.