DiscordLua
discorddiscord
v1.2.4
Install

WebhookClient

Class
On 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.

class Module 1.2.4 REST Source

Constructor

WebhookClient.new(idOrOptions, token)

The class table is callable, so WebhookClient(idOrOptions, token) is the same as .new.

NameTypeRequiredBehavior
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.
lua
local discord = require("discord")
local object = discord.WebhookClient({}, os.getenv("DISCORD_TOKEN"))

Properties

WebhookClient.id

# readonly
Name
id
Type
any
Access
readonly
Description
Snowflake id of this WebhookClient.
Availability
Populated from the Gateway/REST payload or constructor for this WebhookClient.

WebhookClient.options

# readonly
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.

WebhookClient.rest

# readonly
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.

WebhookClient.token

# readonly
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.

WebhookClient.url

# readonly
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

WebhookClient:createdAt()

# REST

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

lua
local discord = require("discord")
-- object is a WebhookClient
object:createdAt()

WebhookClient:createdTimestamp()

# REST

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

lua
local discord = require("discord")
-- object is a WebhookClient
object:createdTimestamp()

WebhookClient:delete()

# REST

Permanently delete this resource through REST.

Signature

WebhookClient:delete(callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:delete(function(err, result)
    if err then error(err) end
end)

WebhookClient:deleteMessage()

# REST

Permanently delete Message through REST.

Signature

WebhookClient:deleteMessage(messageId, callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:deleteMessage("123", function(err, result)
    if err then error(err) end
end)

WebhookClient:edit()

# REST

Apply a REST update to this resource.

Signature

WebhookClient:edit(options, callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:edit({}, function(err, result)
    if err then error(err) end
end)

WebhookClient:editMessage()

# REST

Apply a REST update to Message and refresh the local object when the request succeeds.

Signature

WebhookClient:editMessage(messageId, contentOrOptions, callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:editMessage("123", "Hello", function(err, result)
    if err then error(err) end
end)

WebhookClient:fetch()

# REST

Request a fresh copy of this resource from REST and update the cache.

Signature

WebhookClient:fetch(callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:fetch(function(err, result)
    if err then error(err) end
end)

WebhookClient:fetchMessage()

# REST

Fetch Message from REST and update the local cache when the request succeeds.

Signature

WebhookClient:fetchMessage(messageId, callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:fetchMessage("123", function(err, result)
    if err then error(err) end
end)

WebhookClient:send()

# REST

Send a message, payload, or packet using this object.

Signature

WebhookClient:send(contentOrOptions, callback)

Parameters

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebhookClient
object:send("Hello", function(err, result)
    if err then error(err) end
end)

WebhookClient:sendSlackMessage()

# REST

Send SlackMessage using this WebhookClient.

Signature

WebhookClient:sendSlackMessage(body, callback)

Parameters

NameTypeRequiredBehavior
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

lua
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

lua
local discord = require("discord")
local object = discord.WebhookClient({})

ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc