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.
Parameters
Section titled “Parameters”DiscordClientOptions = {}
Returns
Section titled “Returns”object
webhooks
Section titled “webhooks”webhooks:
object
webhooks.deleteMessage
Section titled “webhooks.deleteMessage”deleteMessage: (
id,token,messageId) =>Promise<void>
Removes a message this webhook posted, e.g. a smoke-test line. A 404 counts as done.
Parameters
Section titled “Parameters”string
string
messageId
Section titled “messageId”string
Returns
Section titled “Returns”Promise<void>
webhooks.editMessage
Section titled “webhooks.editMessage”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.
Parameters
Section titled “Parameters”string
string
messageId
Section titled “messageId”string
number
Returns
Section titled “Returns”Promise<void>
webhooks.execute
Section titled “webhooks.execute”execute: (
id,token,content) =>Promise<void>
Posts plain text. A link in it draws no preview card (SuppressEmbeds); the links stay.
Parameters
Section titled “Parameters”string
string
content
Section titled “content”string
Returns
Section titled “Returns”Promise<void>
webhooks.executeAndWait
Section titled “webhooks.executeAndWait”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.
Parameters
Section titled “Parameters”string
string
content
Section titled “content”string
options?
Section titled “options?”suppressEmbeds?
Section titled “suppressEmbeds?”boolean
false leaves the suppress-embeds flag off the message. Default true.
Returns
Section titled “Returns”Promise<{ channel_id: string; id: string; }>
webhooks.get
Section titled “webhooks.get”get: (
id,token) =>Promise<DiscordWebhookInfo>
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”Promise<DiscordWebhookInfo>