new ClusterManager
src/clustermanager.ts:60new ClusterManager(file: string, token: string, options?: ClusterManagerOptions)Spawns and supervises child processes, each running a ClusterClient over a range of shards.
import { ClusterManager } from 'detritus-client';new ClusterManager(file: string, token: string, options?: ClusterManagerOptions)_run(options: ClusterManagerRunOptions): Promise<ClusterManager>broadcast(message: any): Promise<any[]>broadcastEval(code: string | Function, nonce?: string, timeout?: number): Promise<any[]>broadcastEvalRaw(
code: string | Function,
nonce?: string,
timeout?: number,
): Promise<[any, boolean][]>getRatelimitKey(shardId: number): numberon(event: string | symbol, listener: (...args: any[]) => void): thisAdds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
server.on('connection', (stream) => {
console.log('someone connected!');
});Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// aThe callback function
on(
event: CLUSTER_PROCESS,
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): thison(
event: "clusterProcess",
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): thisonce(event: string | symbol, listener: (...args: any[]) => void): thisAdds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
server.once('connection', (stream) => {
console.log('Ah, we have our first user!');
});Returns a reference to the EventEmitter, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.once('foo', () => console.log('a'));
myEE.prependOnceListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
// b
// aThe callback function
once(
event: CLUSTER_PROCESS,
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): thisonce(
event: "clusterProcess",
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): thisrespawnAll(options?: ClusterProcessRunOptions): Promise<void>run(options?: ClusterManagerRunOptions): Promise<ClusterManager>subscribe(event: string | symbol, listener: (...args: any[]) => void): EventSubscriptionsubscribe(
event: CLUSTER_PROCESS,
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): EventSubscriptionsubscribe(
event: "clusterProcess",
listener: (payload: { clusterProcess: ClusterProcess }) => any,
): EventSubscription