ShardClientUtil
ClassOn this page
ShardClientUtil 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
ShardClientUtil.new(client, id, count) The class table is callable, so ShardClientUtil(client, id, count) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
id |
string |
required | Snowflake id string. |
count |
any |
required | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.ShardClientUtil({}, {}, {})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 ShardClientUtil.
- Name
count- Type
any- Access
- readonly
- Description
- Instance field
ShardClientUtil.count. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this ShardClientUtil.
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this ShardClientUtil.
- Availability
- Populated from the Gateway/REST payload or constructor for this ShardClientUtil.
- Name
ids- Type
any- Access
- readonly
- Description
- Instance field
ShardClientUtil.ids. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this ShardClientUtil.
- Name
mode- Type
any- Access
- readonly
- Description
- Instance field
ShardClientUtil.mode. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this ShardClientUtil.
- Name
parentPort- Type
any- Access
- readonly
- Description
- Instance field
ShardClientUtil.parentPort. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this ShardClientUtil.
Methods
ShardClientUtil:broadcastEval()
#Evaluate a Lua source string on every shard and collect results.
Signature
ShardClientUtil:broadcastEval(script, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
script |
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
ShardClientUtil — the same instance, for chaining.
Throws
Example
local discord = require("discord")
-- object is a ShardClientUtil
object:broadcastEval(script, function(err, result)
if err then error(err) end
end)ShardClientUtil:fetchClientValues()
#Read a property path from every shard client.
Signature
ShardClientUtil:fetchClientValues(prop, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
prop |
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
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
object:fetchClientValues(prop, function(err, result)
if err then error(err) end
end)ShardClientUtil:listen()
#Performs listen on this ShardClientUtil. Call it from bot code when you need that operation on the current object.
Signature
ShardClientUtil:listen() Parameters
No parameters.
Returns
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
object:listen()ShardClientUtil:respawnAll()
#Performs respawn all on this ShardClientUtil. Call it from bot code when you need that operation on the current object.
Signature
ShardClientUtil:respawnAll() Parameters
No parameters.
Returns
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
object:respawnAll()ShardClientUtil:send()
#Send a message, payload, or packet using this object.
Signature
ShardClientUtil:send(message) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
message |
any |
required | Passed through to the implementation as written. |
Returns
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
object:send(message)Performs shard id for guild id on this ShardClientUtil. Call it from bot code when you need that operation on the current object.
Signature
ShardClientUtil.shardIdForGuildId(guildId, shardCount) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
guildId |
string |
required | Snowflake id string. |
shardCount |
any |
required | Passed through to the implementation as written. |
Returns
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
ShardClientUtil.shardIdForGuildId("123", shardCount)Performs singleton on this ShardClientUtil. Call it from bot code when you need that operation on the current object.
Signature
ShardClientUtil.singleton(client) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
Returns
ShardClientUtil — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a ShardClientUtil
ShardClientUtil.singleton(client)Events
shardMessage
#Emitted by ShardClientUtil when the corresponding Gateway or local lifecycle update occurs. Listen with :on("shardMessage", handler).
object:on("shardMessage", function(...)
-- handler arguments match the DiscordLua emit for this event
end)Examples
local discord = require("discord")
local object = discord.ShardClientUtil({})Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0