DiscordLua
discorddiscord
v1.2.4
Install

ShardClientUtil

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

class Module 1.2.4 Source

Constructor

ShardClientUtil.new(client, id, count)

The class table is callable, so ShardClientUtil(client, id, count) is the same as .new.

NameTypeRequiredBehavior
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.
lua
local discord = require("discord")
local object = discord.ShardClientUtil({}, {}, {})

Properties

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

ShardClientUtil.count

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

ShardClientUtil.id

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

ShardClientUtil.ids

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

ShardClientUtil.mode

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

ShardClientUtil.parentPort

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

NameTypeRequiredBehavior
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

ValidationError

Example

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

lua
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

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

Returns

ShardClientUtil — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ShardClientUtil
object:send(message)

ShardClientUtil.shardIdForGuildId()

# static

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

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

Returns

ShardClientUtil — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ShardClientUtil
ShardClientUtil.shardIdForGuildId("123", shardCount)

ShardClientUtil.singleton()

# static

Performs singleton on this ShardClientUtil. Call it from bot code when you need that operation on the current object.

Signature

ShardClientUtil.singleton(client)

Parameters

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

Returns

ShardClientUtil — the same instance, for chaining.

Example

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

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

Examples

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

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

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc