๐ŸฎCluster Utils

broadcastEval

Executes code simultaneously on all clusters, collecting the results and returning them as an array. It's useful for performing tasks or retrieving information across all or specific clusters.

// client.cluster.broadcastEval('this.guilds.cache.size');
client.cluster.broadcastEval((c) => {
    return c.guilds.cache.size;
});

evalOnGuild

Allows you to evaluate code on a specific guild's shard. This method is useful when you need to perform guild-specific operations or retrieve guild-specific information.

client.cluster.evalOnGuild('guild-id-here', (c, context, guild) => {
    return guild?.channels.cache.get(context.channel).send(context.text);
}, {
    context: {
        text: 'Hello World!',
        channel: 'example-channel-id'
    },
});

evalOnManager

Allows you to evaluate code directly on the manager of a sharded bot. It's useful for performing manager-specific operations or retrieving manager-specific information like cluster informations.

client.cluster.evalOnManager((manager) => {
    return manager.clusters.size;
});

Last updated

Was this helpful?