Class: Role

Role

new Role()

Server role users can have on a Server

Properties:
Name Type Description
ID number

Identifier of the role, the owner usually has the role 0.

server Server

Server owner of this Role.

client Client

Client object used to create this Role instance.

name string

Name of this role.

rank number

Rank of this role, the most powerful rank (the owner), is the lowest, and the less important the bigger the rank is.

isDefault boolean

If true, this is the role of all new users on the server.

Source:

Methods

everyMember(callback)

Iterate through all the members of this server role.

Parameters:
Name Type Description
callback function

callback: (errors, user, done) => {}.

  • errors is null or undefined when everything happens correctly.
  • user is a User member of this role.
  • done is a boolean, true when there is no more users to iterate over.
  • To stop the iteration return false inside the callback
Source:
Example
myRole.everyMember(function(errors, user, done){
    if(errors == null && !done){

        //Work with the user object

        //This will stop the iteration if the user with curse ID 1 is found
        if(user.ID === 1){
            return false;
        }
    }
});

isMember(user, callback)

Callback with a boolean to know if a user is member of this group or not, answer is transmitted through callback

Parameters:
Name Type Description
user User

User to check

callback function

callback: (errors, isRole) => {}.

  • errors is null or undefined when everything happens correctly.
  • isRole is a boolean, true if the User has the role, false if not.
Source: