import { ClusterClient, ClusterManager, DjsDiscordClient } from "../"; export interface AutoResharderSendData { clusterId: number; shardData: { shardId: number; guildCount: number; }[]; } interface AutoResharderClusterClientOptions { /** * How often to send the data (the faster the bot grows, the more often you should send the data) * @default 60e3 */ sendDataIntervalMS: number; /** * Function to send the required Data for the AUTORESHARDING * @param cluster * @returns sendData can be either sync or async * * @example * ```ts * sendDataFunction: (cluster:ClusterClient) => { * return { * clusterId: cluster.id, * shardData: cluster.info.SHARD_LIST.map(shardId => ({ shardId, guildCount: cluster.client.guilds.cache.filter(g => g.shardId === shardId).size })) * } * } * ``` */ sendDataFunction: (cluster: ClusterClient) => Promise | AutoResharderSendData; debug?: boolean; } interface AutoResharderManagerOptions { /** * How many shards to be set per cluster */ ShardsPerCluster: number | 'useManagerOption'; /** * This Number declares how many new shards should spawn. * if set to 1500 it aims to create as many shards that on avg. per shard 1500 guilds are set * If set to "auto" it uses the recommendation amount of discord-gateway. * If set to "auto" then MaxGuildsPerShard must be at least 2000 */ MinGuildsPerShard: 'auto' | number; /** If this number is reached, autoresharding starts */ MaxGuildsPerShard: number; /** Restart Options for reclustering */ restartOptions?: { /** The restartMode of the clusterManager, gracefulSwitch = waits until all new clusters have spawned with maintenance mode, rolling = Once the Cluster is Ready, the old cluster will be killed */ restartMode?: 'gracefulSwitch' | 'rolling'; /** The delay to wait between each cluster spawn */ delay?: number; /** The readyTimeout to wait until the cluster spawn promise is rejected */ timeout?: number; }; debug?: boolean; } export declare class AutoResharderClusterClient { private clusterClient; /** The Options of the AutoResharderClusterClient */ private options; /** The Stored Interval */ private interval; /** Wether it is running or not */ private started; /** * The Cluster client and what it shold contain * @param {ClusterClient} clusterClient * @param {Partial} [options] the Optional options * @param {(cluster:ClusterClient) => Promise | AutoResharderSendData} options.sendDataFunction Get the relevant data (custom function if you don't use smt like djs, then provide it!) * @example * ```ts * client.cluster = new ClusterManager(client); * new AutoResharderClusterClient(client.cluster, { * // optional. Default is 60e3 which sends every minute the data / cluster * sendDataIntervalMS: 60e3, * // optional. Default is a valid function for discord.js Client's * sendDataFunction: (cluster:ClusterClient) => { * return { * clusterId: cluster.id, * shardData: cluster.info.SHARD_LIST.map(shardId => ({ shardId, guildCount: cluster.client.guilds.cache.filter(g => g.shardId === shardId).size })) * } * } * }); * ``` */ constructor(clusterClient: ClusterClient, options?: Partial); private validate; /** * Stops the Function and interval * @returns */ stop(): boolean; /** * Start it manually after you stopped it (on initialization it automatically starts the function) * @param newOptions * @param executeSendData Wether it should send the data immediately or as normal: after the interval is reached. * @returns */ start(newOptions?: Partial, executeSendData?: boolean): Promise; /** * Restart the function and interval, if needed * @param newOptions Optinally change the options to your new options * @param executeSendData Wether it should send the data immediately or as normal: after the interval is reached. * @returns */ reStart(newOptions?: Partial, executeSendData?: boolean): Promise; /** * Initializes the interval * @param executeSendData Wether it should send the data immediately or as normal: after the interval is reached. * @returns */ private initialize; private sendData; } export declare class AutoResharderManager { name: 'autoresharder'; private manager?; clusterDatas: AutoResharderSendData[]; options: AutoResharderManagerOptions; isReClustering: boolean; /** * @param options The options when to reshard etc. * @example * * ```ts * manager.extend(new AutoResharderManager({ * ShardsPerCluster: 'useManagerOption', * MinGuildsPerShard: 1500, * MaxGuildsPerShard: 2400, * restartOptions: { * restartMode: 'gracefulSwitch', * delay: 7e3, * timeout: -1, * }, * debug: true, * })) * ``` */ constructor(options?: Partial); build(manager: ClusterManager): this; checkReCluster(): Promise; getData(clusterData: AutoResharderSendData): void; private initialize; private validate; } export {}; //# sourceMappingURL=AutoResharderSystem.d.ts.map