RoleManager
ManagerOn 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.
Constructor
RoleManager.new(client, guild) The class table is callable, so RoleManager(client, guild) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
client |
any |
required | Passed through to the implementation as written. |
guild |
any |
required | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.RoleManager({}, {})Properties
- 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
| Name | Type | Required | Behavior |
|---|---|---|---|
user |
any |
required | Passed through to the implementation as written. |
Returns
RoleManager — the same instance, for chaining.
Example
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
callback |
function |
optional | Optional completion callback function(err, result). If omitted, failures raise a DiscordLua error. |
Returns
RoleManager — the same instance, for chaining.
Example
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
local discord = require("discord")
-- object is a RoleManager
object:highest()RoleManager:setPosition()
#Set the Position field. Builders return this RoleManager so setters can be chained.
Signature
RoleManager:setPosition(role, position) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
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
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
| Name | Type | Required | Behavior |
|---|---|---|---|
positions |
any |
required | Passed through to the implementation as written. |
Returns
RoleManager — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a RoleManager
object:setPositions(positions)Examples
local discord = require("discord")
local object = discord.RoleManager({})Related APIs
ApplicationCommandManager · ApplicationCommandPermissionsManager · ApplicationEmojiManager · AutoModerationRuleManager · BaseGuildEmojiManager · BaseManager · CachedManager · CategoryChannelChildManager
Version: discord 1.2.4 · runtime 1.0.0