Carbon
Core/Classes

Webhook

Type Parameters

Type ParameterDefault type
IsPartial extends booleanfalse

Constructors

Constructor

new Webhook<IsPartial>(client, rawData): Webhook<IsPartial>

Parameters

ParameterType
clientClient
rawDataAPIWebhook

Returns

Webhook<IsPartial>

Overrides

Base.constructor

Constructor

new Webhook<IsPartial>(client, idAndToken): Webhook<IsPartial>

Parameters

ParameterType
clientClient
idAndToken{ id: string; threadId?: string; token: string; }
idAndToken.idstring
idAndToken.threadId?string
idAndToken.tokenstring

Returns

Webhook<IsPartial>

Overrides

Base.constructor

Constructor

new Webhook<IsPartial>(client, url): Webhook<IsPartial>

Parameters

ParameterType
clientClient
urlstring

Returns

Webhook<IsPartial>

Overrides

Base.constructor

Constructor

new Webhook<IsPartial>(client, input): Webhook<IsPartial>

Parameters

ParameterType
clientClient
inputWebhookInput

Returns

Webhook<IsPartial>

Overrides

Base.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited from
clientpublicClientundefined-Base.client
idreadonlystringundefinedThe ID of the webhook-
rawDataprotectednull | APIWebhooknull--
threadId?readonlystringundefinedThe thread ID this webhook is for-
token?readonlystringundefinedThe token of the webhook-

Accessors

applicationId

Get Signature

get applicationId(): IfPartial<IsPartial, null | string>

The bot/OAuth2 application that created this webhook

Returns

IfPartial<IsPartial, null | string>


avatar

Get Signature

get avatar(): IfPartial<IsPartial, null | string>

The default avatar of the webhook

Returns

IfPartial<IsPartial, null | string>


avatarUrl

Get Signature

get avatarUrl(): IfPartial<IsPartial, null | string>

Get the URL of the webhook's avatar

Returns

IfPartial<IsPartial, null | string>


channelId

Get Signature

get channelId(): IfPartial<IsPartial, string>

The channel id this webhook is for

Returns

IfPartial<IsPartial, string>


guildId

Get Signature

get guildId(): IfPartial<IsPartial, undefined | string>

The guild id this webhook is for

Returns

IfPartial<IsPartial, undefined | string>


name

Get Signature

get name(): IfPartial<IsPartial, null | string>

The default name of the webhook

Returns

IfPartial<IsPartial, null | string>


partial

Get Signature

get partial(): IsPartial

Whether the webhook is a partial webhook (meaning it does not have all the data). If this is true, you should use Webhook.fetch to get the full data of the webhook.

Returns

IsPartial


sourceChannel

Get Signature

get sourceChannel(): IfPartial<IsPartial, undefined | Required<_NonNullableFields<Pick<APIPartialChannel, "id" | "name">>>>

The channel that this webhook is following Only returned for Channel Follower Webhooks

Returns

IfPartial<IsPartial, undefined | Required<_NonNullableFields<Pick<APIPartialChannel, "id" | "name">>>>


sourceGuild

Get Signature

get sourceGuild(): IfPartial<IsPartial, undefined | APIWebhookSourceGuild>

The guild of the channel that this webhook is following Only returned for Channel Follower Webhooks

Returns

IfPartial<IsPartial, undefined | APIWebhookSourceGuild>


type

Get Signature

get type(): IfPartial<IsPartial, WebhookType>

The type of the webhook

See

https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types

Returns

IfPartial<IsPartial, WebhookType>


url

Get Signature

get url(): IfPartial<IsPartial, undefined | string>

The url used for executing the webhook Only returned by the webhooks OAuth2 flow

Returns

IfPartial<IsPartial, undefined | string>


user

Get Signature

get user(): IfPartial<IsPartial, undefined | User<false>>

The user this webhook was created by Not returned when getting a webhook with its token

Returns

IfPartial<IsPartial, undefined | User<false>>

Methods

delete()

delete(): Promise<void>

Delete this webhook

Returns

Promise<void>

A Promise that resolves when the webhook is deleted


deleteMessage()

deleteMessage(messageId, threadId?): Promise<void>

Delete a message sent by this webhook

Parameters

ParameterTypeDescription
messageIdstringThe ID of the message to delete
threadId?stringOptional ID of the thread to delete the message from. If not provided, uses the webhook's thread ID.

Returns

Promise<void>

A Promise that resolves when the message is deleted


edit()

edit(messageId, data, threadId?): Promise<Message<false>>

Edit a message sent by this webhook

Parameters

ParameterTypeDescription
messageIdstringThe ID of the message to edit
dataMessagePayloadThe data to edit the message with
threadId?stringOptional ID of the thread to edit the message in. If not provided, uses the webhook's thread ID.

Returns

Promise<Message<false>>

A Promise that resolves to the edited message


fetch()

fetch(): Promise<Webhook<false>>

Fetch this webhook's data

Returns

Promise<Webhook<false>>

A Promise that resolves to a non-partial Webhook


getMessage()

getMessage(messageId, threadId?): Promise<Message<false>>

Get a message sent by this webhook

Parameters

ParameterTypeDescription
messageIdstringThe ID of the message to get
threadId?stringOptional ID of the thread to get the message from. If not provided, uses the webhook's thread ID.

Returns

Promise<Message<false>>

A Promise that resolves to the message


modify()

modify(data): Promise<Webhook<false>>

Modify this webhook

Parameters

ParameterTypeDescription
dataRESTPatchAPIWebhookJSONBodyThe data to modify the webhook with

Returns

Promise<Webhook<false>>

A Promise that resolves to the modified webhook


send()

send(data, threadId?): Promise<Message<false>>

Send a message through this webhook

Parameters

ParameterTypeDescription
dataMessagePayloadThe data to send with the webhook
threadId?stringOptional ID of the thread to send the message to. If not provided, uses the webhook's thread ID.

Returns

Promise<Message<false>>

A Promise that resolves to the created message

On this page