Role
ClassOn this page
Role is a DiscordLua class representing a Discord resource. Obtain it from a manager, an event payload, or the constructor when one is documented below.
Properties
- 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 Role.
- Name
color- Type
any- Access
- mutable
- Description
- Instance field
Role.color. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
colors- Type
any- Access
- mutable
- Description
- Instance field
Role.colors. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
flags- Type
any- Access
- readonly
- Description
- Instance field
Role.flags. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
guildId- Type
any- Access
- readonly
- Description
- Instance field
Role.guildId. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
hoist- Type
any- Access
- mutable
- Description
- Instance field
Role.hoist. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
icon- Type
any- Access
- mutable
- Description
- Instance field
Role.icon. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
id- Type
any- Access
- readonly
- Description
- Snowflake id of this Role.
- Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
managed- Type
any- Access
- readonly
- Description
- Instance field
Role.managed. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
mentionable- Type
any- Access
- mutable
- Description
- Instance field
Role.mentionable. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
name- Type
any- Access
- mutable
- Description
- Display name of this Role.
- Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
permissions- Type
any- Access
- mutable
- Description
- Instance field
Role.permissions. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
position- Type
any- Access
- mutable
- Description
- Instance field
Role.position. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
raw- Type
any- Access
- readonly
- Description
- Instance field
Role.raw. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
rawPosition- Type
any- Access
- readonly
- Description
- Instance field
Role.rawPosition. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
tags- Type
any- Access
- readonly
- Description
- Instance field
Role.tags. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
- Name
unicodeEmoji- Type
any- Access
- mutable
- Description
- Instance field
Role.unicodeEmoji. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this Role.
Methods
Role:comparePositionTo()
#Performs compare position to on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:comparePositionTo(other) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
other |
any |
required | Passed through to the implementation as written. |
Returns
any.
Example
local discord = require("discord")
-- object is a Role
object:comparePositionTo(other)Role:createdAt()
#Create dAt through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
Role:createdAt() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:createdAt()Role:createdTimestamp()
#Create dTimestamp through REST and cache the result when the request succeeds. Pass function(err, result) to handle failures without raising.
Signature
Role:createdTimestamp() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a Role
object:createdTimestamp()Role:delete()
#Permanently delete this resource through REST.
Signature
Role:delete(reason, callback) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
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
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:delete(reason, function(err, result)
if err then error(err) end
end)Role:edit()
#Apply a REST update to this resource.
Signature
Role:edit(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
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:edit({}, function(err, result)
if err then error(err) end
end)Role:editable()
#Apply a REST update to able and refresh the local object when the request succeeds.
Signature
Role:editable() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:editable()Role:equals()
#Return whether this Role refers to the same resource as the argument.
Signature
Role:equals(other) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
other |
any |
required | Passed through to the implementation as written. |
Returns
any.
Example
local discord = require("discord")
-- object is a Role
object:equals(other)Role:guild()
#Performs guild on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:guild() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:guild()Role:hexColor()
#Performs hex color on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:hexColor() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:hexColor()Role:iconURL()
#Performs icon url on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:iconURL(options) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
options |
table |
optional | Lua option table. Field names match the corresponding DiscordLua option type when one exists. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:iconURL({})Role:members()
#Performs members on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:members() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:members()Role:permissionsIn()
#Performs permissions in on this Role. Call it from bot code when you need that operation on the current object.
Signature
Role:permissionsIn(channel, checkAdmin) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
channel |
any |
required | Passed through to the implementation as written. |
checkAdmin |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:permissionsIn(channel, checkAdmin)Role:setColor()
#Set the Color field. Builders return this Role so setters can be chained.
Signature
Role:setColor(color) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
color |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setColor(color)Role:setColors()
#Set the Colors field. Builders return this Role so setters can be chained.
Signature
Role:setColors(colors) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
colors |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setColors(colors)Role:setHoist()
#Set the Hoist field. Builders return this Role so setters can be chained.
Signature
Role:setHoist(hoist) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
hoist |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setHoist(hoist)Role:setIcon()
#Set the Icon field. Builders return this Role so setters can be chained.
Signature
Role:setIcon(icon) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
icon |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setIcon(icon)Role:setMentionable()
#Set the Mentionable field. Builders return this Role so setters can be chained.
Signature
Role:setMentionable(mentionable) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
mentionable |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setMentionable(mentionable)Role:setName()
#Set the Name field. Builders return this Role so setters can be chained.
Signature
Role:setName(name) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
name |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setName(name)Role:setPermissions()
#Set the Permissions field. Builders return this Role so setters can be chained.
Signature
Role:setPermissions(permissions) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
permissions |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setPermissions(permissions)Role:setPosition()
#Set the Position field. Builders return this Role so setters can be chained.
Signature
Role:setPosition(position) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
position |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setPosition(position)Role:setUnicodeEmoji()
#Set the UnicodeEmoji field. Builders return this Role so setters can be chained.
Signature
Role:setUnicodeEmoji(emoji) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
emoji |
any |
required | Passed through to the implementation as written. |
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:setUnicodeEmoji(emoji)Role:toJSON()
#Serialize this Role into a Lua table suitable for REST or debugging.
Signature
Role:toJSON() Parameters
No parameters.
Returns
any.
Example
local discord = require("discord")
-- object is a Role
object:toJSON()Role:toString()
#function toString() { [native code] }
Signature
Role:toString() Parameters
No parameters.
Returns
Role — the same instance, for chaining.
Example
local discord = require("discord")
-- object is a Role
object:toString()Examples
Obtain this object from a manager, wrap helper, or event payload — it is not constructed directly in typical bot code.
Related APIs
ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment
Version: discord 1.2.4 · runtime 1.0.0