Class BaseClusterWorker<LibClient, LibLatencyRef>

The base class for a cluster

Example

const { BaseClusterWorker } = require('eris-fleet');

module.exports = class BotWorker extends BaseClusterWorker {
constructor(setup) {
// Do not delete this super.
super(setup);

this.bot.on('messageCreate', this.handleMessage.bind(this));

// Demonstration of the properties the cluster has (Keep reading for info on IPC):
// ID of the worker
this.ipc.log(this.workerID);
// The ID of the cluster
this.ipc.log(this.clusterID);
}
async handleMessage(msg) {
if (msg.content === "!ping" && !msg.author.bot) {
this.bot.createMessage(msg.channel.id, "Pong!");
}
}
handleCommand(dataSentInCommand) {
// Optional function to return data from this cluster when requested
return "hello!"
}
shutdown(done) {
// Optional function to gracefully shutdown things if you need to.
done(); // Use this function when you are done gracefully shutting down.
}
}

Type Parameters

  • LibClient

  • LibLatencyRef

Hierarchy

  • BaseClusterWorker

Constructors

Properties

Methods

Constructors

Properties

bot: LibClient

The Eris client

clusterID: number

ID of the cluster

ipc: IPC<LibLatencyRef>
workerID: number

ID of the worker

Methods

  • Graceful shutdown of the cluster. Have a function within your bot class called shutdown to use this.

    See

    BaseClusterWorker See for an example

    Parameters

    • done: (() => void)

      Call this function when your shutdown function is complete.

        • (): void
        • Returns void

    Returns void

Generated using TypeDoc