WebhookClient

export class WebhookClient extends BaseClient
export class WebhookClient extends BaseClient
The webhook client.

Extends

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.
rest:REST
The REST manager of the client
Inherited from BaseClient
token:string
Readonly
url:string
The URL of this webhook
The options the client was instantiated with
Inherited from BaseClient
rest:REST
The REST manager of the client
Inherited from BaseClient
[Symbol.asyncDispose]():Promise<void>
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
deleteWebhook(id, options?):Promise<void>
Deletes a webhook.
NameTypeOptionalDescription
idSnowflakeNoThe webhook's id
optionsWebhookDeleteOptionsYesOptions for deleting the webhook
Inherited from BaseClient
destroy():void
Destroys all assets used by the base client.
Inherited from BaseClient
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
toJSON(...props):unknown
NameTypeOptionalDescription
...propsRecord<string, boolean | string>[]NoNone
Inherited from BaseClient
[Symbol.asyncDispose]():Promise<void>
deleteWebhook(id, options?):Promise<void>
Deletes a webhook.
NameTypeOptionalDescription
idSnowflakeNoThe webhook's id
optionsWebhookDeleteOptionsYesOptions for deleting the webhook
Inherited from BaseClient
destroy():void
Destroys all assets used by the base client.
Inherited from BaseClient
toJSON(...props):unknown
NameTypeOptionalDescription
...propsRecord<string, boolean | string>[]NoNone
Inherited from BaseClient