@kingsworld/plugin-cron 1.0.6 → 1.0.8
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
@@ -86,18 +86,18 @@ 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 in the CronTask
|
89
|
+
##### What does the `this.info()`, `this.error()`, `this.warn()`, `this.debug()`, and `this.trace()` methods do in the CronTask class?
|
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
|
|
93
93
|
```ts
|
94
94
|
export class PingPong extends CronTask {
|
95
95
|
run() {
|
96
|
-
this.info("Ping Pong! 🏓"); //
|
97
|
-
this.error("Ping Pong! 🏓"); //
|
98
|
-
this.warn("Ping Pong! 🏓"); //
|
99
|
-
this.debug("Ping Pong! 🏓"); //
|
100
|
-
this.trace("Ping Pong! 🏓"); //
|
96
|
+
this.info("Ping Pong! 🏓"); // INFO - CronTask[ping] Ping Pong! 🏓
|
97
|
+
this.error("Ping Pong! 🏓"); // ERROR - CronTask[ping] Ping Pong! 🏓
|
98
|
+
this.warn("Ping Pong! 🏓"); // WARN - CronTask[ping] Ping Pong! 🏓
|
99
|
+
this.debug("Ping Pong! 🏓"); // DEBUG - CronTask[ping] Ping Pong! 🏓
|
100
|
+
this.trace("Ping Pong! 🏓"); // TRACE - CronTask[ping] Ping Pong! 🏓
|
101
101
|
}
|
102
102
|
}
|
103
103
|
```
|
@@ -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.8",
|
5
5
|
"author": "Seren_Modz 21 <seren@kings-world.net>",
|
6
6
|
"license": "MIT",
|
7
7
|
"main": "dist/index.js",
|
@@ -31,12 +31,11 @@
|
|
31
31
|
"esm:default": "gen-esm-wrapper dist/index.js dist/index.mjs"
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
|
-
"cron": "^2.
|
35
|
-
"tslib": "^2.6.
|
34
|
+
"cron": "^2.4.0",
|
35
|
+
"tslib": "^2.6.1"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
-
"@types/
|
39
|
-
"@types/node": "^20.4.2",
|
38
|
+
"@types/node": "^20.4.5",
|
40
39
|
"gen-esm-wrapper": "^1.1.3",
|
41
40
|
"typescript": "^5.1.6"
|
42
41
|
},
|