@kingsworld/plugin-cron 1.0.6 → 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.
@@ -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/lib/structures/CronTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"CronTask.d.ts","sourceRoot":"","sources":["../../../src/lib/structures/CronTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,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
|
-
|
10
|
+
this.container.logger.info(`CronTask[${this.name}] ${message}`, ...other);
|
25
11
|
}
|
26
12
|
error(message, ...other) {
|
27
|
-
|
13
|
+
this.container.logger.error(`CronTask[${this.name}] ${message}`, ...other);
|
28
14
|
}
|
29
15
|
warn(message, ...other) {
|
30
|
-
|
16
|
+
this.container.logger.warn(`CronTask[${this.name}] ${message}`, ...other);
|
31
17
|
}
|
32
18
|
debug(message, ...other) {
|
33
|
-
|
19
|
+
this.container.logger.debug(`CronTask[${this.name}] ${message}`, ...other);
|
34
20
|
}
|
35
21
|
trace(message, ...other) {
|
36
|
-
|
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;
|
1
|
+
{"version":3,"file":"CronTask.js","sourceRoot":"","sources":["../../../src/lib/structures/CronTask.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAMzC,MAAsB,QAAS,SAAQ,cAAK;IAKxC,YAAY,OAAsB,EAAE,OAAyB;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;IAID,IAAI,CAAC,OAAe,EAAE,GAAG,KAAgB;QACrC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CACtB,YAAY,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,EACnC,GAAG,KAAK,CACX,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,KAAgB;QACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CACvB,YAAY,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,EACnC,GAAG,KAAK,CACX,CAAC;IACN,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,KAAgB;QACrC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CACtB,YAAY,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,EACnC,GAAG,KAAK,CACX,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,KAAgB;QACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CACvB,YAAY,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,EACnC,GAAG,KAAK,CACX,CAAC;IACN,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,KAAgB;QACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CACvB,YAAY,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,EACnC,GAAG,KAAK,CACX,CAAC;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.
|
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",
|