Class: Server

Server

new Server()

A Server is a large Curse group root, to not mix up with groups. It is the responsability of the caller to check if the server doesn't exist already

Properties:
Name Type Description
client Client

Client object used to create this Server instance.

ID string

Curse UUID of the server.

name string

Name of the server.

roles Map

Regroup all the Roles of the current Server. The keys are the roles IDs and the values are instances of the Role class.

channelList array

Regroup all the Channels of the current Server.

Source:

Methods

banUser(user, reason, ipBan, callback)

Kick a User from the server

Parameters:
Name Type Description
user User

Specified user to ban

reason string

Reason of the ban

ipBan boolean

If true, ban the user with his ip.

callback function

Facultative arg, callback: (errors) => {}. This function can take an argument errors that is null or undefined when function ends correctly.

Source:

everyBans(callback)

Iterate through all the bans of the server.

Parameters:
Name Type Description
callback function

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

  • errors is null or undefined when everything happens correctly.
  • ban is a ServerBan object of the next ban.
  • done is a boolean, true when there is no more bans to iterate over.
  • To stop the iteration return false inside the callback
Source:
Example
myServer.everyBans(function(errors, ban, done){
    if(errors == null && !done){

        //Work with the ServerBan object

        //Example to stop iterating:
        //This will stop the iteration if the user banned has curse ID 1
        if(ban.user.ID === 1){
            return false;
        }
    }
});

everyServerMembers(callback)

Iterate through all the members of the server.

Parameters:
Name Type Description
callback function

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

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

        //Work with the user object

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

getBans(query, pagesize, page, callback)

Search for bans in the server. Arguments can be set to undefined.

Parameters:
Name Type Description
query string

String to search the ban (Curse API don't give much detail on it).

pagesize number

Maximum size for the page of results.

page number

First page is 1.

callback function

Callback: (errors, bans) => {}.

  • errors is null or undefined when function ends correctly.
  • bans is an array of ServerBan.
Source:

getUserInfo(user, callback)

Get user informations from the server.

Parameters:
Name Type Description
user User

User to get informations about

callback function

Callback: (errors, results) => {}.

  • errors is null or undefined when function ends correctly.
  • results is a ServerMemberResult.
Source:

kickUser(user, callback)

Kick a User from the server

Parameters:
Name Type Description
user User

Specified user to kick

callback function

Facultative arg, callback: (errors) => {}. This function can take an argument errors that is null or undefined when function ends correctly.

Source:

leave(callback)

Leave this server to not receive notifications from it anymore.

Parameters:
Name Type Description
callback function

Facultative arg, callback: (errors) => {}. This function can take an argument errors that is null or undefined when function ends correctly.

Source:

searchUser(Username, RoleID, ResultSize, ResultPage, SortType, SortAscending, callback)

Search for a particular user, the callback returns an array of ServerMemberResult objects All parameters are facultative, but use everyServerMembers to check the server memberlist

Parameters:
Name Type Description
Username string

Username to search for

RoleID number

Role ID to look into

ResultSize number

Size of the answer, API limits mosts of the arrays to 50 or 100 items

ResultPage number

First page is 1

SortType number

Follows groups-v1.GroupMemberSearchSortType definition.

  • Default: 0
  • Role: 1
  • Username: 2
  • DateJoined: 3
  • DateLastActive: 4
SortAscending boolean

Ascending is true, descending is false.

callback function

Callback: (errors, results) => {}.

  • errors is null or undefined when function ends correctly.
  • results is an array of ServerMemberResult.
Source:

sendPrivateConversationMessage(user, messageContent, callback)

Send a private message to a user inside a server

Parameters:
Name Type Description
user User

User to send the message

messageContent string

Content of the message

callback function

Facultative arg, callback: (errors) => {}. This function can take an argument errors that is null or undefined when function ends correctly.

Source:

unban(user, callback)

Unban a specified user from the current server

Parameters:
Name Type Description
user User

User to unban

callback function

Facultative arg, callback: (errors) => {}. This function can take an argument errors that is null or undefined when function ends correctly.

Source: