Webhook
classe · Source
Represents a webhook.
Properties
client
The client that instantiated the webhook Source
name
The name of the webhook Source
token
The token for the webhook, unavailable for follower webhooks and webhooks owned by another application. Source
avatar
The avatar for the webhook Source
id
The webhook's id Source
type
The type of the webhook Source
guildId
The guild the webhook belongs to Source
channelId
The id of the channel the webhook belongs to Source
owner
The owner of the webhook Source
sourceGuild
The source guild of the webhook Source
sourceChannel
The source channel of the webhook Source
channel
The channel the webhook belongs to Source
createdTimestamp
The timestamp the webhook was created at Source
createdAt
The time the webhook was created at Source
url
The URL of this webhook Source
Methods
send
Sends a message with this webhook. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | WebhookMessageOptions | The options to provide |
Returns: Promise<(Message\|APIMessage)>
// Send a basic message
webhook.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);// Send a basic message in a thread
webhook.send({ content: 'hello!', threadId: '836856309672348295' })
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);// Send a remote file
webhook.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);// Send a local file
webhook.send({
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);// Send an embed with a local image inside
webhook.send({
content: 'This is an embed',
embeds: [{
thumbnail: {
url: 'attachment://file.jpg'
}
}],
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);sendSlackMessage
Sends a raw slack message with this webhook. Parameters
| Name | Type | Description |
|---|---|---|
body | Object | The raw body to send |
Returns: Promise<boolean>
// Send a slack message
webhook.sendSlackMessage({
'username': 'Wumpus',
'attachments': [{
'pretext': 'this looks pretty cool',
'color': '#F0F',
'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png',
'footer': 'Powered by sneks',
'ts': Date.now() / 1_000
}]
}).catch(console.error);edit
Edits this webhook. Parameters
| Name | Type | Description |
|---|---|---|
options | WebhookEditData | Options for editing the webhook |
reason? | string | Reason for editing the webhook |
Returns: Promise<Webhook>Source
fetchMessage
Gets a message that was sent by this webhook. Parameters
| Name | Type | Description |
|---|---|---|
message | Snowflake | '@original' | The id of the message to fetch |
cacheOrOptions? | WebhookFetchMessageOptions | boolean | The options to provide to fetch the message. A deprecated boolean may be passed instead to specify whether to cache the message. Default: {}. |
Returns: Promise<(Message\|APIMessage)> — Returns the raw message data if the webhook was instantiated as a WebhookClient or if the channel is uncached, otherwise a Message will be returned Source
editMessage
Edits a message that was sent by this webhook. Parameters
| Name | Type | Description |
|---|---|---|
message | MessageResolvable | '@original' | The message to edit |
options | string | MessagePayload | WebhookEditMessageOptions | The options to provide |
Returns: Promise<(Message\|APIMessage)> — Returns the raw message data if the webhook was instantiated as a WebhookClient or if the channel is uncached, otherwise a Message will be returned Source
delete
Deletes the webhook. Parameters
| Name | Type | Description |
|---|---|---|
reason? | string | Reason for deleting this webhook |
Returns: Promise<void>Source
deleteMessage
Delete a message that was sent by this webhook. Parameters
| Name | Type | Description |
|---|---|---|
message | MessageResolvable | '@original' | The message to delete |
threadId? | Snowflake | The id of the thread this message belongs to |
Returns: Promise<void>Source
avatarURL
A link to the webhook's avatar. Parameters
| Name | Type | Description |
|---|---|---|
options? | StaticImageURLOptions | Options for the Image URL Default: {}. |
Returns: stringSource
isChannelFollower
Whether or not this webhook is a channel follower webhook. Returns: booleanSource
isIncoming
Whether or not this webhook is an incoming webhook. Returns: booleanSource