rustplus-ts
Version:
Rust+ API Wrapper written in TypeScript for the game Rust.
784 lines • 63.6 kB
TypeScript
import { EventEmitter } from 'events';
import { Logger } from 'winston';
import * as rpi from './interfaces/rustplus';
export declare enum EmitErrorType {
WebSocket = 0,
Callback = 1
}
export declare enum AppResponseError {
/**
* No error was found.
*/
NoError = 0,
/**
* unknown occurences:
* - unknown
*/
Unknown = 1,
/**
* server_error occurences:
* - If there was an error during the executing of request handler on server side.
* - If CameraRendererManager instance is null.
*/
ServerError = 2,
/**
* banned occurences:
* - Trying to run any request while being Rust+ banned on the rust server.
*/
Banned = 3,
/**
* rate_limit occurences:
* - Too many requests too fast, tokens ran out.
*/
RateLimit = 4,
/**
* not_found occurences:
* - playerToken might be invalid, rust server might have reset Rust+ data.
* - smart device can't be found.
* - Trying to run promoteToLeader on someone that is not in the team.
* - Trying to run cameraSubscribe on a cameraId that could not be found.
*/
NotFound = 5,
/**
* wrong_type occurences:
* - Trying to run setEntityValue on Alarm or StorageMonitor.
* - Trying to run checkSubscription on Switch or StorageMonitor.
* - Trying to run setSubscription on Switch or StorageMonitor.
*/
WrongType = 6,
/**
* no_team occurences:
* - Trying to run promoteToLeader when you're not in a team.
* - Trying to run getTeamChat when you're not in a team.
*/
NoTeam = 7,
/**
* no_clan occurences:
* - Trying to run getClanInfo when you're not in a clan.
* - Trying to run setClanMotd when you're not in a clan.
* - Trying to run getClanChat when you're not in a clan.
* - Trying to run sendClanMessage when you're not in a clan.
*/
NoClan = 8,
/**
* no_map occurences:
* - Trying to run getMap but imageData is null.
*/
NoMap = 9,
/**
* no_camera occurences:
* - Trying to run cameraInput when there is no camera subscribed to.
*/
NoCamera = 10,
/**
* no_player occurences:
* - Trying to run cameraSubscribe while player token is invalid or player caller dead.
*/
NoPlayer = 11,
/**
* access_denied occurences:
* - Trying to run cameraSubscribe with a cameraId but access was denied.
* - Trying to run getNexusAuth but access was denied.
* - Trying to run promoteToLeader when you're not the leader.
*/
AccessDenied = 12,
/**
* player_online occurences:
* - Trying to run cameraSubscribe when requester online.
*/
PlayerOnline = 13,
/**
* invalid_playerid occurences:
* - Trying to run getNexusAuth but playerid is invalid.
*/
InvalidPlayerid = 14,
/**
* invalid_id occurences:
* - Trying to run cameraSubscribe with a cameraId that is an empty string.
*/
InvalidId = 15,
/**
* invalid_motd occurences:
* - Trying to run setClanMotd but motd was invalid.
*/
InvalidMotd = 16,
/**
* too_many_subscribers occurences:
* - Trying to run setSubscription on a Alarm that have too many subscribers already.
*/
TooManySubscribers = 17,
/**
* not_enabled occurences:
* - Trying to run cameraInput when cameras are disabled on the rust server.
* - Trying to run cameraSubscribe when cameras are disabled on the rust server.
* - Trying to run cameraUnsubscribe when cameras are disabled on the rust server.
*/
NotEnabled = 18,
/**
* message_not_sent occurences:
* - Trying to run sendClanMessage but something went wrong on server side.
* - Trying to run sendTeamMessage but something went wrong on server side.
*/
MessageNotSent = 19
}
export interface RustPlusRequestTokens {
connection: number;
playerId: {
[playerId: string]: number;
};
serverPairing: number;
}
export declare enum ConsumeTokensError {
NoError = 0,
Unknown = 1,
NotEnoughConnectionTokens = 2,
NotEnoughPlayerIdTokens = 3,
WaitReplenishTimeout = 4
}
interface CallbackFunction {
(appMessage: rpi.AppMessage): void;
}
export declare class RustPlus extends EventEmitter {
private static readonly MAX_REQUESTS_PER_IP_ADDRESS;
private static readonly REQUESTS_PER_IP_REPLENISH_RATE;
private static readonly MAX_REQUESTS_PER_PLAYER_ID;
private static readonly REQUESTS_PER_PLAYER_ID_REPLENISH_RATE;
private static readonly MAX_REQUESTS_FOR_SERVER_PAIRING;
private static readonly REQUESTS_FOR_SERVER_PAIRING_REPLENISH_RATE;
private static readonly REQUEST_GET_INFO_TOKEN_COST;
private static readonly REQUEST_GET_TIME_TOKEN_COST;
private static readonly REQUEST_GET_MAP_TOKEN_COST;
private static readonly REQUEST_GET_TEAM_INFO_TOKEN_COST;
private static readonly REQUEST_GET_TEAM_CHAT_TOKEN_COST;
private static readonly REQUEST_SEND_TEAM_MESSAGE_TOKEN_COST;
private static readonly REQUEST_GET_ENTITY_INFO_TOKEN_COST;
private static readonly REQUEST_SET_ENTITY_VALUE_TOKEN_COST;
private static readonly REQUEST_CHECK_SUBSCRIPTION_TOKEN_COST;
private static readonly REQUEST_SET_SUBSCRIPTION_TOKEN_COST;
private static readonly REQUEST_GET_MAP_MARKERS_TOKEN_COST;
private static readonly REQUEST_PROMOTE_TO_LEADER_TOKEN_COST;
private static readonly REQUEST_GET_CLAN_INFO_TOKEN_COST;
private static readonly REQUEST_SET_CLAN_MOTD_TOKEN_COST;
private static readonly REQUEST_GET_CLAN_CHAT_TOKEN_COST;
private static readonly REQUEST_SEND_CLAN_MESSAGE_TOKEN_COST;
private static readonly REQUEST_GET_NEXUS_AUTH_TOKEN_COST;
private static readonly REQUEST_CAMERA_SUBSCRIBE_TOKEN_COST;
private static readonly REQUEST_CAMERA_UNSUBSCRIBE_TOKEN_COST;
private static readonly REQUEST_CAMERA_INPUT_TOKEN_COST;
private static readonly REQUEST_GET_INFO_TIMEOUT_MS;
private static readonly REQUEST_GET_TIME_TIMEOUT_MS;
private static readonly REQUEST_GET_MAP_TIMEOUT_MS;
private static readonly REQUEST_GET_TEAM_INFO_TIMEOUT_MS;
private static readonly REQUEST_GET_TEAM_CHAT_TIMEOUT_MS;
private static readonly REQUEST_SEND_TEAM_MESSAGE_TIMEOUT_MS;
private static readonly REQUEST_GET_ENTITY_INFO_TIMEOUT_MS;
private static readonly REQUEST_SET_ENTITY_VALUE_TIMEOUT_MS;
private static readonly REQUEST_CHECK_SUBSCRIPTION_TIMEOUT_MS;
private static readonly REQUEST_SET_SUBSCRIPTION_TIMEOUT_MS;
private static readonly REQUEST_GET_MAP_MARKERS_TIMEOUT_MS;
private static readonly REQUEST_PROMOTE_TO_LEADER_TIMEOUT_MS;
private static readonly REQUEST_GET_CLAN_INFO_TIMEOUT_MS;
private static readonly REQUEST_SET_CLAN_MOTD_TIMEOUT_MS;
private static readonly REQUEST_GET_CLAN_CHAT_TIMEOUT_MS;
private static readonly REQUEST_SEND_CLAN_MESSAGE_TIMEOUT_MS;
private static readonly REQUEST_GET_NEXUS_AUTH_TIMEOUT_MS;
private static readonly REQUEST_CAMERA_SUBSCRIBE_TIMEOUT_MS;
private static readonly REQUEST_CAMERA_UNSUBSCRIBE_TIMEOUT_MS;
private static readonly REQUEST_CAMERA_INPUT_TIMEOUT_MS;
ip: string;
port: string;
private useFacepunchProxy;
private logger;
private seq;
private seqCallbacks;
private ws;
private tokens;
private replenishInterval;
/**
* @param {string} ip The ip address or hostname of the Rust Server.
* @param {string} port The port of the Rust Server (app.port in server.cfg)
* @param useFacepunchProxy True to use secure websocket via Facepunch's proxy, or false to directly connect
* to Rust Server.
*
* Events emitted by the RustPlus class instance
* - connecting: When we are connecting to the Rust Server.
* - connected: When we are connected to the Rust Server.
* - message: When an AppMessage has been received from the Rust Server.
* - request: When an AppRequest has been sent to the Rust Server.
* - disconnected: When we are disconnected from the Rust Server.
* - error: When something goes wrong with the WebSocket, incoming message or the request callback function.
*/
constructor(ip: string, port: string, useFacepunchProxy?: boolean, logger?: Logger | null);
/**
* Function that replenish the connection, playerId and server pairing tokens.
*/
private replenishTask;
/**
* Function that replenish the connection tokens.
*/
private replenishConnectionTokens;
/**
* Function that replenish the playerId tokens.
*/
private replenishPlayerIdTokens;
/**
* Function that replenish the server pairing tokens.
*/
private replenishServerPairingTokens;
/**
* Consume tokens amount of tokens from connection and playerId.
* @param {string} playerId - The steamId of the player consuming the tokens.
* @param {number} tokens - The tokens to consume.
* @param {boolean} waitForReplenish - If true, it will wait till there are available tokens to consume.
* @param {number} timeoutMs - Timeout if tokens were not replenished in timeout milliseconds.
* @returns {Promise<ConsumeTokensError>} Resolves with a `ConsumeTokensError` enum value indicating success or
* the type of error encountered.
*/
private consumeTokens;
/**
* Delays the execution of the next operation by a specified number of milliseconds.
*
* @param {number} ms - The amount of time, in milliseconds, to delay the execution.
*
* @returns {Promise<void>} A promise that resolves after the specified delay.
*/
private delay;
/**
* Retrieves the next available sequence number for a request.
*
* Increments the sequence number and ensures that it is unique by checking for any existing callbacks
* associated with the current sequence number. If a callback exists, it continues to increment the
* sequence until a unique number is found.
*
* @returns {number} The next available sequence number.
*/
private getNextSeq;
/**
* Setup and connect to the Rust Server via WebSocket.
* @returns {Promise<boolean>} Promise of True if successful, else false.
*/
connect(): Promise<boolean>;
/**
* Disconnect from the Rust Server and clear WebSocket variable.
* @returns {boolean} True if successful, else false.
*/
disconnect(): Promise<boolean>;
/**
* Check if RustPlus is connected to the server.
* @returns {boolean} True if connected, else false.
*/
isConnected(): boolean;
/**
* Sends a request to the Rust server with a specified callback that will be executed upon receiving a response.
* The request is created using the `AppRequest` protocol, and it ensures that the WebSocket connection is open
* before sending the request. The function also handles the sequence number for requests and stores the callback
* for when the response arrives.
*
* @param {Omit<rpi.AppRequest, 'seq' | 'playerId' | 'playerToken'>} data - The data for the request,
* excluding the `seq`, `playerId`,
* and `playerToken`, which are
* provided separately.
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when the server responds.
* @param {number | null} [seq=null] - The sequence number for the request. If not provided, a new sequence number
* is generated.
*
* @returns {Error | void} Returns an `Error` if there was an issue sending the request or formatting the data.
* Returns `void` if the request is successfully sent.
*/
sendRequest(data: Omit<rpi.AppRequest, 'seq' | 'playerId' | 'playerToken'>, playerId: string, playerToken: number, callback: CallbackFunction, seq?: number | null): Error | void;
/**
* Sends an asynchronous request to the Rust server and returns a Promise that resolves when a response is received
* or rejects when a timeout is reached. The request is formatted using the `AppRequest` protocol, and the server's
* response is handled within the promise. If no response is received within the provided timeout, an error is
* returned.
*
* @param {Omit<rpi.AppRequest, 'seq' | 'playerId' | 'playerToken'>} data - The data for the request,
* excluding the `seq`, `playerId`,
* and `playerToken`, which are
* passed separately.
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} [timeoutMs=10000] - The timeout in milliseconds to wait for a response before returning an error.
*
* @returns {Promise<rpi.AppResponse | Error>} A Promise that resolves to the server's response if
* successful, or an Error if the request times out or encounters
* an issue.
*/
sendRequestAsync(data: Omit<rpi.AppRequest, 'seq' | 'playerId' | 'playerToken'>, playerId: string, playerToken: number, timeoutMs?: number): Promise<rpi.AppResponse | Error>;
/**
* Translates an `AppResponse` error object into a corresponding `AppResponseError` enum value.
* If the `appResponse` contains no error, it returns `AppResponseError.NoError`.
* If the `appResponse.error` matches any known error string, the function maps it to the appropriate
* `AppResponseError` enum. If no matching error string is found, it returns `AppResponseError.Unknown`.
*
* @param {rpi.AppResponse} appResponse - The response object from the Rust server which may contain an error.
*
* @returns {AppResponseError} The corresponding `AppResponseError` enum value based on the error string in the
* `appResponse.error` object. Returns `AppResponseError.NoError` if no error is
* present.
*/
getAppResponseError(appResponse: rpi.AppResponse): AppResponseError;
/**
* Rust+ API requests.
*/
/**
* Get the server info (callback version).
* Consumes tokens and then sends a request to retrieve server information.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getInfo(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the server info (async version).
* Consumes tokens and then sends a request to retrieve server information, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* server info (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getInfoAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the server time (callback version).
* Consumes tokens and then sends a request to retrieve server time.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getTime(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the server time (async version).
* Consumes tokens and then sends a request to retrieve server time, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* server time (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getTimeAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the server map (callback version).
* Consumes tokens and then sends a request to retrieve server map.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getMap(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the server map (async version).
* Consumes tokens and then sends a request to retrieve server map, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* server map (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getMapAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the team info (callback version).
* Consumes tokens and then sends a request to retrieve team information.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getTeamInfo(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the team info (async version).
* Consumes tokens and then sends a request to retrieve team information, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* team info (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getTeamInfoAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the team chat (callback version).
* Consumes tokens and then sends a request to retrieve team chat.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getTeamChat(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the team chat (async version).
* Consumes tokens and then sends a request to retrieve team chat, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* team chat (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getTeamChatAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Send a team message (callback version).
* Consumes tokens and then sends a request to send team message.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} message - The message to be sent in the team chat.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
sendTeamMessage(playerId: string, playerToken: number, message: string, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Send a team message (async version).
* Consumes tokens and then sends a request to send team message, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} message - The message to be sent in the team chat.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* send team message (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
sendTeamMessageAsync(playerId: string, playerToken: number, message: string, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get entity info (callback version).
* Consumes tokens and then sends a request to retrieve entity information.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity to retrieve information about.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getEntityInfo(playerId: string, playerToken: number, entityId: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get entity info (async version).
* Consumes tokens and then sends a request to retrieve entity information, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity to retrieve information about.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* entity info (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getEntityInfoAsync(playerId: string, playerToken: number, entityId: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Set entity value (callback version).
* Consumes tokens and then sends a request to set entity value.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity to set the value for.
* @param {boolean} value - The value to set for the entity.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
setEntityValue(playerId: string, playerToken: number, entityId: number, value: boolean, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Set entity value (async version).
* Consumes tokens and then sends a request to set entity value, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity to set the value for.
* @param {boolean} value - The value to set for the entity.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* set entity value (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
setEntityValueAsync(playerId: string, playerToken: number, entityId: number, value: boolean, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Check the subscription status of an entity (Alarm) (callback version).
* Consumes tokens and then sends a request to check if an entity (Alarm) is subscribed.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity (Alarm) to check subscription for.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
checkSubscription(playerId: string, playerToken: number, entityId: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Check the subscription status of an entity (Alarm) (async version).
* Consumes tokens and then sends a request to check if an entity (Alarm) is subscribed, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity (Alarm) to check subscription for.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* check subscription (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
checkSubscriptionAsync(playerId: string, playerToken: number, entityId: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Set the subscription status of an entity (Alarm) (callback version).
* Consumes tokens and then sends a request to set the subscription status for an entity.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity (Alarm) to set the subscription status for.
* @param {boolean} value - The value to set for the subscription.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
setSubscription(playerId: string, playerToken: number, entityId: number, value: boolean, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Set the subscription status of an entity (Alarm) (async version).
* Consumes tokens and then sends a request to set the subscription status for an entity, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {number} entityId - The ID of the entity (Alarm) to set the subscription status for.
* @param {boolean} value - The value to set for the subscription.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* set subscription (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
setSubscriptionAsync(playerId: string, playerToken: number, entityId: number, value: boolean, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get map markers (callback version).
* Consumes tokens and then sends a request to retrieve server map markers.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getMapMarkers(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get map markers (async version).
* Consumes tokens and then sends a request to retrieve server map markers, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* server map markers (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
getMapMarkersAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Promote a team member to leader (callback version).
* Consumes tokens and then sends a request to promote a specified team member to leader.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} steamId - The steamId of the player to be promoted to leader.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
promoteToLeader(playerId: string, playerToken: number, steamId: string, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Promote a team member to leader (async version).
* Consumes tokens and then sends a request to promote a specified team member to leader, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} steamId - The steamId of the player to be promoted to leader.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* promote to leader (AppResponse), or an
* error if token consumption fails or there
* is an issue with the request.
*/
promoteToLeaderAsync(playerId: string, playerToken: number, steamId: string, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the clan info (callback version).
* Consumes tokens and then sends a request to retrieve clan information.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getClanInfo(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the clan info (async version).
* Consumes tokens and then sends a request to retrieve clan information, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* clan info (AppResponse), or an error if
* token consumption fails or there is an
* issue with the request.
*/
getClanInfoAsync(playerId: string, playerToken: number, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Set clan motd (callback version).
* Consumes tokens and then sends a request to set clan motd.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} message - The message to be set as clan motd.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
setClanMotd(playerId: string, playerToken: number, message: string, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Set clan motd (async version).
* Consumes tokens and then sends a request to set clan motd, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {string} message - The message to be set as clan motd.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
* @param {number} [timeoutMs=10000] - Time (in milliseconds) to wait for a response before timing out.
*
* @returns {Promise<ConsumeTokensError | Error | rpi.AppResponse>} Returns a promise that resolves to the
* set clan motd (AppResponse), or an error
* if token consumption fails or there is an
* issue with the request.
*/
setClanMotdAsync(playerId: string, playerToken: number, message: string, waitForReplenish?: boolean, timeoutMs?: number): Promise<rpi.AppResponse | Error | ConsumeTokensError>;
/**
* Get the clan chat (callback version).
* Consumes tokens and then sends a request to retrieve clan chat.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {CallbackFunction} callback - The callback function that will be executed when a response is received.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before proceeding with the
* request.
*
* @returns {Promise<ConsumeTokensError | Error | void>} Returns an error if token consumption fails or if there is
* an issue sending the request, otherwise returns void.
*/
getClanChat(playerId: string, playerToken: number, callback: CallbackFunction, waitForReplenish?: boolean): Promise<ConsumeTokensError | Error | void>;
/**
* Get the clan chat (async version).
* Consumes tokens and then sends a request to retrieve clan chat, returning a promise.
*
* @param {string} playerId - The steamId of the player making the request.
* @param {number} playerToken - The authentication token of the player making the request.
* @param {boolean} [waitForReplenish=true] - If true, wait until tokens are available before procee