Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Schedule

Schedule is a singleton, use {@link KlasaClient#schedule} instead. The Schedule class that manages all scheduled tasks

Hierarchy

  • Schedule

Index

Constructors

constructor

Properties

Private #interval

#interval: Timer | null = null

The current interval that runs the tasks

since

0.5.0

client

client: Client

The Client instance that initialized this instance

since

0.5.0

tasks

tasks: ScheduledTask[] = []

An array of all processed ScheduledTask instances

since

0.5.0

Accessors

Protected _tasks

Methods

[Symbol.iterator]

Private _add

Private _checkInterval

  • _checkInterval(): void

Private _clearInterval

  • _clearInterval(): void

Protected _insert

clear

  • clear(): Promise<void>

create

  • Adds a new task to the database

    since

    0.5.0

    example

    // Create a new reminder that ends in 2018-03-09T12:30:00.000Z (UTC) Schedule.create('reminder', new Date(Date.UTC(2018, 2, 9, 12, 30)), { data: { user: '242043489611808769', db_id: 'jbifpb4f' } });

    // Create a scheduled task that runs once a week Schedule.create('backup', '@weekly');

    // Or even, a weekly backup on Tuesday and Friday that fires at 00:00 (UTC) Schedule.create('backup', '0 0 * * tue,fri');

    // NOTE: It's highly advised ScheduledTaskOptions.data to be a small object or string, // as it being larger can cause a slowdown and memory increase. You can, however, have // a table in your database and query it by its entry id from the Task instance.

    see

    https://en.wikipedia.org/wiki/Cron For more details

    Parameters

    • taskName: string

      The name of the task

    • time: Date | number | string

      The time or Cron pattern

    • Optional options: ScheduledTaskOptions

      The options for the ScheduleTask instance

    Returns Promise<ScheduledTask | null>

delete

  • delete(id: string): Promise<this>

Protected execute

  • execute(): Promise<void>

get

init

  • init(): Promise<void>

next

Generated using TypeDoc