Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Master

Master process controller

Hierarchy

  • EventEmitter<{ CLUSTER_STARTED: Cluster; CLUSTER_STOPPED: Cluster; DEBUG: string; READY: Master }>
    • Master

Index

Constructors

constructor

  • Creates a new Master instance

    Parameters

    • fileName: string

      Location of Worker file

    • options: BotOptions

      Options

    Returns Master

Properties

chunks

chunks: number[][] = ...

Chunked Numbers for shards / cluster

fileName

fileName: string

File name to spawn with

handlers

handlers: { emit: any; on: any } = ...

Type declaration

  • emit:function
    • emit<K>(event: K, cluster: Cluster, data: ThreadEvents[K]["send"], resolve: ResolveFunction<K>): boolean
    • Type parameters

      Parameters

      Returns boolean

  • on:function
    • on<K>(event: K, listener: (cluster: Cluster, data: ThreadEvents[K]["send"], resolve: ResolveFunction<K>) => void): any
    • Type parameters

      Parameters

      Returns any

log

log: (msg: string, cluster?: Cluster) => void

Log function

Type declaration

    • (msg: string, cluster?: Cluster): void
    • Log function

      Parameters

      • msg: string
      • Optional cluster: Cluster

      Returns void

options

options: CompleteBotOptions

Options

processes

processes: Collection<string, Cluster> = ...

Process list (including custom processes)

rest

rest: RestManager

session

session: APIGatewaySessionStartLimit

Session data (Set after .start())

sharder

sharder: Sharder = ...

Sharding manager for handling shard ratelimits

spawned

spawned: boolean = false

Whether or not the master has been spawned

Accessors

clusters

  • get clusters(): Collection<string, Cluster>
  • Get all Discord Bot clusters (discludes custom processes)

    Returns Collection<string, Cluster>

Methods

broadcastEval

  • broadcastEval(code: string): Promise<any[]>
  • Evals code on every cluster

    Parameters

    • code: string

      Code to eval

    Returns Promise<any[]>

    An array of responses

debug

  • debug(msg: string): void
  • Parameters

    • msg: string

    Returns void

getStats

  • Gets each clusters stats

    Returns Promise<ClusterStats[]>

    Stats

guildToCluster

  • guildToCluster(guildId: string): Cluster
  • Get a cluster based on the guild that should be cached there

    Parameters

    • guildId: string

      Guild ID

    Returns Cluster

    Cluster guild belongs to

guildToShard

  • guildToShard(guildId: string): number
  • Get the shard that has a certain guild

    Parameters

    • guildId: string

      ID of guild

    Returns number

    ID of shard

sendToAll

  • Sends an event to all clusters

    Type parameters

    Parameters

    • event: K

      Event name

    • data: ThreadEvents[K]["send"]

      Event data

    • all: boolean = false

      Whether or not to send to all processes, including custom ones

    Returns Promise<ThreadEvents[K]["receive"][]>

    The data sent back

shardToCluster

  • shardToCluster(shardId: number): Cluster
  • Convert a shard ID into it's containing cluster

    Parameters

    • shardId: number

      Shard ID to convert to

    Returns Cluster

    The cluster the shard belongs to

spawnProcess

  • spawnProcess(name: string, fileName: string): Cluster
  • Spawns a custom process

    Parameters

    • name: string

      Name of the process (especially for logging)

    • fileName: string

      Direct path for process

    Returns Cluster

    The new Cluster thread created

start

  • start(): Promise<void>
  • Starts the bot and spawns workers

    Returns Promise<void>

tellAll

  • tellAll<K>(event: K, data: ThreadEvents[K]["send"], all?: boolean): any[]
  • Sends a TELL event to all clusters

    Type parameters

    Parameters

    • event: K

      Event name

    • data: ThreadEvents[K]["send"]

      Event data

    • all: boolean = false

      Whether or not to send to all processes, including custom ones

    Returns any[]

    Nothing

Generated using TypeDoc