Skip to Content
nyx logonyx guide

Manager

See in:
DefaultScheduleManagerGitHub
ScheduleManagerGitHub
Reading time:2 min read

The ScheduleManager is the object that holds together the nyx schedule system. At a glance:

  • Registration flow: when adding a schedule, stores it in the repository and then starts its runtime job in the scheduler.
  • Failure safety: if schedule registration fails midway, rolls back repository state and scheduler job creation to stay consistent.
  • Execution boundary: tick resolves a schedule by ID and executes it through the executor with populated metadata.
  • Schedule events: emits manager-level ScheduleAdd/ScheduleRemove events and supports subscriptions for schedule lifecycle reactions.

In practice, this makes it the boundary where schedule persistence, job lifecycle, execution, and manager events are coordinated.

Overriding

Creation

Create a custom schedule manager by either:

import {  } from '@nyx-discord/djs';

class  extends  {
  public () {
    return 'I work!' as ;
  }
}

Registration

Then you can pass it to your bot:

import { , type  } from '@nyx-discord/djs';

const  = .((: ) => ({
  // ... other options
  : new (/** ... */),
}));

const  = .();
const result = .();
const result: "I work!"

The class is able to infer the type of your custom manager, so accessing any custom method or property will work without errors.

If you ever want to use this custom bot type with your injected manager somewhere else, you can do so via the generic:

import type { ,  } from '@nyx-discord/djs';

type  = < & { :  }>;

function (: ) {
  const  = .();
  const result = .();
const result: "I work!"
}

For readability purposes, we recommend storing the type with the generic in a separate type, like in the example.

Edit on GitHub

Last updated on

On this page