Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseClusterWorker

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.
}
}

Hierarchy

  • BaseClusterWorker

Index

Constructors

Properties

bot: Client

The Eris client

clusterID: number

ID of the cluster

handleCommand?: (data: any) => any

Type declaration

    • (data: any): any
    • Function to handle commands. Have a function called handleCommand to your cluster class to handle commands.

      see

      BaseClusterWorker See for an example

      Parameters

      • data: any

        Data sent in the command

      Returns any

ipc: IPC
shutdown?: (done: () => void) => void

Type declaration

    • (done: () => void): void
    • 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

workerID: number

ID of the worker

Generated using TypeDoc