WebhookClient

export class WebhookClient extends WebhookMixin(BaseClient)
export class WebhookClient extends WebhookMixin(BaseClient)
The webhook client.

Extends

WebhookMixin(BaseClient)
constructor(data, options?)
NameTypeOptionalDescription
dataWebhookClientDataNoNone
optionsWebhookClientOptionsYesNone
Readonly
client:this
Readonly
createdAt:Date
The time the webhook was created at
Readonly
createdTimestamp:number
The timestamp the webhook was created at
The webhook's id
The options the webhook client was instantiated with.
token:string
Readonly
url:string
The URL of this webhook
delete(reason?):Promise<void>
Deletes the webhook.
NameTypeOptionalDescription
reasonstringYesReason for deleting this webhook
deleteMessage(message, threadId?):Promise<void>
Delete a message that was sent by this webhook.
NameTypeOptionalDescription
messageMessageResolvable | '@original'NoThe message to delete
threadIdSnowflakeYesThe id of the thread this message belongs to
edit(options):Promise<Webhook>
Edits this webhook.
NameTypeOptionalDescription
optionsWebhookEditOptionsNoOptions for editing the webhook
editMessage(message, options):Promise<APIMessage>
Edits a message that was sent by this webhook.
Returns
Returns the message edited by this webhook
NameTypeOptionalDescription
messageMessageResolvableNoThe message to edit
optionsstring | MessagePayload | WebhookMessageEditOptionsNoThe options to provide
fetchMessage(message, options?):Promise<APIMessage>
Gets a message that was sent by this webhook.
Returns
Returns the message sent by this webhook
NameTypeOptionalDescription
messageSnowflakeNoThe id of the message to fetch
optionsWebhookFetchMessageOptionsYesThe options to provide to fetch the message.
send(options):Promise<APIMessage>
Sends a message with this webhook.
NameTypeOptionalDescription
optionsstring | MessagePayload | WebhookMessageCreateOptionsNoThe content for the reply
sendSlackMessage(body):Promise<boolean>
Sends a raw slack message with this webhook.
Example
// 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);
// 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);
NameTypeOptionalDescription
bodyobjectNoThe raw body to send