DiscordLua
discorddiscord
v1.2.4
Install

ChannelManager

Manager
On this page

ChannelManager is the cache and REST facade for Channel objects owned by the parent. Typical calls are fetch, create, edit, delete, resolve, and resolveId.

manager Module 1.2.4 REST Source

Constructor

ChannelManager.new(client, guild, channel)

The class table is callable, so ChannelManager(client, guild, channel) is the same as .new.

NameTypeRequiredBehavior
client any required Passed through to the implementation as written.
guild any required Passed through to the implementation as written.
channel any required Passed through to the implementation as written.
lua
local discord = require("discord")
local object = discord.ChannelManager({}, {}, {})

Properties

ChannelManager.channel

# readonly
Name
channel
Type
any
Access
readonly
Description
Channel this ChannelManager belongs to, when resolved from cache.
Availability
Populated from the Gateway/REST payload or constructor for this ChannelManager.

ChannelManager.guild

# readonly
Name
guild
Type
any
Access
readonly
Description
Guild this ChannelManager belongs to, when the payload included a guild id.
Availability
Populated from the Gateway/REST payload or constructor for this ChannelManager.

Methods

ChannelManager:addFollower()

#

Add Follower to this ChannelManager.

Signature

ChannelManager:addFollower(channel, targetChannel, callback)

Parameters

NameTypeRequiredBehavior
channel any required Passed through to the implementation as written.
targetChannel 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

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:addFollower(channel, targetChannel, function(err, result)
    if err then error(err) end
end)

ChannelManager:channelCountWithoutThreads()

#

Performs channel count without threads on this ChannelManager. Call it from bot code when you need that operation on the current object.

Signature

ChannelManager:channelCountWithoutThreads()

Parameters

No parameters.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:channelCountWithoutThreads()

ChannelManager:create()

#

Create a new resource through REST and cache the result.

Signature

ChannelManager:create(guildId, options, callback)

Parameters

NameTypeRequiredBehavior
guildId string required Snowflake id string.
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:create("123", {}, function(err, result)
    if err then error(err) end
end)

ChannelManager:createMessage()

#

Create Message through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.

Signature

ChannelManager:createMessage(channel, options, callback)

Parameters

NameTypeRequiredBehavior
channel any required Passed through to the implementation as written.
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:createMessage(channel, {}, function(err, result)
    if err then error(err) end
end)

ChannelManager:createWebhook()

#

Create Webhook through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.

Signature

ChannelManager:createWebhook(channel, options, callback)

Parameters

NameTypeRequiredBehavior
channel any required Passed through to the implementation as written.
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:createWebhook(channel, {}, function(err, result)
    if err then error(err) end
end)

ChannelManager:delete()

#

Permanently delete this resource through REST.

Signature

ChannelManager:delete(id, reason, callback)

Parameters

NameTypeRequiredBehavior
id string required Snowflake id string.
reason string optional Audit-log reason sent as X-Audit-Log-Reason on REST mutations.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:delete("123", reason, function(err, result)
    if err then error(err) end
end)

ChannelManager:edit()

#

Apply a REST update to this resource.

Signature

ChannelManager:edit(channel, options, callback)

Parameters

NameTypeRequiredBehavior
channel any required Passed through to the implementation as written.
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:edit(channel, {}, function(err, result)
    if err then error(err) end
end)

ChannelManager:fetch()

#

Request a fresh copy of this resource from REST and update the cache.

Signature

ChannelManager:fetch(id, callback)

Parameters

NameTypeRequiredBehavior
id string required Snowflake id string.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Throws

A DiscordLua error when arguments are invalid or the request fails without a callback.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:fetch("123", function(err, result)
    if err then error(err) end
end)

ChannelManager:fetchActive()

#

Fetch Active from REST and update the local cache when the request succeeds.

Signature

ChannelManager:fetchActive(callback)

Parameters

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:fetchActive(function(err, result)
    if err then error(err) end
end)

ChannelManager:fetchActiveThreads()

#

Fetch ActiveThreads from REST and update the local cache when the request succeeds.

Signature

ChannelManager:fetchActiveThreads(callback)

Parameters

NameTypeRequiredBehavior
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:fetchActiveThreads(function(err, result)
    if err then error(err) end
end)

ChannelManager:fetchArchived()

#

Fetch Archived from REST and update the local cache when the request succeeds.

Signature

ChannelManager:fetchArchived(options, callback)

Parameters

NameTypeRequiredBehavior
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:fetchArchived({}, function(err, result)
    if err then error(err) end
end)

ChannelManager:fetchWebhooks()

#

Fetch Webhooks from REST and update the local cache when the request succeeds.

Signature

ChannelManager:fetchWebhooks(channel, callback)

Parameters

NameTypeRequiredBehavior
channel 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

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:fetchWebhooks(channel, function(err, result)
    if err then error(err) end
end)

ChannelManager:setPosition()

#

Set the Position field. Builders return this ChannelManager so setters can be chained.

Signature

ChannelManager:setPosition(channel, position, options, callback)

Parameters

NameTypeRequiredBehavior
channel any required Passed through to the implementation as written.
position any required Passed through to the implementation as written.
options table optional Lua option table. Field names match the corresponding DiscordLua option type when one exists.
callback function optional Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error.

Returns

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:setPosition(channel, position, {}, function(err, result)
    if err then error(err) end
end)

ChannelManager:setPositions()

#

Set the Positions field. Builders return this ChannelManager so setters can be chained.

Signature

ChannelManager:setPositions(positions, callback)

Parameters

NameTypeRequiredBehavior
positions 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

ChannelManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a ChannelManager
object:setPositions(positions, function(err, result)
    if err then error(err) end
end)

Examples

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

ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CachedManager · CategoryChannelChildManager

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc