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.
Properties
Property
Type
Description
channelIdChannel ID this webhook posts to, or
null.createdAtWhen this webhook was created, decoded from the webhook snowflake.
guildIdGuild ID this webhook belongs to, or
null.idWebhook ID.
nameWebhook name, or
null.tokenWebhook token (only available for incoming webhooks), or
null. Treat it as a credential: do not log it or store it in KV.typeType 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.fetchMessage(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.