WebSocketShard
ClassOn this page
WebSocketShard is a DiscordLua class representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Constructor
WebSocketShard.new(manager, id) The class table is callable, so WebSocketShard(manager, id) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
manager |
any |
required | Passed through to the implementation as written. |
id |
string |
required | Snowflake id string. |
local discord = require("discord")
local object = discord.WebSocketShard({}, {})Properties
- Name
client- Type
any- Access
- readonly
- Description
- Owning Client instance used for REST, cache, and event dispatch.
- Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
closeSequence- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.closeSequence. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this WebSocketShard.
- Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
lastPayload- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.lastPayload. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
lastPingTimestamp- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.lastPingTimestamp. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
manager- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.manager. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
ping- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.ping. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
sessionInfo- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.sessionInfo. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
- Name
status- Type
any- Access
- readonly
- Description
- Instance field
WebSocketShard.status. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketShard.
Methods
WebSocketShard:close()
#Performs close on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard:close(code, reason) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
code |
any |
required | Passed through to the implementation as written. |
reason |
string |
optional | Audit-log reason sent as X-Audit-Log-Reason on REST mutations. |
Returns
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:close(code, reason)WebSocketShard:destroy()
#Close the Gateway, voice, and REST resources owned by this client.
Signature
WebSocketShard:destroy(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:destroy({})WebSocketShard:emit()
#Performs emit on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard: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
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:emit(event, ...)WebSocketShard:emitClose()
#Performs emit close on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard:emitClose(code, reason) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
code |
any |
required | Passed through to the implementation as written. |
reason |
string |
optional | Audit-log reason sent as X-Audit-Log-Reason on REST mutations. |
Returns
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:emitClose(code, reason)WebSocketShard:markReady()
#Performs mark ready on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard:markReady() Parameters
No parameters.
Returns
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:markReady()WebSocketShard:off()
#Performs off on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard: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
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:off(event, function(err, result)
if err then error(err) end
end)WebSocketShard:on()
#Performs on on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard: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
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:on(event, function(err, result)
if err then error(err) end
end)WebSocketShard:once()
#Performs once on this WebSocketShard. Call it from bot code when you need that operation on the current object.
Signature
WebSocketShard: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
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:once(event, function(err, result)
if err then error(err) end
end)WebSocketShard:send()
#Send a message, payload, or packet using this object.
Signature
WebSocketShard:send(payload) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
payload |
any |
required | Passed through to the implementation as written. |
Returns
WebSocketShard — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketShard
object:send(payload)Events
allReady
#Emitted by WebSocketShard when the corresponding Gateway or local lifecycle update occurs. Listen with :on("allReady", handler).
object:on("allReady", function(...)
-- handler arguments match the DiscordLua emit for this event
end)close
#Emitted by WebSocketShard when the corresponding Gateway or local lifecycle update occurs. Listen with :on("close", handler).
object:on("close", function(...)
-- handler arguments match the DiscordLua emit for this event
end)ready
#Emitted by WebSocketShard 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)Examples
local discord = require("discord")
local object = discord.WebSocketShard({})Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationCommandNumericOptionMinMaxValueMixin · ApplicationCommandOptionBase
Version: discord 1.2.9 · runtime 1.0.0