WebSocketManager
ManagerOn this page
WebSocketManager is the cache and REST facade for WebSocket objects owned by the parent. Typical calls are fetch, create, edit, delete, resolve, and resolveId.
Constructor
WebSocketManager.new(client) The class table is callable, so WebSocketManager(client) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.WebSocketManager({})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 WebSocketManager.
- Name
destroyed- Type
any- Access
- readonly
- Description
- Instance field
WebSocketManager.destroyed. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketManager.
- Name
gateway- Type
any- Access
- readonly
- Description
- Instance field
WebSocketManager.gateway. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketManager.
- Name
options- Type
any- Access
- readonly
- Description
- Instance field
WebSocketManager.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 WebSocketManager.
- Name
shards- Type
- Collection
- Access
- readonly
- Description
- Instance field
WebSocketManager.shards. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketManager.
- Related
- Collection
- Name
status- Type
any- Access
- readonly
- Description
- Instance field
WebSocketManager.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 WebSocketManager.
- Name
strategy- Type
- SimpleShardingStrategy
- Access
- readonly
- Description
- Instance field
WebSocketManager.strategy. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketManager.
- Related
- SimpleShardingStrategy
- Name
totalShards- Type
any- Access
- readonly
- Description
- Instance field
WebSocketManager.totalShards. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this WebSocketManager.
Methods
WebSocketManager:broadcast()
#Performs broadcast on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager:broadcast(packet) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
packet |
any |
required | Passed through to the implementation as written. |
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:broadcast(packet)WebSocketManager:connect()
#Performs connect on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager:connect() Parameters
No parameters.
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:connect()WebSocketManager:destroy()
#Close the Gateway, voice, and REST resources owned by this client.
Signature
WebSocketManager: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
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:destroy({})WebSocketManager:emit()
#Performs emit on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager: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
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:emit(event, ...)WebSocketManager:fetchGatewayInformation()
#Fetch GatewayInformation from REST and update the local cache when the request succeeds.
Signature
WebSocketManager:fetchGatewayInformation() Parameters
No parameters.
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:fetchGatewayInformation()WebSocketManager:getShardCount()
#Read the ShardCount value from this WebSocketManager.
Signature
WebSocketManager:getShardCount() Parameters
No parameters.
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:getShardCount()WebSocketManager:getShardIds()
#Read the ShardIds value from this WebSocketManager.
Signature
WebSocketManager:getShardIds() Parameters
No parameters.
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:getShardIds()WebSocketManager:off()
#Performs off on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager: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
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:off(event, function(err, result)
if err then error(err) end
end)WebSocketManager:on()
#Performs on on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager: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
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:on(event, function(err, result)
if err then error(err) end
end)WebSocketManager:once()
#Performs once on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager: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
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:once(event, function(err, result)
if err then error(err) end
end)WebSocketManager:ping()
#Performs ping on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager:ping() Parameters
No parameters.
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:ping()WebSocketManager:shard()
#Performs shard on this WebSocketManager. Call it from bot code when you need that operation on the current object.
Signature
WebSocketManager:shard(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
WebSocketManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a WebSocketManager
object:shard("123")Examples
local discord = require("discord")
local object = discord.WebSocketManager({})Related APIs
ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CachedManager · CategoryChannelChildManager
Version: discord 1.2.9 · runtime 1.0.0