DiscordLua
discorddiscord
v1.2.4
Install

Client

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

class Module 1.2.4 REST Source

Constructor

Client.new(options)

The class table is callable, so Client(options) is the same as .new.

NameTypeRequiredBehavior
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
lua
local discord = require("discord")
local object = discord.Client({})

Properties

Client.api

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

Client.application

# readonly
Name
application
Type
ClientApplication
Access
readonly
Description
Application object for the logged-in bot, available after ready.
Availability
Nil until the Gateway ready payload is processed.
Related
ClientApplication

Client.channels

# readonly
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.new and remains valid for the lifetime of the Client.
Related
ChannelManager

Client.emojis

# readonly
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.new and remains valid for the lifetime of the Client.
Related
BaseGuildEmojiManager

Client.guilds

# readonly
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.new and remains valid for the lifetime of the Client.
Related
GuildManager

Client.intents

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

Client.lastPingTimestamps

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

Client.options

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

Client.partials

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

Client.pings

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

Client.presence

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

Client.readyAt

# readonly
Name
readyAt
Type
any
Access
readonly
Description
Timestamp of the last successful Gateway ready payload.
Availability
Nil until the Gateway ready payload is processed.

Client.readyTimestamp

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

Client.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 Client.

Client.shard

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

Client.shardCount

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

Client.shardId

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

Client.sweepers

# readonly
Name
sweepers
Type
Sweepers
Access
readonly
Description
Instance field Client.sweepers. 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
Sweepers

Client.token

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

Client.user

# readonly
Name
user
Type
ClientUser
Access
readonly
Description
User object associated with this Client.
Availability
Nil until the Gateway ready payload is processed.
Related
ClientUser

Client.users

# readonly
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.new and remains valid for the lifetime of the Client.
Related
UserManager

Client.voice

# readonly
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.new and remains valid for the lifetime of the Client.

Client.ws

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

NameTypeRequiredBehavior
kind any required Passed through to the implementation as written.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
id string required Snowflake id string.

Returns

Client — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Client
object:clearTimer("123")

Client:deleteWebhook()

#

Permanently delete Webhook through REST.

Signature

Client:deleteWebhook(id)

Parameters

NameTypeRequiredBehavior
id string required Snowflake id string.

Returns

Client — the same instance, for chaining.

Example

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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

lua
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

NameTypeRequiredBehavior
event any required Passed through to the implementation as written.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
token string optional Bot token. When omitted, Client:login reads DISCORD_TOKEN.

Returns

Client — the same instance, for chaining.

Throws

AuthenticationError

Example

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

NameTypeRequiredBehavior
commands any required Passed through to the implementation as written.
guildId string required Snowflake id string.

Returns

Client — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a Client
object:registerCommands(commands, "123")

Client:removeAllListeners()

#

Remove AllListeners from this Client.

Signature

Client:removeAllListeners(event)

Parameters

NameTypeRequiredBehavior
event any required Passed through to the implementation as written.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a Client
object:request(method, path, body, function(err, result)
    if err then error(err) end
end)

Client.resolveShard()

# static

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

NameTypeRequiredBehavior
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

AuthenticationError

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

NameTypeRequiredBehavior
count any required Passed through to the implementation as written.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
presence any required Passed through to the implementation as written.

Returns

Client — the same instance, for chaining.

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
object:on("guildSoundboardSoundDelete", function(...)
    -- handler arguments match the DiscordLua emit for this event
end)

guildUnavailable

#

Emitted by Client when the corresponding Gateway or local lifecycle update occurs. Listen with :on("guildUnavailable", handler).

lua
object:on("guildUnavailable", 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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
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).

lua
object:on("webhooksUpdate", function(...)
    -- handler arguments match the DiscordLua emit for this event
end)

Examples

lua
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"))

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

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc