DiscordLua
discorddiscord
v1.2.4
Install

WebSocketShard

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

class Module 1.2.4 Source

Constructor

WebSocketShard.new(manager, id)

The class table is callable, so WebSocketShard(manager, id) is the same as .new.

NameTypeRequiredBehavior
manager any required Passed through to the implementation as written.
id string required Snowflake id string.
lua
local discord = require("discord")
local object = discord.WebSocketShard({}, {})

Properties

WebSocketShard.client

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

WebSocketShard.id

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

WebSocketShard.lastPayload

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

WebSocketShard.lastPingTimestamp

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

WebSocketShard.manager

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

WebSocketShard.ping

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

WebSocketShard.status

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

NameTypeRequiredBehavior
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

lua
local discord = require("discord")
-- object is a WebSocketShard
object:close(code, reason)

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

NameTypeRequiredBehavior
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

lua
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

lua
local discord = require("discord")
-- object is a WebSocketShard
object:markReady()

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

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

WebSocketShard — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a WebSocketShard
object:on(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

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

Returns

WebSocketShard — the same instance, for chaining.

Example

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

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

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

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

Examples

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

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

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc