Client
ClassOn this page
Client is the process entry point for a DiscordLua bot. It owns the Gateway session, REST client, structure caches, and event dispatch. Construct one, register listeners with :on, then call :login.
Constructor
Client.new(options) The class table is callable, so Client(options) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
local discord = require("discord")
local object = discord.Client({})Properties
- Name
api- Type
any- Access
- readonly
- Description
- Instance field
Client.api. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
application- Type
- ClientApplication
- Access
- readonly
- Description
- Application object for the logged-in bot, available after ready.
- Availability
- Nil until the Gateway
readypayload is processed. - Related
- ClientApplication
- Name
channels- Type
- ChannelManager
- Access
- readonly
- Description
- Cache and REST facade for channel objects owned by this Client. Use it to fetch, create, resolve, and mutate those resources.
- Availability
- Created in
Client.newand remains valid for the lifetime of the Client. - Related
- ChannelManager
- Name
emojis- Type
- BaseGuildEmojiManager
- Access
- readonly
- Description
- Cache and REST facade for baseguildemoji objects owned by this Client. Use it to fetch, create, resolve, and mutate those resources.
- Availability
- Created in
Client.newand remains valid for the lifetime of the Client. - Related
- BaseGuildEmojiManager
- Name
guilds- Type
- GuildManager
- Access
- readonly
- Description
- Cache and REST facade for guild objects owned by this Client. Use it to fetch, create, resolve, and mutate those resources.
- Availability
- Created in
Client.newand remains valid for the lifetime of the Client. - Related
- GuildManager
- Name
intents- Type
any- Access
- readonly
- Description
- Gateway intents this Client identified with.
- Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
lastPingTimestamps- Type
- Collection
- Access
- readonly
- Description
- Instance field
Client.lastPingTimestamps. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Related
- Collection
- Name
options- Type
any- Access
- readonly
- Description
- Instance field
Client.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 Client.
- Name
partials- Type
any- Access
- readonly
- Description
- Instance field
Client.partials. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
pings- Type
- Collection
- Access
- readonly
- Description
- Instance field
Client.pings. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Related
- Collection
- Name
presence- Type
any- Access
- mutable
- Description
- Instance field
Client.presence. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
readyAt- Type
any- Access
- readonly
- Description
- Timestamp of the last successful Gateway ready payload.
- Availability
- Nil until the Gateway
readypayload is processed.
- Name
readyTimestamp- Type
any- Access
- readonly
- Description
- Instance field
Client.readyTimestamp. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- 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 Client.
- Name
shard- Type
any- Access
- readonly
- Description
- Instance field
Client.shard. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
shardCount- Type
any- Access
- readonly
- Description
- Instance field
Client.shardCount. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
shardId- Type
any- Access
- readonly
- Description
- Instance field
Client.shardId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
- Name
token- Type
any- Access
- readonly
- Description
- Authentication token held by this Client. Do not log this value.
- Availability
- Set by
login. Do not log this value.
- Name
user- Type
- ClientUser
- Access
- readonly
- Description
- User object associated with this Client.
- Availability
- Nil until the Gateway
readypayload is processed. - Related
- ClientUser
- Name
users- Type
- UserManager
- Access
- readonly
- Description
- Cache and REST facade for user objects owned by this Client. Use it to fetch, create, resolve, and mutate those resources.
- Availability
- Created in
Client.newand remains valid for the lifetime of the Client. - Related
- UserManager
- Name
voice- Type
VoiceManager- Access
- readonly
- Description
- Cache and REST facade for voice objects owned by this Client. Use it to fetch, create, resolve, and mutate those resources.
- Availability
- Created in
Client.newand remains valid for the lifetime of the Client.
- Name
ws- Type
any- Access
- readonly
- Description
- Instance field
Client.ws. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Client.
Methods
Client:allowsPartial()
#Performs allows partial on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:allowsPartial(kind) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
kind |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:allowsPartial(kind)Client:clearTimer()
#Cancel a timer previously returned by setTimeout or setInterval.
Signature
Client:clearTimer(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:clearTimer("123")Client:deleteWebhook()
#Permanently delete Webhook through REST.
Signature
Client:deleteWebhook(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:deleteWebhook("123")Client:destroy()
#Close the Gateway, voice, and REST resources owned by this client.
Signature
Client:destroy() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:destroy()Client:emit()
#Performs emit on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:emit(event, ...) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
any |
required | Passed through to the implementation as written. |
... |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:emit(event, ...)Client:eventNames()
#Performs event names on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:eventNames() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:eventNames()Client:fetch()
#Request a fresh copy of this resource from REST and update the cache.
Signature
Client:fetch(method, path, body, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
method |
any |
required | Passed through to the implementation as written. |
path |
any |
required | Passed through to the implementation as written. |
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
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetch(method, path, body, function(err, result)
if err then error(err) end
end)Client:fetchChannel()
#Fetch Channel from REST and update the local cache when the request succeeds.
Signature
Client:fetchChannel(id, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchChannel("123", function(err, result)
if err then error(err) end
end)Client:fetchDefaultSoundboardSounds()
#Fetch DefaultSoundboardSounds from REST and update the local cache when the request succeeds.
Signature
Client:fetchDefaultSoundboardSounds(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:fetchDefaultSoundboardSounds(function(err, result)
if err then error(err) end
end)Client:fetchGuild()
#Fetch Guild from REST and update the local cache when the request succeeds.
Signature
Client:fetchGuild(id, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchGuild("123", function(err, result)
if err then error(err) end
end)Client:fetchGuildPreview()
#Fetch GuildPreview from REST and update the local cache when the request succeeds.
Signature
Client:fetchGuildPreview(guildId, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
guildId |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchGuildPreview("123", function(err, result)
if err then error(err) end
end)Client:fetchGuildTemplate()
#Fetch GuildTemplate from REST and update the local cache when the request succeeds.
Signature
Client:fetchGuildTemplate(code, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
code |
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
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchGuildTemplate(code, function(err, result)
if err then error(err) end
end)Client:fetchGuildWidget()
#Fetch GuildWidget from REST and update the local cache when the request succeeds.
Signature
Client:fetchGuildWidget(guildId, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
guildId |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchGuildWidget("123", function(err, result)
if err then error(err) end
end)Client:fetchInvite()
#Fetch Invite from REST and update the local cache when the request succeeds.
Signature
Client:fetchInvite(code, options, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
code |
any |
required | Passed through to the implementation as written. |
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
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchInvite(code, {}, function(err, result)
if err then error(err) end
end)Client:fetchPremiumStickerPacks()
#Fetch PremiumStickerPacks from REST and update the local cache when the request succeeds.
Signature
Client:fetchPremiumStickerPacks(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:fetchPremiumStickerPacks(function(err, result)
if err then error(err) end
end)Client:fetchSKUs()
#Fetch SKUs from REST and update the local cache when the request succeeds.
Signature
Client:fetchSKUs(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:fetchSKUs(function(err, result)
if err then error(err) end
end)Client:fetchSticker()
#Fetch Sticker from REST and update the local cache when the request succeeds.
Signature
Client:fetchSticker(id, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchSticker("123", function(err, result)
if err then error(err) end
end)Client:fetchStickerPacks()
#Fetch StickerPacks from REST and update the local cache when the request succeeds.
Signature
Client:fetchStickerPacks(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchStickerPacks(function(err, result)
if err then error(err) end
end)Client:fetchUser()
#Fetch User from REST and update the local cache when the request succeeds.
Signature
Client:fetchUser(id, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchUser("123", function(err, result)
if err then error(err) end
end)Client:fetchVoiceRegions()
#Fetch VoiceRegions from REST and update the local cache when the request succeeds.
Signature
Client:fetchVoiceRegions(callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchVoiceRegions(function(err, result)
if err then error(err) end
end)Client:fetchWebhook()
#Fetch Webhook from REST and update the local cache when the request succeeds.
Signature
Client:fetchWebhook(id, token, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
token |
string |
optional | Bot token. When omitted, Client:login reads DISCORD_TOKEN. |
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:fetchWebhook("123", os.getenv("DISCORD_TOKEN"), function(err, result)
if err then error(err) end
end)Client:generateInvite()
#Performs generate invite on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:generateInvite(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:generateInvite({})Client:getMaxListeners()
#Read the MaxListeners value from this Client.
Signature
Client:getMaxListeners() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:getMaxListeners()Client:invalidate()
#Predicate that returns whether this Client matches invalidate. Use it to branch before calling type-specific methods.
Signature
Client:invalidate() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:invalidate()Client:isReady()
#Predicate that returns whether this Client matches isReady. Use it to branch before calling type-specific methods.
Signature
Client:isReady() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:isReady()Client:listenerCount()
#Performs listener count on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:listenerCount(event) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:listenerCount(event)Client:login()
#Stores the bot token, identifies the Gateway session through the native handle, and starts cache sweepers. If token is omitted, reads DISCORD_TOKEN. Invalid tokens raise AuthenticationError.
Signature
Client:login(token) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
token |
string |
optional | Bot token. When omitted, Client:login reads DISCORD_TOKEN. |
Returns
Client — the same instance, for chaining.
Throws
Example
local discord = require("discord")
-- object is a Client
object:login(os.getenv("DISCORD_TOKEN"))Client:logout()
#Performs logout on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:logout() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:logout()Client:off()
#Performs off on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:off(event, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
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
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:off(event, function(err, result)
if err then error(err) end
end)Client:on()
#Performs on on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:on(event, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
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
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:on(event, function(err, result)
if err then error(err) end
end)Client:once()
#Performs once on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:once(event, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
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
Client — the same instance, for chaining.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a Client
object:once(event, function(err, result)
if err then error(err) end
end)Client:ping()
#Performs ping on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:ping() Parameters
No parameters.
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:ping()Client:registerCommands()
#Performs register commands on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:registerCommands(commands, guildId) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
commands |
any |
required | Passed through to the implementation as written. |
guildId |
string |
required | Snowflake id string. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:registerCommands(commands, "123")Client:removeAllListeners()
#Remove AllListeners from this Client.
Signature
Client:removeAllListeners(event) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
event |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:removeAllListeners(event)Client:request()
#Performs request on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:request(method, path, body, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
method |
any |
required | Passed through to the implementation as written. |
path |
any |
required | Passed through to the implementation as written. |
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
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:request(method, path, body, function(err, result)
if err then error(err) end
end)Performs resolve shard on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client.resolveShard(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
Client — the same instance, for chaining.
Throws
Example
local discord = require("discord")
-- object is a Client
Client.resolveShard({})Client:setInterval()
#Schedule a repeating timer. Returns a timer id.
Signature
Client:setInterval(callback, ms) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
ms |
number |
required | Duration in milliseconds. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:setInterval(function(err, result)
if err then error(err) end
end, ms)Client:setMaxListeners()
#Set the MaxListeners field. Builders return this Client so setters can be chained.
Signature
Client:setMaxListeners(count) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
count |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:setMaxListeners(count)Client:setPresence()
#Set the Presence field. Builders return this Client so setters can be chained.
Signature
Client:setPresence(presence) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
presence |
any |
required | Passed through to the implementation as written. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:setPresence(presence)Client:setTimeout()
#Schedule a one-shot timer. Returns a timer id.
Signature
Client:setTimeout(callback, ms) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
ms |
number |
required | Duration in milliseconds. |
Returns
Client — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Client
object:setTimeout(function(err, result)
if err then error(err) end
end, ms)Client:toJSON()
#Serialize this Client into a Lua table suitable for REST or debugging.
Signature
Client:toJSON() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a Client
object:toJSON()Client:uptime()
#Performs uptime on this Client. Call it from bot code when you need that operation on the current object.
Signature
Client:uptime() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a Client
object:uptime()Events
applicationCommandPermissionsUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("applicationCommandPermissionsUpdate", handler).
object:on("applicationCommandPermissionsUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)autoModerationActionExecution
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("autoModerationActionExecution", handler).
object:on("autoModerationActionExecution", function(...)
-- handler arguments match the DiscordLua emit for this event
end)autoModerationRuleCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("autoModerationRuleCreate", handler).
object:on("autoModerationRuleCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)autoModerationRuleDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("autoModerationRuleDelete", handler).
object:on("autoModerationRuleDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)autoModerationRuleUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("autoModerationRuleUpdate", handler).
object:on("autoModerationRuleUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)channelCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("channelCreate", handler).
object:on("channelCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)channelDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("channelDelete", handler).
object:on("channelDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)channelPinsUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("channelPinsUpdate", handler).
object:on("channelPinsUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)channelUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("channelUpdate", handler).
object:on("channelUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)clientReady
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("clientReady", handler).
object:on("clientReady", function(...)
-- handler arguments match the DiscordLua emit for this event
end)emojiDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("emojiDelete", handler).
object:on("emojiDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)entitlementDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("entitlementDelete", handler).
object:on("entitlementDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildAuditLogEntryCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildAuditLogEntryCreate", handler).
object:on("guildAuditLogEntryCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildAvailable
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildAvailable", handler).
object:on("guildAvailable", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildCreate", handler).
object:on("guildCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildDelete", handler).
object:on("guildDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildIntegrationsUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildIntegrationsUpdate", handler).
object:on("guildIntegrationsUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildMemberAdd
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildMemberAdd", handler).
object:on("guildMemberAdd", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildMemberAvailable
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildMemberAvailable", handler).
object:on("guildMemberAvailable", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildMemberUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildMemberUpdate", handler).
object:on("guildMemberUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildMembersChunk
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildMembersChunk", handler).
object:on("guildMembersChunk", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildScheduledEventDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildScheduledEventDelete", handler).
object:on("guildScheduledEventDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildSoundboardSoundDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildSoundboardSoundDelete", handler).
object:on("guildSoundboardSoundDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)guildUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildUpdate", handler).
object:on("guildUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)integrationDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("integrationDelete", handler).
object:on("integrationDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)interactionCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("interactionCreate", handler).
object:on("interactionCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)invalidated
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("invalidated", handler).
object:on("invalidated", function(...)
-- handler arguments match the DiscordLua emit for this event
end)inviteCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("inviteCreate", handler).
object:on("inviteCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)inviteDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("inviteDelete", handler).
object:on("inviteDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageCreate", handler).
object:on("messageCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageDeleteBulk
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageDeleteBulk", handler).
object:on("messageDeleteBulk", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageReactionAdd
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageReactionAdd", handler).
object:on("messageReactionAdd", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageReactionRemove
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageReactionRemove", handler).
object:on("messageReactionRemove", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageReactionRemoveAll
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageReactionRemoveAll", handler).
object:on("messageReactionRemoveAll", function(...)
-- handler arguments match the DiscordLua emit for this event
end)messageReactionRemoveEmoji
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("messageReactionRemoveEmoji", handler).
object:on("messageReactionRemoveEmoji", function(...)
-- handler arguments match the DiscordLua emit for this event
end)presenceUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("presenceUpdate", handler).
object:on("presenceUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)ready
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("ready", handler).
object:on("ready", function(...)
-- handler arguments match the DiscordLua emit for this event
end)resumed
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("resumed", handler).
object:on("resumed", function(...)
-- handler arguments match the DiscordLua emit for this event
end)roleCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("roleCreate", handler).
object:on("roleCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)roleDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("roleDelete", handler).
object:on("roleDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)roleUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("roleUpdate", handler).
object:on("roleUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)stickerDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("stickerDelete", handler).
object:on("stickerDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)subscriptionDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("subscriptionDelete", handler).
object:on("subscriptionDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadCreate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadCreate", handler).
object:on("threadCreate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadDelete
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadDelete", handler).
object:on("threadDelete", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadListSync
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadListSync", handler).
object:on("threadListSync", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadMemberUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadMemberUpdate", handler).
object:on("threadMemberUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadMembersUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadMembersUpdate", handler).
object:on("threadMembersUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)threadUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("threadUpdate", handler).
object:on("threadUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)typingStart
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("typingStart", handler).
object:on("typingStart", function(...)
-- handler arguments match the DiscordLua emit for this event
end)userUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("userUpdate", handler).
object:on("userUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)voiceChannelEffectSend
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("voiceChannelEffectSend", handler).
object:on("voiceChannelEffectSend", function(...)
-- handler arguments match the DiscordLua emit for this event
end)voiceServerUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("voiceServerUpdate", handler).
object:on("voiceServerUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)voiceStateUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("voiceStateUpdate", handler).
object:on("voiceStateUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)webhooksUpdate
#Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("webhooksUpdate", handler).
object:on("webhooksUpdate", function(...)
-- handler arguments match the DiscordLua emit for this event
end)Examples
local discord = require("discord")
local client = discord.Client({
intents = { "Guilds", "GuildMessages", "MessageContent" }
})
client:on("ready", function()
print("Bot is ready")
end)
client:login(os.getenv("DISCORD_TOKEN"))Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0