Webhook
Type Parameters
Type Parameter | Default type |
---|---|
IsPartial extends boolean | false |
Constructors
Constructor
new Webhook<
IsPartial
>(client
,rawData
):Webhook
<IsPartial
>
Parameters
Parameter | Type |
---|---|
client | Client |
rawData | APIWebhook |
Returns
Webhook
<IsPartial
>
Overrides
Base.constructor
Constructor
new Webhook<
IsPartial
>(client
,idAndToken
):Webhook
<IsPartial
>
Parameters
Parameter | Type |
---|---|
client | Client |
idAndToken | { id : string ; threadId? : string ; token : string ; } |
idAndToken.id | string |
idAndToken.threadId? | string |
idAndToken.token | string |
Returns
Webhook
<IsPartial
>
Overrides
Base.constructor
Constructor
new Webhook<
IsPartial
>(client
,url
):Webhook
<IsPartial
>
Parameters
Parameter | Type |
---|---|
client | Client |
url | string |
Returns
Webhook
<IsPartial
>
Overrides
Base.constructor
Constructor
new Webhook<
IsPartial
>(client
,input
):Webhook
<IsPartial
>
Parameters
Parameter | Type |
---|---|
client | Client |
input | WebhookInput |
Returns
Webhook
<IsPartial
>
Overrides
Base.constructor
Properties
Property | Modifier | Type | Default value | Description | Inherited from |
---|---|---|---|---|---|
client | public | Client | undefined | - | Base.client |
id | readonly | string | undefined | The ID of the webhook | - |
rawData | protected | null | APIWebhook | null | - | - |
threadId? | readonly | string | undefined | The thread ID this webhook is for | - |
token? | readonly | string | undefined | The 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
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
Parameter | Type | Description |
---|---|---|
messageId | string | The ID of the message to delete |
threadId? | string | Optional 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 a message sent by this webhook
Parameters
Parameter | Type | Description |
---|---|---|
messageId | string | The ID of the message to edit |
data | MessagePayload | The data to edit the message with |
threadId? | string | Optional ID of the thread to edit the message in. If not provided, uses the webhook's thread ID. |
Returns
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()
Get a message sent by this webhook
Parameters
Parameter | Type | Description |
---|---|---|
messageId | string | The ID of the message to get |
threadId? | string | Optional ID of the thread to get the message from. If not provided, uses the webhook's thread ID. |
Returns
A Promise that resolves to the message
modify()
modify(
data
):Promise
<Webhook
<false
>>
Modify this webhook
Parameters
Parameter | Type | Description |
---|---|---|
data | RESTPatchAPIWebhookJSONBody | The data to modify the webhook with |
Returns
Promise
<Webhook
<false
>>
A Promise that resolves to the modified webhook
send()
Send a message through this webhook
Parameters
Parameter | Type | Description |
---|---|---|
data | MessagePayload | The data to send with the webhook |
threadId? | string | Optional ID of the thread to send the message to. If not provided, uses the webhook's thread ID. |
Returns
A Promise that resolves to the created message