WebhookClient
ClassOn this page
WebhookClient is a DiscordLua class representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Constructor
WebhookClient.new(idOrOptions, token) The class table is callable, so WebhookClient(idOrOptions, token) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
idOrOptions |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
token |
string |
optional | Bot token. When omitted, Client:login reads DISCORD_TOKEN. |
local discord = require("discord")
local object = discord.WebhookClient({}, os.getenv("DISCORD_TOKEN"))Properties
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this WebhookClient.
- Availability
- Populated from the Gateway/REST payload or constructor for this WebhookClient.
- Name
options- Type
any- Access
- readonly
- Description
- Instance field
WebhookClient.options. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebhookClient.
- Name
rest- Type
any- Access
- readonly
- Description
- REST manager used to send authenticated HTTP requests.
- Availability
- Populated from the Gateway/REST payload or constructor for this WebhookClient.
- Name
token- Type
any- Access
- readonly
- Description
- Authentication token held by this WebhookClient. Do not log this value.
- Availability
- Set by
login. Do not log this value.
- Name
url- Type
any- Access
- readonly
- Description
- Instance field
WebhookClient.url. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebhookClient.
Methods
Create dAt through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
WebhookClient:createdAt() Parameters
No parameters.
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:createdAt()Create dTimestamp through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
WebhookClient:createdTimestamp() Parameters
No parameters.
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:createdTimestamp()Permanently delete this resource through REST.
Signature
WebhookClient:delete(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:delete(function(err, result)
if err then error(err) end
end)Permanently delete Message through REST.
Signature
WebhookClient:deleteMessage(messageId, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
messageId |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:deleteMessage("123", function(err, result)
if err then error(err) end
end)Apply a REST update to this resource.
Signature
WebhookClient:edit(options, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:edit({}, function(err, result)
if err then error(err) end
end)Apply a REST update to Message and refresh the local object when the request succeeds.
Signature
WebhookClient:editMessage(messageId, contentOrOptions, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
messageId |
string |
required | Snowflake id string. |
contentOrOptions |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:editMessage("123", "Hello", function(err, result)
if err then error(err) end
end)Request a fresh copy of this resource from REST and update the cache.
Signature
WebhookClient:fetch(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:fetch(function(err, result)
if err then error(err) end
end)Fetch Message from REST and update the local cache when the request succeeds.
Signature
WebhookClient:fetchMessage(messageId, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
messageId |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:fetchMessage("123", function(err, result)
if err then error(err) end
end)Send a message, payload, or packet using this object.
Signature
WebhookClient:send(contentOrOptions, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
contentOrOptions |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:send("Hello", function(err, result)
if err then error(err) end
end)Send SlackMessage using this WebhookClient.
Signature
WebhookClient:sendSlackMessage(body, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
body |
any |
required | Passed through to the implementation as written. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
WebhookClient — the same instance, for chaining.
Side effects
Sends an HTTP request through the native REST client. Rate-limit headers are honored by the runtime.
Example
local discord = require("discord")
-- object is a WebhookClient
object:sendSlackMessage(body, function(err, result)
if err then error(err) end
end)Static members
-
WebhookClient.InteractionWebhook -
WebhookClient.Webhook -
WebhookClient.wrapMany
Examples
local discord = require("discord")
local object = discord.WebhookClient({})Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0