DiscordLua
discorddiscord
v1.2.4
Install

Role

Class
On 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.

class Module 1.2.4 Source

Properties

Role.client

# readonly
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.

Role.color

# mutable
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.

Role.colors

# mutable
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.

Role.flags

# readonly
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.

Role.guildId

# readonly
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.

Role.hoist

# mutable
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.

Role.icon

# mutable
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.

Role.id

# readonly
Name
id
Type
any
Access
readonly
Description
Snowflake id of this Role.
Availability
Populated from the Gateway/REST payload or constructor for this Role.

Role.managed

# readonly
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.

Role.mentionable

# mutable
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.

Role.name

# mutable
Name
name
Type
any
Access
mutable
Description
Display name of this Role.
Availability
Populated from the Gateway/REST payload or constructor for this Role.

Role.permissions

# mutable
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.

Role.position

# mutable
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.

Role.raw

# readonly
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.

Role.rawPosition

# readonly
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.

Role.tags

# readonly
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.

Role.unicodeEmoji

# mutable
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

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

Returns

any.

Example

lua
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

lua
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

lua
local discord = require("discord")
-- object is a Role
object:createdTimestamp()

Role:delete()

#

Permanently delete this resource through REST.

Signature

Role:delete(reason, callback)

Parameters

NameTypeRequiredBehavior
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

lua
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

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

Role — the same instance, for chaining.

Example

lua
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

lua
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

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

Returns

any.

Example

lua
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

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

lua
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

NameTypeRequiredBehavior
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

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

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

Returns

Role — the same instance, for chaining.

Example

lua
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

lua
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

lua
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.

ActionRow · Activity · ActivityInstance · ActivityLocation · AnonymousGuild · ApplicationCommand · ApplicationRoleConnectionMetadata · Attachment

Version: discord 1.2.4 · runtime 1.0.0

Search Ctrl K Navigate Open Esc