UNPKG

status-sharding

Version:

Welcome to Status Sharding! This package is designed to provide an efficient and flexible solution for sharding Discord bots, allowing you to scale your bot across multiple processes or workers.

39 lines (38 loc) 1.85 kB
import { PackageType, ValidIfSerializable } from '../types'; /** Sharding utils. */ export declare class ShardingUtils { /** Generates a nonce. */ static generateNonce(): string; /** Chunks an array into smaller arrays. */ static chunkArray<T>(array: T[], chunkSize: number, equalize?: boolean): T[][]; /** Delays for a certain amount of time. */ static delayFor(ms: number): Promise<void>; /** Checks if a value is serializable. */ static isSerializable<T>(value: T): value is T & ValidIfSerializable<T>; /** Removes all non-existing values from an array. */ static removeNonExisting<T>(array: (T | undefined)[]): T[] | undefined; /** Makes an error plain. */ static makePlainError(err: Error): { name: string; message: string; stack: string; }; /** Merges two objects. */ static mergeObjects<T extends object>(main: Partial<T>, toMerge: Partial<T>): T; /** Gets the shard id for a guild id. */ static shardIdForGuildId(guildId: string, totalShards: number): number; /** Gets the cluster id for a shard id. */ static clusterIdForShardId(shardId: string, totalShards: number, totalClusters: number): number; /** Gets the cluster id for a guild id. */ static clusterIdForGuildId(guildId: string, totalShards: number, totalClusters: number): number; /** Gets the cluster id for a shard id. */ static getRecommendedShards(token: string, guildsPerShard?: number, options?: { http: { api: string; version: string; }; }): Promise<number>; static parseInput<T>(input: string | T, context?: unknown, packageType?: PackageType | null, ...args: string[]): string; static boolProp<T extends string>(input: unknown, key: T): T | `not ${T}`; static relativeTime(time?: number): string; }