task() declares a task, from any file of src/, and the name of its export is the name of the task. It takes one object, TaskConfig.
src/tasks/cleanup.ts
How to write a task, and what happens when a run takes long or fails, is in the guide. This page lists what exists.
task()
src/: the name of the export is the name of the task.
TaskDeclaration
Whattask() returns: a declaration the framework finds in the exports of a file.
TaskConfig
What a task file gives totask(): when it runs, and what it does. It is an EveryTaskConfig or a CronTaskConfig: one of every and cron, never both.
Also run once as soon as the bot is connected, without waiting for the first time of the schedule.
EveryTaskConfig
A task that runs every so often.How often the task runs: a number and a unit,
s, m, h or d, like '30s', '10m', '2h', '1d' or '1h30m'. Once per second at most. Counted from when the bot connects.CronTaskConfig
A task that runs at given times.When the task runs, as a cron expression: minute, hour, day of month, month and day of week, like
'0 9 * * 1-5' (9:00 on weekdays). *, lists (1,15), ranges (1-5), steps (*/15) and names (mon, jan) work.TaskContext
Whatrun receives: the bot, as the ready event gives it, and the time.
A task also receives t, in the default language, when the project has a language: see TranslationContext.