CachedManager
ManagerOn this page
CachedManager is the cache and REST facade for Cached objects owned by the parent. Typical calls are fetch, create, edit, delete, resolve, and resolveId.
Constructor
CachedManager.new(client, holds) The class table is callable, so CachedManager(client, holds) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
holds |
any |
required | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.CachedManager({}, {})Properties
- Name
cache- Type
- Collection
- Access
- readonly
- Description
- In-memory Collection of cached objects owned by this CachedManager.
- Availability
- Populated from the Gateway/REST payload or constructor for this CachedManager.
- Related
- Collection
- 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 CachedManager.
- Name
holds- Type
any- Access
- readonly
- Description
- Instance field
CachedManager.holds. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this CachedManager.
Methods
CachedManager:clear()
#Performs clear on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:clear() Parameters
No parameters.
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:clear()CachedManager:delete()
#Permanently delete this resource through REST.
Signature
CachedManager:delete(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:delete("123")CachedManager:each()
#Performs each on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:each(fn) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
fn |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:each(fn)CachedManager:filter()
#Performs filter on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:filter(predicate) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
predicate |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:filter(predicate)CachedManager:find()
#Performs find on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:find(predicate) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
predicate |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:find(predicate)CachedManager:get()
#Performs get on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:get(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:get("123")CachedManager:has()
#Performs has on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:has(id) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:has("123")CachedManager:resolve()
#Resolve a snowflake, object, or mention to a cached instance.
Signature
CachedManager:resolve(idOrInstance) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
idOrInstance |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:resolve("123")CachedManager:resolveId()
#Resolve a snowflake, object, or mention to an id string.
Signature
CachedManager:resolveId(idOrInstance) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
idOrInstance |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:resolveId("123")CachedManager:set()
#Performs set on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:set(id, value) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
id |
string |
required | Snowflake id string. |
value |
any |
required | Passed through to the implementation as written. |
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:set("123", value)CachedManager:size()
#Performs size on this CachedManager. Call it from bot code when you need that operation on the current object.
Signature
CachedManager:size() Parameters
No parameters.
Returns
CachedManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a CachedManager
object:size()Static members
-
CachedManager.BaseManager -
CachedManager.DataManager
Examples
local discord = require("discord")
local object = discord.CachedManager({})Related APIs
ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CategoryChannelChildManager · ChannelManager
Version: discord 1.2.4 · runtime 1.0.0