DiscordLua
discorddiscord
v1.2.4
Install

RoleManager

Manager
On this page

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

manager Module 1.2.4 REST Source

Constructor

RoleManager.new(client, guild)

The class table is callable, so RoleManager(client, guild) 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.
lua
local discord = require("discord")
local object = discord.RoleManager({}, {})

Properties

RoleManager.guild

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

Methods

RoleManager:botRoleFor()

#

Performs bot role for on this RoleManager. Call it from bot code when you need that operation on the current object.

Signature

RoleManager:botRoleFor(user)

Parameters

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

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:botRoleFor(user)

RoleManager:comparePositions()

#

Performs compare positions on this RoleManager. Call it from bot code when you need that operation on the current object.

Signature

RoleManager:comparePositions(role1, role2)

Parameters

NameTypeRequiredBehavior
role1 any required Passed through to the implementation as written.
role2 any required Passed through to the implementation as written.

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:comparePositions(role1, role2)

RoleManager:create()

#

Create a new resource through REST and cache the result.

Signature

RoleManager:create(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

RoleManager — the same instance, for chaining.

Example

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

RoleManager:delete()

#

Permanently delete this resource through REST.

Signature

RoleManager: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

RoleManager — the same instance, for chaining.

Example

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

RoleManager:edit()

#

Apply a REST update to this resource.

Signature

RoleManager:edit(role, options, callback)

Parameters

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

RoleManager — the same instance, for chaining.

Example

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

RoleManager:everyone()

#

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

Signature

RoleManager:everyone()

Parameters

No parameters.

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:everyone()

RoleManager:fetch()

#

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

Signature

RoleManager: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

RoleManager — the same instance, for chaining.

Example

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

RoleManager:fetchMemberCounts()

#

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

Signature

RoleManager:fetchMemberCounts(callback)

Parameters

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

Returns

RoleManager — the same instance, for chaining.

Example

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

RoleManager:highest()

#

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

Signature

RoleManager:highest()

Parameters

No parameters.

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:highest()

RoleManager:premiumSubscriberRole()

#

Performs premium subscriber role on this RoleManager. Call it from bot code when you need that operation on the current object.

Signature

RoleManager:premiumSubscriberRole()

Parameters

No parameters.

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:premiumSubscriberRole()

RoleManager:setPosition()

#

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

Signature

RoleManager:setPosition(role, position)

Parameters

NameTypeRequiredBehavior
role any required Passed through to the implementation as written.
position any required Passed through to the implementation as written.

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:setPosition(role, position)

RoleManager:setPositions()

#

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

Signature

RoleManager:setPositions(positions)

Parameters

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

Returns

RoleManager — the same instance, for chaining.

Example

lua
local discord = require("discord")
-- object is a RoleManager
object:setPositions(positions)

Examples

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

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

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc