@kingsworld/plugin-cron 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,7 +10,7 @@ yarn add @kingsworld/plugin-cron @sapphire/framework
10
10
 
11
11
  ## Usage
12
12
 
13
- Make sure to register the plegin before creating the client
13
+ Make sure to register the plugin before creating the client
14
14
 
15
15
  ```ts
16
16
  import "@kingsworld/plugin-cron/register";
@@ -65,7 +65,7 @@ export class PingPong extends CronTask {
65
65
  }
66
66
  ```
67
67
 
68
- Using the command constructor:
68
+ Using the class constructor:
69
69
 
70
70
  ```ts
71
71
  import { CronTask } from "@kingsworld/plugin-cron";
@@ -86,7 +86,7 @@ export class PingPong extends CronTask {
86
86
 
87
87
  ### Frequently Asked Questions
88
88
 
89
- ##### What does the `this.info()`, `this.error()`, `this.warn()`, `this.debug()`, and `this.trace()` methods do instead the CronTask#run() method?
89
+ ##### What does the `this.info()`, `this.error()`, `this.warn()`, `this.debug()`, and `this.trace()` methods do in the CronTask#run() method?
90
90
 
91
91
  These methods are small helpers towards Sapphire's logger that prefixes logs with `CronTask[$name]`. The helpers are optional, however, I find them useful when using them in my own projects.
92
92
 
@@ -1,5 +1,5 @@
1
1
  import { Piece } from "@sapphire/pieces";
2
- import { CronJob } from "cron";
2
+ import type { CronJob } from "cron";
3
3
  import type { CronTaskStore } from "./CronTaskStore";
4
4
  import type { CronJobOptions } from "../types/CronTaskTypes";
5
5
  import type { Awaitable } from "@sapphire/framework";
@@ -14,7 +14,6 @@ export declare abstract class CronTask extends Piece {
14
14
  warn(message: string, ...other: unknown[]): void;
15
15
  debug(message: string, ...other: unknown[]): void;
16
16
  trace(message: string, ...other: unknown[]): void;
17
- unload(): Promise<void>;
18
17
  }
19
18
  export declare namespace CronTask {
20
19
  type Options = Piece.Options & CronJobOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"CronTask.d.ts","sourceRoot":"","sources":["../../../src/l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ACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,8BAAsB,QAAS,SAAQ,KAAK;IAChC,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;gBAEtB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO;IAI7D,QAAQ,CAAC,GAAG,IAAI,SAAS,CAAC,OAAO,CAAC;IAElC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;IAOzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;IAO1C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;IAOzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;IAO1C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE;CAM7C;AAED,yBAAiB,QAAQ,CAAC;IACtB,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;IACrD,KAAY,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;CACvC"}
@@ -2,46 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CronTask = void 0;
4
4
  const pieces_1 = require("@sapphire/pieces");
5
- const cron_1 = require("cron");
6
5
  class CronTask extends pieces_1.Piece {
7
6
  constructor(context, options) {
8
7
  super(context, options);
9
- Object.defineProperty(this, "job", {
10
- enumerable: true,
11
- configurable: true,
12
- writable: true,
13
- value: void 0
14
- });
15
- this.job = new cron_1.CronJob({
16
- ...options,
17
- start: false,
18
- context: this,
19
- onTick: this.run.bind(this),
20
- timeZone: options.timeZone ?? this.container.cron.defaultTimezone,
21
- });
22
8
  }
23
9
  info(message, ...other) {
24
- return this.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);
10
+ this.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);
25
11
  }
26
12
  error(message, ...other) {
27
- return this.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);
13
+ this.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);
28
14
  }
29
15
  warn(message, ...other) {
30
- return this.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);
16
+ this.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);
31
17
  }
32
18
  debug(message, ...other) {
33
- return this.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);
19
+ this.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);
34
20
  }
35
21
  trace(message, ...other) {
36
- return this.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);
37
- }
38
- unload() {
39
- // job is undefined when an error occurrs during the CronJob construction
40
- // it is not typed as optional because it should never be undefined otherwise
41
- if (this.job?.running) {
42
- this.job.stop();
43
- }
44
- return super.unload();
22
+ this.container.logger.trace(`CronTask[${this.name}] ${message}`, ...other);
45
23
  }
46
24
  }
47
25
  exports.CronTask = CronTask;
@@ -1 +1 @@
1
- {"version":3,"file":"CronTask.js","sourceRoot":"","sources":["../../../src/lib/structures/CronTask.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,+BAA+B;AAK/B,MAAsB,QAAS,SAAQ,cAAK;IAMxC,YAAY,OAAsB,EAAE,OAAyB;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAN5B;;;;;WAAa;QAQT,IAAI,CAAC,GAAG,GAAG,IAAI,cAAO,CAAC;YACnB,GAAG,OAAO;YACV,KAAK,EA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C;IACN,CAAC;CACJ;AA7CD,4BA6CC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kingsworld/plugin-cron",
3
3
  "description": "A simple @sapphire/framework plugin that aims to make use of the cron package and allow users to make cron jobs within their Sapphire discord bot.",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "author": "Seren_Modz 21 <seren@kings-world.net>",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",