Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ScheduledTask

The structure for future tasks to be run

Hierarchy

  • ScheduledTask

Index

Constructors

constructor

Properties

Private #running

#running: boolean = false

If the ScheduledTask is being run currently

since

0.5.0

catchUp

catchUp: boolean

If the task should catch up in the event the bot is down

since

0.5.0

client

client: Client

The Client instance that initialized this instance

since

0.5.0

data

data: Record<PropertyKey, unknown>

The stored metadata to send to the Task

since

0.5.0

id

id: string

The id for this scheduled task

since

0.5.0

recurring

recurring: Cron | null

Whether this scheduled task is scheduled with the {@link Cron} pattern

since

0.5.0

taskName

taskName: string

The name of the Task this scheduled task will run

since

0.5.0

time

time: Date

The Date when this scheduled task ends

since

0.5.0

Accessors

store

task

  • get task(): Task | null

Methods

delete

run

  • run(): Promise<this>

toJSON

update

  • update(__namedParameters?: { catchUp: undefined | false | true; data: undefined | {}; time: undefined | string | number | Cron | Date }): Promise<this>
  • Update the task

    since

    0.5.0

    example

    // Update the data from the current scheduled task. Let's say I want to change the reminder content to remind me // another thing ScheduledTask.update({ data: { content: 'Woo! I edited this reminder's content!' } });

    // But you can also update the time this will end at, for example, to change it so it ends in 1 hour: ScheduledTask.update({ time: Date.now() + 60000 * 60 });

    Parameters

    • Default value __namedParameters: { catchUp: undefined | false | true; data: undefined | {}; time: undefined | string | number | Cron | Date } = {}
      • catchUp: undefined | false | true
      • data: undefined | {}
      • time: undefined | string | number | Cron | Date

    Returns Promise<this>

Static Private _generateID

  • _generateID(client: Client): string

Static Private _resolveTime

Static Private _validate

Generated using TypeDoc