@kingsworld/plugin-cron 2.1.1-next.fab1c9f → 2.1.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@kingsworld/plugin-cron@2.1.1](https://github.com/Kings-World/sapphire-plugins/compare/@kingsworld/plugin-cron@2.1.0...@kingsworld/plugin-cron@2.1.1) - (2025-04-05)
6
+
7
+ ## 🐛 Bug Fixes
8
+
9
+ - **deps:** Update all non-major dependencies ([83f972e](https://github.com/Kings-World/sapphire-plugins/commit/83f972eda0f3db62cfab8916e5c444abc0247e10)) ([#97](https://github.com/Kings-World/sapphire-plugins/pull/97) by @renovate[bot])
10
+ - **deps:** Update dependency cron to v4 ([1550eff](https://github.com/Kings-World/sapphire-plugins/commit/1550eff0705e5430281291aeb0fe18a830186915)) ([#91](https://github.com/Kings-World/sapphire-plugins/pull/91) by @renovate[bot])
11
+ - **deps:** Update all non-major dependencies ([d5bd44f](https://github.com/Kings-World/sapphire-plugins/commit/d5bd44fbbe46d8aaa92b6157dccb9536debc66a0)) ([#80](https://github.com/Kings-World/sapphire-plugins/pull/80) by @renovate[bot])
12
+ - **deps:** Update all non-major dependencies ([fab1c9f](https://github.com/Kings-World/sapphire-plugins/commit/fab1c9f661175bc9c2fdfc7d9ab3af59d16acc6f)) ([#79](https://github.com/Kings-World/sapphire-plugins/pull/79) by @renovate[bot])
13
+ - **deps:** Update all non-major dependencies ([e44b9ef](https://github.com/Kings-World/sapphire-plugins/commit/e44b9efa5b164699dd4393188c38e6f3fdadcc3e)) ([#75](https://github.com/Kings-World/sapphire-plugins/pull/75) by @renovate[bot])
14
+
5
15
  # [@kingsworld/plugin-cron@2.1.0](https://github.com/Kings-World/sapphire-plugins/compare/@kingsworld/plugin-cron@2.0.3...@kingsworld/plugin-cron@2.1.0) - (2024-10-03)
6
16
 
7
17
  ## 🚀 Features
@@ -6,7 +6,7 @@ var CronTaskStore_cjs = require('./lib/structures/CronTaskStore.cjs');
6
6
  var CronTaskTypes_cjs = require('./lib/types/CronTaskTypes.cjs');
7
7
 
8
8
  // src/index.ts
9
- var version = "2.1.1-next.fab1c9f";
9
+ var version = "2.1.1";
10
10
 
11
11
  exports.version = version;
12
12
  Object.keys(CronTaskHandler_cjs).forEach(function (k) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AA+BO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcron: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcron?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '2.1.1-next.fab1c9f';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AA+BO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcron: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcron?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '2.1.1';\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Piece, Store } from '@sapphire/pieces';
2
2
  import { Awaitable } from '@sapphire/framework';
3
- import { CronJobParams, CronJob } from 'cron';
3
+ import { CronJob, CronJobParams } from 'cron';
4
4
  import Sentry from '@sentry/node';
5
5
 
6
6
  interface CronTaskHandlerOptions {
@@ -195,4 +195,5 @@ declare module 'discord.js' {
195
195
  */
196
196
  declare const version: string;
197
197
 
198
- export { type CronJobOptions, CronTask, CronTaskHandler, type CronTaskHandlerOptions, CronTaskStore, version };
198
+ export { CronTask, CronTaskHandler, CronTaskStore, version };
199
+ export type { CronJobOptions, CronTaskHandlerOptions };
@@ -30,7 +30,7 @@ var _CronTaskStore = class _CronTaskStore extends pieces.Store {
30
30
  */
31
31
  stopAll() {
32
32
  for (const task of this.values()) {
33
- if (!task.job.running) continue;
33
+ if (!task.job.isActive) continue;
34
34
  task.job.stop();
35
35
  }
36
36
  pieces.Store.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);
@@ -56,7 +56,7 @@ var _CronTaskStore = class _CronTaskStore extends pieces.Store {
56
56
  }
57
57
  delete(key) {
58
58
  const task = this.get(key);
59
- if (task?.job.running) {
59
+ if (task?.job.isActive) {
60
60
  task.job.stop();
61
61
  }
62
62
  return super.delete(key);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"names":["Store","CronTask","CronJob","Info","DateTime","FixedOffsetZone"],"mappings":";;;;;;;;;AAKO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAsBA,YAA8B,CAAA;AAAA,EACzD,WAAc,GAAA;AACpB,IAAA,KAAA,CAAMC,qBAAU,EAAA,EAAE,IAAM,EAAA,YAAA,EAAc,CAAA;AAAA;AACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAW,GAAA;AACjB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,EAAU,EAAA;AACjC,MAAI,IAAA,CAAC,KAAK,OAAS,EAAA;AACnB,MAAA,IAAA,CAAK,IAAI,KAAM,EAAA;AAAA;AAGhB,IAAAD,YAAA,CAAM,MAAS,GAAA,CAAA,UAAA,EAAa,IAAK,CAAA,IAAI,CAAsC,oCAAA,CAAA,CAAA;AAC3E,IAAO,OAAA,IAAA;AAAA;AACR;AAAA;AAAA;AAAA;AAAA,EAMO,OAAU,GAAA;AAChB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,EAAU,EAAA;AACjC,MAAI,IAAA,CAAC,IAAK,CAAA,GAAA,CAAI,OAAS,EAAA;AACvB,MAAA,IAAA,CAAK,IAAI,IAAK,EAAA;AAAA;AAGf,IAAAA,YAAA,CAAM,MAAS,GAAA,CAAA,UAAA,EAAa,IAAK,CAAA,IAAI,CAAqC,mCAAA,CAAA,CAAA;AAC1E,IAAO,OAAA,IAAA;AAAA;AACR,EAEgB,GAAA,CAAI,KAAa,KAAuB,EAAA;AACvD,IAAM,MAAA,EAAE,SAAY,GAAA,KAAA;AAEpB,IAAA,MAAM,EAAE,MAAA,EAAQ,eAAgB,EAAA,GAAI,KAAK,SAAU,CAAA,IAAA;AACnD,IAAA,MAAM,UAAU,MAAS,GAAA,MAAA,CAAO,KAAK,cAAe,CAA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,OAAO,IAAK,CAAA,QAAA;AAGjD,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEd,CAAA;AA7FiE,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAA1D,IAAM,aAAN,GAAA","file":"CronTaskStore.cjs","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { CronJob } from 'cron';\nimport { CronTask } from './CronTask';\nimport { Info, DateTime, FixedOffsetZone, type Zone } from 'luxon';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and starts those that are enabled.\n\t * This gets called automatically when the Client is ready.\n\t * @returns CronTaskStore\n\t */\n\tpublic startAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled) continue;\n\t\t\ttask.job.start();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [START] Started all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.job.running) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { options } = value;\n\n\t\tconst { sentry, defaultTimezone } = this.container.cron;\n\t\tconst cronJob = sentry ? sentry.cron.instrumentCron(CronJob, key) : CronJob;\n\n\t\ttry {\n\t\t\tvalue.job = cronJob.from({\n\t\t\t\t...options,\n\t\t\t\tonTick: () => void value.run.bind(value)(),\n\t\t\t\tstart: false,\n\t\t\t\tcontext: value,\n\t\t\t\ttimeZone: this.formatLuxonZone(options.timeZone ?? defaultTimezone)\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task?.job.running) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t * @returns void\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n\n\t/**\n\t * Formats a Luxon-compatible timezone string into a TZ timezone string.\n\t * This is required because Sentry requires time zones to be in TZ format.\n\t * @param timezone The Luxon-compatible timezone to format.\n\t * @returns The formatted TZ timezone.\n\t * @private\n\t */\n\tprivate formatLuxonZone(timezone?: string | Zone | number) {\n\t\tconst zone = Info.normalizeZone(timezone);\n\n\t\t// If the zone is invalid, return the system zone\n\t\tif (!zone.isValid) return DateTime.local().zoneName;\n\n\t\t// If the zone is a fixed offset zone, return the IANA name\n\t\tif (zone instanceof FixedOffsetZone) return zone.ianaName;\n\n\t\t// Otherwise, return the zone name\n\t\treturn zone.name;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"names":["Store","CronTask","CronJob","Info","DateTime","FixedOffsetZone"],"mappings":";;;;;;;;;AAKO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAsBA,YAA8B,CAAA;AAAA,EACzD,WAAc,GAAA;AACpB,IAAA,KAAA,CAAMC,qBAAU,EAAA,EAAE,IAAM,EAAA,YAAA,EAAc,CAAA;AAAA;AACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAW,GAAA;AACjB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,EAAU,EAAA;AACjC,MAAI,IAAA,CAAC,KAAK,OAAS,EAAA;AACnB,MAAA,IAAA,CAAK,IAAI,KAAM,EAAA;AAAA;AAGhB,IAAAD,YAAA,CAAM,MAAS,GAAA,CAAA,UAAA,EAAa,IAAK,CAAA,IAAI,CAA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GAAa,EAAA;AACnC,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA;AACzB,IAAI,IAAA,IAAA,EAAM,IAAI,QAAU,EAAA;AACvB,MAAA,IAAA,CAAK,IAAI,IAAK,EAAA;AAAA;AAGf,IAAO,OAAA,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA;AACxB;AAAA;AAAA;AAAA;AAAA,EAMgB,KAAQ,GAAA;AACvB,IAAA,IAAA,CAAK,OAAQ,EAAA;AACb,IAAA,OAAO,MAAM,KAAM,EAAA;AAAA;AACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,gBAAgB,QAAmC,EAAA;AAC1D,IAAM,MAAA,IAAA,GAAOC,UAAK,CAAA,aAAA,CAAc,QAAQ,CAAA;AAGxC,IAAA,IAAI,CAAC,IAAK,CAAA,OAAA,EAAgB,OAAAC,cAAA,CAAS,OAAQ,CAAA,QAAA;AAG3C,IAAI,IAAA,IAAA,YAAgBC,qBAAiB,EAAA,OAAO,IAAK,CAAA,QAAA;AAGjD,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEd,CAAA;AA7FiE,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAA1D,IAAM,aAAN,GAAA","file":"CronTaskStore.cjs","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { CronJob } from 'cron';\nimport { CronTask } from './CronTask';\nimport { Info, DateTime, FixedOffsetZone, type Zone } from 'luxon';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and starts those that are enabled.\n\t * This gets called automatically when the Client is ready.\n\t * @returns CronTaskStore\n\t */\n\tpublic startAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled) continue;\n\t\t\ttask.job.start();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [START] Started all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.job.isActive) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { options } = value;\n\n\t\tconst { sentry, defaultTimezone } = this.container.cron;\n\t\tconst cronJob = sentry ? sentry.cron.instrumentCron(CronJob, key) : CronJob;\n\n\t\ttry {\n\t\t\tvalue.job = cronJob.from({\n\t\t\t\t...options,\n\t\t\t\tonTick: () => void value.run.bind(value)(),\n\t\t\t\tstart: false,\n\t\t\t\tcontext: value,\n\t\t\t\ttimeZone: this.formatLuxonZone(options.timeZone ?? defaultTimezone)\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task?.job.isActive) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t * @returns void\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n\n\t/**\n\t * Formats a Luxon-compatible timezone string into a TZ timezone string.\n\t * This is required because Sentry requires time zones to be in TZ format.\n\t * @param timezone The Luxon-compatible timezone to format.\n\t * @returns The formatted TZ timezone.\n\t * @private\n\t */\n\tprivate formatLuxonZone(timezone?: string | Zone | number) {\n\t\tconst zone = Info.normalizeZone(timezone);\n\n\t\t// If the zone is invalid, return the system zone\n\t\tif (!zone.isValid) return DateTime.local().zoneName;\n\n\t\t// If the zone is a fixed offset zone, return the IANA name\n\t\tif (zone instanceof FixedOffsetZone) return zone.ianaName;\n\n\t\t// Otherwise, return the zone name\n\t\treturn zone.name;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/register.ts"],"names":["Plugin","preGenericsInitialization","container","CronTaskHandler","postInitialization","CronTaskStore","preLogin","postLogin","SapphireClient"],"mappings":";;;;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,gBAAO,CAAA;AAAA,EAC1C,QAAeC,mCAAyB,CAAA,CAAwB,OAAwB,EAAA;AACvF,IAAAC,mBAAA,CAAU,IAAO,GAAA,IAAIC,yBAAgB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA;AAClD,EAEA,QAAeC,4BAAkB,CAAwB,GAAA;AACxD,IAAA,IAAA,CAAK,MAAO,CAAA,QAAA,CAAS,IAAIC,uBAAA,EAAe,CAAA;AAAA;AACzC,EAEA,cAAqBC,kBAAQ,CAAwB,GAAA;AACpD,IAAI,IAAAJ,mBAAA,CAAU,KAAK,aAAe,EAAA;AAClC,IAAUA,mBAAA,CAAA,IAAA,CAAK,SAAS,MAAM,OAAO,cAAc,CAAE,CAAA,KAAA,CAAM,MAAM,KAAS,CAAA,CAAA;AAAA;AAC3E,EAEA,QAAeK,mBAAS,CAAwB,GAAA;AAC/C,IAAAL,mBAAA,CAAU,KAAK,QAAS,EAAA;AAAA;AAE1B,CAAA;AAjB2C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAApC,IAAM,cAAN,GAAA;AAmBPM,wBAAA,CAAe,OAAQ,CAAA,qCAAA,CAAsC,cAAe,CAAAP,mCAAyB,GAAG,qCAAqC,CAAA;AAE7IO,wBAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,cAAe,CAAAJ,4BAAkB,GAAG,8BAA8B,CAAA;AAExHI,wBAAA,CAAe,OAAQ,CAAA,oBAAA,CAAqB,cAAe,CAAAF,kBAAQ,GAAG,oBAAoB,CAAA;AAE1FE,wBAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,cAAe,CAAAD,mBAAS,GAAG,qBAAqB,CAAA","file":"register.cjs","sourcesContent":["import './index';\n\nimport { container, Plugin, postInitialization, postLogin, preGenericsInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { CronTaskHandler, CronTaskStore } from './index';\n\nexport class CronTaskPlugin extends Plugin {\n\tpublic static [preGenericsInitialization](this: SapphireClient, options: ClientOptions) {\n\t\tcontainer.cron = new CronTaskHandler(options.cron);\n\t}\n\n\tpublic static [postInitialization](this: SapphireClient) {\n\t\tthis.stores.register(new CronTaskStore());\n\t}\n\n\tpublic static async [preLogin](this: SapphireClient) {\n\t\tif (container.cron.disableSentry) return;\n\t\tcontainer.cron.sentry = await import('@sentry/node').catch(() => undefined);\n\t}\n\n\tpublic static [postLogin](this: SapphireClient) {\n\t\tcontainer.cron.startAll();\n\t}\n}\n\nSapphireClient.plugins.registerPreGenericsInitializationHook(CronTaskPlugin[preGenericsInitialization], 'Cron-Task-PreGenericsInitialization');\n\nSapphireClient.plugins.registerPostInitializationHook(CronTaskPlugin[postInitialization], 'Cron-Task-PostInitialization');\n\nSapphireClient.plugins.registerPreLoginHook(CronTaskPlugin[preLogin], 'Cron-Task-PreLogin');\n\nSapphireClient.plugins.registerPostLoginHook(CronTaskPlugin[postLogin], 'Cron-Task-PostLogin');\n"]}
1
+ {"version":3,"sources":["../../src/register.ts"],"names":["Plugin","preGenericsInitialization","container","CronTaskHandler","postInitialization","CronTaskStore","preLogin","postLogin","SapphireClient"],"mappings":";;;;;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuBA,gBAAO,CAAA;AAAA,EAC1C,QAAeC,mCAAyB,CAAA,CAAwB,OAAwB,EAAA;AACvF,IAAAC,mBAAA,CAAU,IAAO,GAAA,IAAIC,yBAAgB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA;AAClD,EAEA,QAAeC,4BAAkB,CAAwB,GAAA;AACxD,IAAA,IAAA,CAAK,MAAO,CAAA,QAAA,CAAS,IAAIC,uBAAA,EAAe,CAAA;AAAA;AACzC,EAEA,cAAqBC,kBAAQ,CAAwB,GAAA;AACpD,IAAI,IAAAJ,mBAAA,CAAU,KAAK,aAAe,EAAA;AAClC,IAAUA,mBAAA,CAAA,IAAA,CAAK,SAAS,MAAM,OAAO,cAAc,CAAE,CAAA,KAAA,CAAM,MAAM,MAAS,CAAA;AAAA;AAC3E,EAEA,QAAeK,mBAAS,CAAwB,GAAA;AAC/C,IAAAL,mBAAA,CAAU,KAAK,QAAS,EAAA;AAAA;AAE1B,CAAA;AAjB2C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAApC,IAAM,cAAN,GAAA;AAmBPM,wBAAA,CAAe,OAAQ,CAAA,qCAAA,CAAsC,cAAe,CAAAP,mCAAyB,GAAG,qCAAqC,CAAA;AAE7IO,wBAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,cAAe,CAAAJ,4BAAkB,GAAG,8BAA8B,CAAA;AAExHI,wBAAA,CAAe,OAAQ,CAAA,oBAAA,CAAqB,cAAe,CAAAF,kBAAQ,GAAG,oBAAoB,CAAA;AAE1FE,wBAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,cAAe,CAAAD,mBAAS,GAAG,qBAAqB,CAAA","file":"register.cjs","sourcesContent":["import './index';\n\nimport { container, Plugin, postInitialization, postLogin, preGenericsInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { CronTaskHandler, CronTaskStore } from './index';\n\nexport class CronTaskPlugin extends Plugin {\n\tpublic static [preGenericsInitialization](this: SapphireClient, options: ClientOptions) {\n\t\tcontainer.cron = new CronTaskHandler(options.cron);\n\t}\n\n\tpublic static [postInitialization](this: SapphireClient) {\n\t\tthis.stores.register(new CronTaskStore());\n\t}\n\n\tpublic static async [preLogin](this: SapphireClient) {\n\t\tif (container.cron.disableSentry) return;\n\t\tcontainer.cron.sentry = await import('@sentry/node').catch(() => undefined);\n\t}\n\n\tpublic static [postLogin](this: SapphireClient) {\n\t\tcontainer.cron.startAll();\n\t}\n}\n\nSapphireClient.plugins.registerPreGenericsInitializationHook(CronTaskPlugin[preGenericsInitialization], 'Cron-Task-PreGenericsInitialization');\n\nSapphireClient.plugins.registerPostInitializationHook(CronTaskPlugin[postInitialization], 'Cron-Task-PostInitialization');\n\nSapphireClient.plugins.registerPreLoginHook(CronTaskPlugin[preLogin], 'Cron-Task-PreLogin');\n\nSapphireClient.plugins.registerPostLoginHook(CronTaskPlugin[postLogin], 'Cron-Task-PostLogin');\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Piece, Store } from '@sapphire/pieces';
2
2
  import { Awaitable } from '@sapphire/framework';
3
- import { CronJobParams, CronJob } from 'cron';
3
+ import { CronJob, CronJobParams } from 'cron';
4
4
  import Sentry from '@sentry/node';
5
5
 
6
6
  interface CronTaskHandlerOptions {
@@ -195,4 +195,5 @@ declare module 'discord.js' {
195
195
  */
196
196
  declare const version: string;
197
197
 
198
- export { type CronJobOptions, CronTask, CronTaskHandler, type CronTaskHandlerOptions, CronTaskStore, version };
198
+ export { CronTask, CronTaskHandler, CronTaskStore, version };
199
+ export type { CronJobOptions, CronTaskHandlerOptions };
@@ -4,7 +4,7 @@ export * from './lib/structures/CronTask.mjs';
4
4
  export * from './lib/structures/CronTaskStore.mjs';
5
5
  export * from './lib/types/CronTaskTypes.mjs';
6
6
 
7
- var version = "2.1.1-next.fab1c9f";
7
+ var version = "2.1.1";
8
8
 
9
9
  export { version };
10
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AA+BO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcron: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcron?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '2.1.1-next.fab1c9f';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AA+BO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { CronTaskStore } from './lib/structures/CronTaskStore';\nimport type { CronTaskHandler } from './lib/CronTaskHandler';\nimport type { CronTaskHandlerOptions } from './lib/types/CronTaskTypes';\n\nexport * from './lib/CronTaskHandler';\nexport * from './lib/structures/CronTask';\nexport * from './lib/structures/CronTaskStore';\nexport * from './lib/types/CronTaskTypes';\n\ndeclare module '@sapphire/pieces' {\n\tinterface Container {\n\t\tcron: CronTaskHandler;\n\t}\n\n\tinterface StoreRegistryEntries {\n\t\t'cron-tasks': CronTaskStore;\n\t}\n}\n\ndeclare module 'discord.js' {\n\texport interface ClientOptions {\n\t\tcron?: Partial<CronTaskHandlerOptions>;\n\t}\n}\n\n/**\n * The [@kingsworld/plugin-cron](https://github.com/Kings-World/sapphire-plugins/tree/main/packages/cron) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\nexport const version: string = '2.1.1';\n"]}
@@ -27,7 +27,7 @@ var _CronTaskStore = class _CronTaskStore extends Store {
27
27
  */
28
28
  stopAll() {
29
29
  for (const task of this.values()) {
30
- if (!task.job.running) continue;
30
+ if (!task.job.isActive) continue;
31
31
  task.job.stop();
32
32
  }
33
33
  Store.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);
@@ -53,7 +53,7 @@ var _CronTaskStore = class _CronTaskStore extends Store {
53
53
  }
54
54
  delete(key) {
55
55
  const task = this.get(key);
56
- if (task?.job.running) {
56
+ if (task?.job.isActive) {
57
57
  task.job.stop();
58
58
  }
59
59
  return super.delete(key);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"names":[],"mappings":";;;;;;AAKO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAsB,KAA8B,CAAA;AAAA,EACzD,WAAc,GAAA;AACpB,IAAA,KAAA,CAAM,QAAU,EAAA,EAAE,IAAM,EAAA,YAAA,EAAc,CAAA;AAAA;AACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAW,GAAA;AACjB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,EAAU,EAAA;AACjC,MAAI,IAAA,CAAC,KAAK,OAAS,EAAA;AACnB,MAAA,IAAA,CAAK,IAAI,KAAM,EAAA;AAAA;AAGhB,IAAA,KAAA,CAAM,MAAS,GAAA,CAAA,UAAA,EAAa,IAAK,CAAA,IAAI,CAAsC,oCAAA,CAAA,CAAA;AAC3E,IAAO,OAAA,IAAA;AAAA;AACR;AAAA;AAAA;AAAA;AAAA,EAMO,OAAU,GAAA;AAChB,IAAW,KAAA,MAAA,IAAA,IAAQ,IAAK,CAAA,MAAA,EAAU,EAAA;AACjC,MAAI,IAAA,CAAC,IAAK,CAAA,GAAA,CAAI,OAAS,EAAA;AACvB,MAAA,IAAA,CAAK,IAAI,IAAK,EAAA;AAAA;AAGf,IAAA,KAAA,CAAM,MAAS,GAAA,CAAA,UAAA,EAAa,IAAK,CAAA,IAAI,CAAqC,mCAAA,CAAA,C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;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,gBAAgB,QAAmC,EAAA;AAC1D,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,aAAA,CAAc,QAAQ,CAAA;AAGxC,IAAA,IAAI,CAAC,IAAK,CAAA,OAAA,EAAgB,OAAA,QAAA,CAAS,OAAQ,CAAA,QAAA;AAG3C,IAAI,IAAA,IAAA,YAAgB,eAAiB,EAAA,OAAO,IAAK,CAAA,QAAA;AAGjD,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEd,CAAA;AA7FiE,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAA1D,IAAM,aAAN,GAAA","file":"CronTaskStore.mjs","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { CronJob } from 'cron';\nimport { CronTask } from './CronTask';\nimport { Info, DateTime, FixedOffsetZone, type Zone } from 'luxon';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and starts those that are enabled.\n\t * This gets called automatically when the Client is ready.\n\t * @returns CronTaskStore\n\t */\n\tpublic startAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled) continue;\n\t\t\ttask.job.start();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [START] Started all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.job.running) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { options } = value;\n\n\t\tconst { sentry, defaultTimezone } = this.container.cron;\n\t\tconst cronJob = sentry ? sentry.cron.instrumentCron(CronJob, key) : CronJob;\n\n\t\ttry {\n\t\t\tvalue.job = cronJob.from({\n\t\t\t\t...options,\n\t\t\t\tonTick: () => void value.run.bind(value)(),\n\t\t\t\tstart: false,\n\t\t\t\tcontext: value,\n\t\t\t\ttimeZone: this.formatLuxonZone(options.timeZone ?? defaultTimezone)\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task?.job.running) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t * @returns void\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n\n\t/**\n\t * Formats a Luxon-compatible timezone string into a TZ timezone string.\n\t * This is required because Sentry requires time zones to be in TZ format.\n\t * @param timezone The Luxon-compatible timezone to format.\n\t * @returns The formatted TZ timezone.\n\t * @private\n\t */\n\tprivate formatLuxonZone(timezone?: string | Zone | number) {\n\t\tconst zone = Info.normalizeZone(timezone);\n\n\t\t// If the zone is invalid, return the system zone\n\t\tif (!zone.isValid) return DateTime.local().zoneName;\n\n\t\t// If the zone is a fixed offset zone, return the IANA name\n\t\tif (zone instanceof FixedOffsetZone) return zone.ianaName;\n\n\t\t// Otherwise, return the zone name\n\t\treturn zone.name;\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../../../../src/lib/structures/CronTaskStore.ts"],"names":[],"mappings":";;;;;;AAKO,IAAM,cAAA,GAAN,MAAM,cAAA,SAAsB,KAA8B,CAAA;AAAA,EACzD,WAAc,GAAA;AACpB,IAAA,KAAA,CAAM,QAAU,EAAA,EAAE,IAAM,EAAA,YAAA,EAAc,CAAA;AAAA;AACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,QAAW,GAAA;AACjB,IAAW,KAAA,MA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A,aACO,KAAO,EAAA;AACf,MAAM,KAAA,CAAA,KAAA,CAAM,oDAAoD,KAAK,CAAA;AACrE,MAAA,KAAK,MAAM,MAAO,EAAA;AAAA;AAGnB,IAAO,OAAA,KAAA,CAAM,GAAI,CAAA,GAAA,EAAK,KAAK,CAAA;AAAA;AAC5B,EAEgB,OAAO,GAAa,EAAA;AACnC,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,GAAA,CAAI,GAAG,CAAA;AACzB,IAAI,IAAA,IAAA,EAAM,IAAI,QAAU,EAAA;AACvB,MAAA,IAAA,CAAK,IAAI,IAAK,EAAA;AAAA;AAGf,IAAO,OAAA,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA;AACxB;AAAA;AAAA;AAAA;AAAA,EAMgB,KAAQ,GAAA;AACvB,IAAA,IAAA,CAAK,OAAQ,EAAA;AACb,IAAA,OAAO,MAAM,KAAM,EAAA;AAAA;AACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,gBAAgB,QAAmC,EAAA;AAC1D,IAAM,MAAA,IAAA,GAAO,IAAK,CAAA,aAAA,CAAc,QAAQ,CAAA;AAGxC,IAAA,IAAI,CAAC,IAAK,CAAA,OAAA,EAAgB,OAAA,QAAA,CAAS,OAAQ,CAAA,QAAA;AAG3C,IAAI,IAAA,IAAA,YAAgB,eAAiB,EAAA,OAAO,IAAK,CAAA,QAAA;AAGjD,IAAA,OAAO,IAAK,CAAA,IAAA;AAAA;AAEd,CAAA;AA7FiE,MAAA,CAAA,cAAA,EAAA,eAAA,CAAA;AAA1D,IAAM,aAAN,GAAA","file":"CronTaskStore.mjs","sourcesContent":["import { Store } from '@sapphire/pieces';\nimport { CronJob } from 'cron';\nimport { CronTask } from './CronTask';\nimport { Info, DateTime, FixedOffsetZone, type Zone } from 'luxon';\n\nexport class CronTaskStore extends Store<CronTask, 'cron-tasks'> {\n\tpublic constructor() {\n\t\tsuper(CronTask, { name: 'cron-tasks' });\n\t}\n\n\t/**\n\t * Loops over all tasks and starts those that are enabled.\n\t * This gets called automatically when the Client is ready.\n\t * @returns CronTaskStore\n\t */\n\tpublic startAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.enabled) continue;\n\t\t\ttask.job.start();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [START] Started all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Loops over all tasks and stops those that are running.\n\t * @returns CronTaskStore\n\t */\n\tpublic stopAll() {\n\t\tfor (const task of this.values()) {\n\t\t\tif (!task.job.isActive) continue;\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\tStore.logger?.(`[STORE => ${this.name}] [STOP] Stopped all cronjob tasks.`);\n\t\treturn this;\n\t}\n\n\tpublic override set(key: string, value: CronTask): this {\n\t\tconst { options } = value;\n\n\t\tconst { sentry, defaultTimezone } = this.container.cron;\n\t\tconst cronJob = sentry ? sentry.cron.instrumentCron(CronJob, key) : CronJob;\n\n\t\ttry {\n\t\t\tvalue.job = cronJob.from({\n\t\t\t\t...options,\n\t\t\t\tonTick: () => void value.run.bind(value)(),\n\t\t\t\tstart: false,\n\t\t\t\tcontext: value,\n\t\t\t\ttimeZone: this.formatLuxonZone(options.timeZone ?? defaultTimezone)\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tvalue.error('Encountered an error while creating the cron job', error);\n\t\t\tvoid value.unload();\n\t\t}\n\n\t\treturn super.set(key, value);\n\t}\n\n\tpublic override delete(key: string) {\n\t\tconst task = this.get(key);\n\t\tif (task?.job.isActive) {\n\t\t\ttask.job.stop();\n\t\t}\n\n\t\treturn super.delete(key);\n\t}\n\n\t/**\n\t * Stops all running cron jobs and clears the store.\n\t * @returns void\n\t */\n\tpublic override clear() {\n\t\tthis.stopAll();\n\t\treturn super.clear();\n\t}\n\n\t/**\n\t * Formats a Luxon-compatible timezone string into a TZ timezone string.\n\t * This is required because Sentry requires time zones to be in TZ format.\n\t * @param timezone The Luxon-compatible timezone to format.\n\t * @returns The formatted TZ timezone.\n\t * @private\n\t */\n\tprivate formatLuxonZone(timezone?: string | Zone | number) {\n\t\tconst zone = Info.normalizeZone(timezone);\n\n\t\t// If the zone is invalid, return the system zone\n\t\tif (!zone.isValid) return DateTime.local().zoneName;\n\n\t\t// If the zone is a fixed offset zone, return the IANA name\n\t\tif (zone instanceof FixedOffsetZone) return zone.ianaName;\n\n\t\t// Otherwise, return the zone name\n\t\treturn zone.name;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,MAAO,CAAA;AAAA,EAC1C,QAAe,yBAAyB,CAAA,CAAwB,OAAwB,EAAA;AACvF,IAAA,SAAA,CAAU,IAAO,GAAA,IAAI,eAAgB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA;AAClD,EAEA,QAAe,kBAAkB,CAAwB,GAAA;AACxD,IAAA,IAAA,CAAK,MAAO,CAAA,QAAA,CAAS,IAAI,aAAA,EAAe,CAAA;AAAA;AACzC,EAEA,cAAqB,QAAQ,CAAwB,GAAA;AACpD,IAAI,IAAA,SAAA,CAAU,KAAK,aAAe,EAAA;AAClC,IAAU,SAAA,CAAA,IAAA,CAAK,SAAS,MAAM,OAAO,cAAc,CAAE,CAAA,KAAA,CAAM,MAAM,KAAS,CAAA,CAAA;AAAA;AAC3E,EAEA,QAAe,SAAS,CAAwB,GAAA;AAC/C,IAAA,SAAA,CAAU,KAAK,QAAS,EAAA;AAAA;AAE1B,CAAA;AAjB2C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAApC,IAAM,cAAN,GAAA;AAmBP,cAAA,CAAe,OAAQ,CAAA,qCAAA,CAAsC,cAAe,CAAA,yBAAyB,GAAG,qCAAqC,CAAA;AAE7I,cAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,cAAe,CAAA,kBAAkB,GAAG,8BAA8B,CAAA;AAExH,cAAA,CAAe,OAAQ,CAAA,oBAAA,CAAqB,cAAe,CAAA,QAAQ,GAAG,oBAAoB,CAAA;AAE1F,cAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,cAAe,CAAA,SAAS,GAAG,qBAAqB,CAAA","file":"register.mjs","sourcesContent":["import './index';\n\nimport { container, Plugin, postInitialization, postLogin, preGenericsInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { CronTaskHandler, CronTaskStore } from './index';\n\nexport class CronTaskPlugin extends Plugin {\n\tpublic static [preGenericsInitialization](this: SapphireClient, options: ClientOptions) {\n\t\tcontainer.cron = new CronTaskHandler(options.cron);\n\t}\n\n\tpublic static [postInitialization](this: SapphireClient) {\n\t\tthis.stores.register(new CronTaskStore());\n\t}\n\n\tpublic static async [preLogin](this: SapphireClient) {\n\t\tif (container.cron.disableSentry) return;\n\t\tcontainer.cron.sentry = await import('@sentry/node').catch(() => undefined);\n\t}\n\n\tpublic static [postLogin](this: SapphireClient) {\n\t\tcontainer.cron.startAll();\n\t}\n}\n\nSapphireClient.plugins.registerPreGenericsInitializationHook(CronTaskPlugin[preGenericsInitialization], 'Cron-Task-PreGenericsInitialization');\n\nSapphireClient.plugins.registerPostInitializationHook(CronTaskPlugin[postInitialization], 'Cron-Task-PostInitialization');\n\nSapphireClient.plugins.registerPreLoginHook(CronTaskPlugin[preLogin], 'Cron-Task-PreLogin');\n\nSapphireClient.plugins.registerPostLoginHook(CronTaskPlugin[postLogin], 'Cron-Task-PostLogin');\n"]}
1
+ {"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AAMO,IAAM,eAAA,GAAN,MAAM,eAAA,SAAuB,MAAO,CAAA;AAAA,EAC1C,QAAe,yBAAyB,CAAA,CAAwB,OAAwB,EAAA;AACvF,IAAA,SAAA,CAAU,IAAO,GAAA,IAAI,eAAgB,CAAA,OAAA,CAAQ,IAAI,CAAA;AAAA;AAClD,EAEA,QAAe,kBAAkB,CAAwB,GAAA;AACxD,IAAA,IAAA,CAAK,MAAO,CAAA,QAAA,CAAS,IAAI,aAAA,EAAe,CAAA;AAAA;AACzC,EAEA,cAAqB,QAAQ,CAAwB,GAAA;AACpD,IAAI,IAAA,SAAA,CAAU,KAAK,aAAe,EAAA;AAClC,IAAU,SAAA,CAAA,IAAA,CAAK,SAAS,MAAM,OAAO,cAAc,CAAE,CAAA,KAAA,CAAM,MAAM,MAAS,CAAA;AAAA;AAC3E,EAEA,QAAe,SAAS,CAAwB,GAAA;AAC/C,IAAA,SAAA,CAAU,KAAK,QAAS,EAAA;AAAA;AAE1B,CAAA;AAjB2C,MAAA,CAAA,eAAA,EAAA,gBAAA,CAAA;AAApC,IAAM,cAAN,GAAA;AAmBP,cAAA,CAAe,OAAQ,CAAA,qCAAA,CAAsC,cAAe,CAAA,yBAAyB,GAAG,qCAAqC,CAAA;AAE7I,cAAA,CAAe,OAAQ,CAAA,8BAAA,CAA+B,cAAe,CAAA,kBAAkB,GAAG,8BAA8B,CAAA;AAExH,cAAA,CAAe,OAAQ,CAAA,oBAAA,CAAqB,cAAe,CAAA,QAAQ,GAAG,oBAAoB,CAAA;AAE1F,cAAA,CAAe,OAAQ,CAAA,qBAAA,CAAsB,cAAe,CAAA,SAAS,GAAG,qBAAqB,CAAA","file":"register.mjs","sourcesContent":["import './index';\n\nimport { container, Plugin, postInitialization, postLogin, preGenericsInitialization, preLogin, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { CronTaskHandler, CronTaskStore } from './index';\n\nexport class CronTaskPlugin extends Plugin {\n\tpublic static [preGenericsInitialization](this: SapphireClient, options: ClientOptions) {\n\t\tcontainer.cron = new CronTaskHandler(options.cron);\n\t}\n\n\tpublic static [postInitialization](this: SapphireClient) {\n\t\tthis.stores.register(new CronTaskStore());\n\t}\n\n\tpublic static async [preLogin](this: SapphireClient) {\n\t\tif (container.cron.disableSentry) return;\n\t\tcontainer.cron.sentry = await import('@sentry/node').catch(() => undefined);\n\t}\n\n\tpublic static [postLogin](this: SapphireClient) {\n\t\tcontainer.cron.startAll();\n\t}\n}\n\nSapphireClient.plugins.registerPreGenericsInitializationHook(CronTaskPlugin[preGenericsInitialization], 'Cron-Task-PreGenericsInitialization');\n\nSapphireClient.plugins.registerPostInitializationHook(CronTaskPlugin[postInitialization], 'Cron-Task-PostInitialization');\n\nSapphireClient.plugins.registerPreLoginHook(CronTaskPlugin[preLogin], 'Cron-Task-PreLogin');\n\nSapphireClient.plugins.registerPostLoginHook(CronTaskPlugin[postLogin], 'Cron-Task-PostLogin');\n"]}
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": "2.1.1-next.fab1c9f",
4
+ "version": "2.1.1",
5
5
  "author": "Seren_Modz 21 <seren@kings-world.net>",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.cjs",
@@ -36,7 +36,7 @@
36
36
  "scripts": {
37
37
  "build": "tsup && yarn build:types && yarn build:rename-cjs-register",
38
38
  "build:types": "concurrently \"yarn:build:types:*\"",
39
- "build:types:cjs": "rollup-type-bundler -d dist/cjs -ot .cts",
39
+ "build:types:cjs": "rollup-type-bundler -d dist/cjs --output-typings-file-extension .cts",
40
40
  "build:types:esm": "rollup-type-bundler -d dist/esm -t .mts",
41
41
  "build:types:cleanup": "tsx ../../scripts/clean-register-imports.mts",
42
42
  "build:rename-cjs-register": "tsx ../../scripts/rename-cjs-register.mts",
@@ -46,17 +46,17 @@
46
46
  "check-update": "cliff-jumper --dry-run"
47
47
  },
48
48
  "dependencies": {
49
- "cron": "^3.3.2"
49
+ "cron": "^4.1.3"
50
50
  },
51
51
  "devDependencies": {
52
- "@favware/cliff-jumper": "^5.0.0",
53
- "@favware/rollup-type-bundler": "^3.3.0",
54
- "@sentry/node": "^8.47.0",
52
+ "@favware/cliff-jumper": "^6.0.0",
53
+ "@favware/rollup-type-bundler": "^4.0.0",
54
+ "@sentry/node": "^9.10.1",
55
55
  "@types/luxon": "^3.4.2",
56
- "@types/node": "^22.10.5",
56
+ "@types/node": "^22.13.14",
57
57
  "concurrently": "^9.1.2",
58
- "tsup": "^8.3.5",
59
- "tsx": "^4.19.2",
58
+ "tsup": "^8.4.0",
59
+ "tsx": "^4.19.3",
60
60
  "typescript": "~5.4.5"
61
61
  },
62
62
  "homepage": "https://github.com/Kings-World/sapphire-plugins",