© 2026 Hedgehog Software, LLC
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks'; export class IntervalTask extends ScheduledTask { public constructor(context: ScheduledTask.LoaderContext, options: ScheduledTask.Options) { super(context, { ...options, interval: 60_000 // 60 seconds }); } public async run() { this.container.logger.info('I run every minute'); } } declare module '@sapphire/plugin-scheduled-tasks' { interface ScheduledTasks { interval: never; } }
import { Listener } from '@sapphire/framework'; import { ScheduledTask, ScheduledTaskEvents, ScheduledTaskOptions } from '@sapphire/plugin-scheduled-tasks'; export class ScheduledTaskSuccessListener extends Listener<typeof ScheduledTaskEvents.ScheduledTaskSuccess> { public constructor(context: Listener.LoaderContext, options: Listener.Options) { super(context, { event: ScheduledTaskEvents.ScheduledTaskSuccess, once: false }); } public async run(task: ScheduledTask<"interval", ScheduledTaskOptions>): Promise<void> { this.container.logger.info(`Scheduled task "${task}" completed successfully.`); } }
Join the Discord to ask follow-up questions and connect with the community
Sapphire is a next-gen object-oriented Discord.js bot framework.
2,286 Members