Luigit
repositories / Unfugwart

Unfugwart

Discord caretaker for Abteilung Unfug

owned by admin

readiness.js

Raw
export class ShardReadiness {
  constructor() {
    this.bootstrapped = false;
    this.shards = new Set();
  }

  bootstrap(shardIds) {
    this.bootstrapped = true;
    for (const shardId of shardIds) this.shards.add(shardId);
  }

  ready(shardId) {
    if (!this.bootstrapped) return false;
    this.shards.add(shardId);
    return true;
  }

  resume(shardId) {
    return this.ready(shardId);
  }

  unavailable(shardId) {
    this.shards.delete(shardId);
  }

  has(shardId) {
    return this.shards.has(shardId);
  }
}