For the complete documentation index, see llms.txt. This page is also available as Markdown.

Schedules

This page explains how to create your own schedules for your AthenaBot plugin.


1. Setting up the schedule file

  1. Copy the schedule template.

const scheduledTask = require('../../../../main/discord/core/schedule/schedule.js');

module.exports = class loop extends scheduledTask {
  constructor(heart) {
    super(heart, 'loop', { repeat: true, interval: 60000 });
  }

  execute() {
    this.heart.core.console.log(this.heart.core.console.type.log, '60 seconds have passed since the last time :-:');
  }
};
  1. Create a new schedule file inside your /plugins/<plugin_name>/src/schedules/ directory.

  2. The name of the file must follow the format <schedule_name>.js.

Parameters

  • 'loop': A unique identifier for the schedule.

  • repeat: Defines whether the file should be executed repeatedly every <interval> milliseconds, or only once after <interval> milliseconds.

  • interval: The time in milliseconds between each execution.


2. Schedule response

Schedules are used to handle tasks that occur repeatedly. A common example is unmutes.

When a user is muted, the mute duration and punishment date are stored in the user database. The bot then loads all documents of currently muted users and, at each interval check, determines whether the mute has expired. If so, it automatically executes the unmute function.

For an example, see the unmute schedule from Athena’s source code:


3. Additional information

Last updated