Skip to content

createDiscordClient

createDiscordClient(opts?): object

Defined in: index.ts:11

Builds the webhook client: a webhooks group that reads, posts to and deletes messages from a webhook by its id and token.

DiscordClientOptions = {}

object

webhooks: object

deleteMessage: (id, token, messageId) => Promise<void>

Removes a message this webhook posted, e.g. a smoke-test line. A 404 counts as done.

string

string

string

Promise<void>

editMessage: (id, token, messageId, body) => Promise<void>

Edits a message this webhook wrote. A 429 is waited out (Discord’s retry-after, at most EDIT_RETRY_WAIT_MS each time, EDIT_RETRIES times) and sent again: Discord rejected that request without acting on it, so repeating it cannot edit twice.

string

string

string

number

Promise<void>

execute: (id, token, content) => Promise<void>

Posts plain text. A link in it draws no preview card (SuppressEmbeds); the links stay.

string

string

string

Promise<void>

executeAndWait: (id, token, content, options?) => Promise<{ channel_id: string; id: string; }>

Posts and waits (?wait=true) for Discord to answer with the message, so a check can read it back or delete it, or a bot can start a thread on it. channel_id is the channel the webhook posts to. Like execute, it draws no preview card under a link, unless options.suppressEmbeds is false: the message then carries no flag, and a link that should show no card is written <https://...> by the caller.

string

string

string

boolean

false leaves the suppress-embeds flag off the message. Default true.

Promise<{ channel_id: string; id: string; }>

get: (id, token) => Promise<DiscordWebhookInfo>

string

string

Promise<DiscordWebhookInfo>