️💼 Schedule Manager
The ScheduleManager is the object that holds together the nyx schedule system.
It consists of:
ScheduleExecutionSchedulerfor tracking the execution of schedules.ScheduleRepositoryfor storing schedules.ScheduleExecutorfor executing schedules.EventBusfor emitting schedule related events.
As well as methods to interact with them.
👷 Creation
You can create a custom schedule manager by either:
- Extending
DefaultScheduleManagerfrom@nyx-discord/framework(recommended). - Implementing
ScheduleManagerfrom@nyx-discord/core.
Then you can pass it to your bot:
class MyScheduleManager extends DefaultScheduleManager {
public myCustomPublicMethod() {}
}
const myBot = Bot.create((bot: NyxBot) => ({
// ...
schedules: new MyScheduleManager(/** ... */),
}));
myBot.getScheduleManager().myCustomPublicMethod() // works!
The Bot class is able to infer the type of your custom manager via generics, so accessing any custom public method or
property will work without errors.