dexare
Version:
Modular and extendable Discord bot framework
70 lines (69 loc) • 2.45 kB
TypeScript
import DexareClient from './client';
import { ClientEvent } from './client/events';
import { ThrottlingOptions } from './modules/commands/command';
import LoggerHandler from './util/logger';
/** Options for the {@link DataManager}. */
export interface DataManagerOptions {
/** The name of the manager. */
name: string;
/** The description of the manager. */
description?: string;
}
/** The throttle result of {@link DataManager#throttleCommand} */
export interface ThrottleResult {
okay: boolean;
reset?: number;
usesLeft?: number;
}
/** @private */
export interface ThrottleObject {
reset: number;
uses: number;
}
/** A data manager for Dexare. */
export default class DataManager {
/** The options for this manager. */
readonly options: DataManagerOptions;
/** The logger for the manager. */
readonly logger: LoggerHandler<DexareClient<any>>;
/** The Dexare client for this manager. */
readonly client: DexareClient<any>;
/**
* The file path of the manager.
* Set this to `__filename` in the constructor.
*/
filePath?: string;
constructor(client: DexareClient<any>, options: DataManagerOptions);
/** Fired when the manager is signaled to start. */
start(): Promise<void>;
/** Fired when the manager is signaled to stop. */
stop(): Promise<void>;
/**
* Gets the throttle result from an ID and scope.
* @param scope The scope of the throttles
* @param id The ID of the throttle
* @returns The Throttle result, if any
*/
getThrottle(scope: string, id: string): Promise<ThrottleObject | void>;
/**
* Sets the throttle result to an ID and scope.
* @param scope The scope of the throttles
* @param id The ID of the throttle
* @param object The throttle to set
*/
setThrottle(scope: string, id: string, object: ThrottleObject): Promise<void>;
/**
* Removes a throttle object.
* @param scope The scope of the throttles
* @param id The ID of the throttle
*/
removeThrottle(scope: string, id: string): Promise<void>;
/**
* Throttles something.
* @param scope The group to put the throttle in
* @param opts The throttling options to use
* @param id The identifier of the throttle
* @param event The event to use
*/
throttle(scope: string, opts: ThrottlingOptions, id: string, event?: ClientEvent): Promise<ThrottleResult>;
}