UNPKG

nationstates.js

Version:

A wrapper to interact with the NationStates API.

69 lines (68 loc) 2.36 kB
import { API, Client } from "../client"; import { RequestBuilder } from "../request_builder/request_builder"; import { Mode } from "../enums/mode"; import { Category } from "../enums/category"; import { Factbook } from "../enums/factbook"; import { Account } from "../enums/account"; import { Meta } from "../enums/meta"; import { Bulletin } from "../enums/bulletin"; /** * A class to handle creating, editing, and deleting dispatches in more high-level functions. * @example const methods = new Dispatch(api, 'nation', 'password', Mode.add); * @param { client } client The client object to enforce rate limiting and user agents. * @param { string } nation Your nation name without prefixes. Used for authenticating with the NationStates client. * @param { string } password Your password. Used for authenticating with the NationStates client. * @param { Mode } action Enumerator to specify the action to be taken. */ export declare class Dispatch extends RequestBuilder { client: Client; private readonly nation; private readonly password; private readonly action; private result; constructor(client: API | Client, nation: string, password: string, action: Mode); /** * Set the dispatch mode. It can be either: * - 'add' * - 'remove' * - 'edit'<br><br> * See NationStates client documentation for more information. * @param method */ private addAction; /** * Add title to the dispatch. * @param text */ title(text: string): this; /** * Add text to the dispatch. * @param text */ text(text: string): this; /** * Set the category of the dispatch. * @param category */ category(category: Category): this; /** * Set the category of the dispatch. * @param subcategory */ subcategory(subcategory: Factbook | Bulletin | Account | Meta): this; /** * Set the dispatch ID when editing or a removing a dispatch. * @param id */ dispatchID(id: number): this; /** * Obtain the x-pin of a nation. * @private */ private authenticate; /** * Sends command asynchronously according to specifications with mode=prepare and mode=execute. * To check for success, access the returned response attribute. */ execute(): Promise<RequestBuilder>; }