Role class

const role = new Role(data, addon, guild);

constructor

The Permissions class provides three required arguments. The first argument is the Discord.js Role class where it can collect the data from. The second argument is a Zyno Bot Addons Addon class of the addon where the role belongs to. The third argument is the Zyno Bot Addons Guild class of the guild where the role belongs to.

Properties

id

The id of the role and is a Twitter snowflake.

name

The name of the role.

string

The role as a string mention for in a Discord channel.

color

An object which provides the hex and the base10 color of the role.

{
    hex: string;
    base: number;
}

hoist

A boolean which defines whether the role should be displayed separately from the members or not.

position

The position of the role compared to the other roles where the lowest possible position is 0.

created

An instance of the NodeJS built-in Date class which defines the time when the role was created.

createdTimestamp

A number which represents the timestamp of the time when the role was created.

editable

A boolean which defines whether the bot is able to change this role or not.

guild

The Zyno Bot Addons Guild class which defines in which guild the role belongs.

guildId

The id of the guild where the role belongs to.

permissions

An instance of the Discord.js PermissionsBitField class which defines which permissions members with the role have.

mentionable

A boolean which defines whether the role can be mentioned by others or not.

Functions

setName

role.setName(name: string, reason?: string) : Promise<Role>;

Updates the name of the current role. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

name

The new name you would like to give the role. The name must be a string between 1-100 characters.

reason

The reason to change the role's name. This must be a string between 1-512 characters, but is not required.

setHoist

role.setHoist(hoist?: boolean, reason?: string) : Promise<Role>;

Displays the role separately from the members or makes it display equally with the members depending on the value of the hoist argument. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

hoist

A boolean which defines whether or not you want the role to be displayed separately from the members or not in the members list. When this argument is not set, it will automatically set the value to the opposite of what currently is the case.

reason

The reason to change the role's hoist status. This must be a string between 1-512 characters, but is not required.

setColor

role.setColor(color: string | number, reason?: string) : Promise<Role>;

Changes the color of the role. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

color

The new color of the role. This must be a HEX color (string) or a base10 color (number) which represents the color of the role.

reason

The reason to change the role's color. This must be a string between 1-512 characters, but is not required.

setPosition

role.setPosition(position: number, reason?: string) : Promise<Role>;

Changes the position of the role compared to the other roles. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

position

A number which defines the new position of the role compared to the other roles where 0 is the highest position.

reason

The reason to change the role's position. This must be a string between 1-512 characters, but is not required.

setMentionable

role.setMentionable(mentionable?: boolean, reason?: string) : Promise<Role>;

Changes the mentionable status of the role. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

mentionable

A boolean which defines whether or not you want others to be able to mention the role or not. When this argument is not set, it will automatically set the value to the opposite of what currently is the case.

reason

The reason to change the role's mentionable status. This must be a string between 1-512 characters, but is not required.

setPermissions

role.setPermissions(permissions: [bigint], reason?: string) : Promise<Role>;

Sets new permissions for the role and overwrites previously set permissions. The function returns a Promise which returns the Role class once the Promise has been fulfilled.

ArgumentDescription

permissions

An array with the permissions the user should have. The values of the array should be bigints which represents the permission you want to set. You can also use the permissionsBitfield object to get these bigint values.

reason

The reason to change the role's permissions. This must be a string between 1-512 characters, but is not required.

delete

role.delete() : Promise<void>;

Deletes the role. The function returns a Promise which will be fulfilled once the role has been deleted.

Last updated