Executor
Reading time:2 min read
The ScheduleExecutor is responsible for the actual execution of a schedule's logic.
It runs the schedule's tick() method, and also:
- Checks the
ScheduleMiddlewareList. - Wraps the execution in a try-catch block.
- Emits events for success or failure.
When to override
| ✅ Override if you want to... | ❌ Don't override if you want to... |
|---|---|
| Customize execution behavior, including middleware injection or error handling. | Only change the middleware chain. Use ScheduleMiddlewareList for that. |
| Instrument executor-owned branches such as success/failure handling. | Only change how errors are consumed. Use ScheduleErrorHandler for that. |
| Implement custom retry/backoff or exception mapping for failed executions. | Change when schedules run. That belongs to ScheduleExecutionScheduler and ScheduleJobAdapter. |
Overriding
Creation
Create a custom executor by either:
- Extending
DefaultScheduleExecutor(recommended, less work). - Implementing
ScheduleExecutor.
import { } from '@nyx-discord/djs';
class extends {}Registration
Create it and set it to the ScheduleManager.
class extends {
/** Your overrides */
}
.().(.());The DefaultScheduleExecutor.create() method instantiates your custom executor, not the default one.
Dependencies
The executor has two core dependencies you can customize:
Edit on GitHub
Last updated on
