@sapphire/plugin-scheduled-tasks 0.1.0-next.65d5f04.0

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.
Files changed (68) hide show
  1. package/LICENSE.md +24 -0
  2. package/README.md +254 -0
  3. package/dist/index.d.ts +21 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +8 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +6 -0
  8. package/dist/lib/ScheduledTaskHandler.d.ts +12 -0
  9. package/dist/lib/ScheduledTaskHandler.d.ts.map +1 -0
  10. package/dist/lib/ScheduledTaskHandler.js +51 -0
  11. package/dist/lib/ScheduledTaskHandler.js.map +1 -0
  12. package/dist/lib/strategies/ScheduledTaskRedisStrategy.d.ts +22 -0
  13. package/dist/lib/strategies/ScheduledTaskRedisStrategy.d.ts.map +1 -0
  14. package/dist/lib/strategies/ScheduledTaskRedisStrategy.js +65 -0
  15. package/dist/lib/strategies/ScheduledTaskRedisStrategy.js.map +1 -0
  16. package/dist/lib/strategies/ScheduledTaskSQSStrategy.d.ts +20 -0
  17. package/dist/lib/strategies/ScheduledTaskSQSStrategy.d.ts.map +1 -0
  18. package/dist/lib/strategies/ScheduledTaskSQSStrategy.js +73 -0
  19. package/dist/lib/strategies/ScheduledTaskSQSStrategy.js.map +1 -0
  20. package/dist/lib/structures/ScheduledTask.d.ts +15 -0
  21. package/dist/lib/structures/ScheduledTask.d.ts.map +1 -0
  22. package/dist/lib/structures/ScheduledTask.js +25 -0
  23. package/dist/lib/structures/ScheduledTask.js.map +1 -0
  24. package/dist/lib/structures/ScheduledTaskStore.d.ts +10 -0
  25. package/dist/lib/structures/ScheduledTaskStore.d.ts.map +1 -0
  26. package/dist/lib/structures/ScheduledTaskStore.js +35 -0
  27. package/dist/lib/structures/ScheduledTaskStore.js.map +1 -0
  28. package/dist/lib/types/ScheduledTaskBaseStrategy.d.ts +10 -0
  29. package/dist/lib/types/ScheduledTaskBaseStrategy.d.ts.map +1 -0
  30. package/dist/lib/types/ScheduledTaskBaseStrategy.js +3 -0
  31. package/dist/lib/types/ScheduledTaskBaseStrategy.js.map +1 -0
  32. package/dist/lib/types/ScheduledTaskCreateRepeatedTask.d.ts +6 -0
  33. package/dist/lib/types/ScheduledTaskCreateRepeatedTask.d.ts.map +1 -0
  34. package/dist/lib/types/ScheduledTaskCreateRepeatedTask.js +3 -0
  35. package/dist/lib/types/ScheduledTaskCreateRepeatedTask.js.map +1 -0
  36. package/dist/lib/types/ScheduledTasksOptions.d.ts +5 -0
  37. package/dist/lib/types/ScheduledTasksOptions.d.ts.map +1 -0
  38. package/dist/lib/types/ScheduledTasksOptions.js +3 -0
  39. package/dist/lib/types/ScheduledTasksOptions.js.map +1 -0
  40. package/dist/lib/types/ScheduledTasksTaskOptions.d.ts +16 -0
  41. package/dist/lib/types/ScheduledTasksTaskOptions.d.ts.map +1 -0
  42. package/dist/lib/types/ScheduledTasksTaskOptions.js +3 -0
  43. package/dist/lib/types/ScheduledTasksTaskOptions.js.map +1 -0
  44. package/dist/lib/types/index.d.ts +5 -0
  45. package/dist/lib/types/index.d.ts.map +1 -0
  46. package/dist/lib/types/index.js +8 -0
  47. package/dist/lib/types/index.js.map +1 -0
  48. package/dist/register-redis.d.ts +4 -0
  49. package/dist/register-redis.d.ts.map +1 -0
  50. package/dist/register-redis.js +7 -0
  51. package/dist/register-redis.js.map +1 -0
  52. package/dist/register-redis.mjs +4 -0
  53. package/dist/register-sqs.d.ts +4 -0
  54. package/dist/register-sqs.d.ts.map +1 -0
  55. package/dist/register-sqs.js +7 -0
  56. package/dist/register-sqs.js.map +1 -0
  57. package/dist/register-sqs.mjs +4 -0
  58. package/dist/register.d.ts +21 -0
  59. package/dist/register.d.ts.map +1 -0
  60. package/dist/register.js +44 -0
  61. package/dist/register.js.map +1 -0
  62. package/package.json +85 -0
  63. package/register-redis.d.ts +1 -0
  64. package/register-redis.js +4 -0
  65. package/register-redis.mjs +1 -0
  66. package/register-sqs.d.ts +1 -0
  67. package/register-sqs.js +4 -0
  68. package/register-sqs.mjs +1 -0
package/LICENSE.md ADDED
@@ -0,0 +1,24 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright © `2020` `The Sapphire Community and its contributors`
4
+
5
+ Permission is hereby granted, free of charge, to any person
6
+ obtaining a copy of this software and associated documentation
7
+ files (the “Software”), to deal in the Software without
8
+ restriction, including without limitation the rights to use,
9
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ <div align="center">
2
+
3
+ ![Sapphire Logo](https://cdn.skyra.pw/gh-assets/sapphire-banner.png)
4
+
5
+ # @sapphire/plugin-scheduled-tasks
6
+
7
+ **Plugin for <a href="https://github.com/sapphiredev/framework">@sapphire/framework</a> to add support for scheduled tasks.**
8
+
9
+ [![GitHub](https://img.shields.io/github/license/sapphiredev/plugins)](https://github.com/sapphiredev/plugins/blob/main/LICENSE.md)
10
+ [![codecov](https://codecov.io/gh/sapphiredev/plugins/branch/main/graph/badge.svg?token=QWL8FB16BR)](https://codecov.io/gh/sapphiredev/plugins)
11
+ [![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/plugin-scheduled-tasks?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/plugin-scheduled-tasks)
12
+ [![npm](https://img.shields.io/npm/v/@sapphire/plugin-scheduled-tasks?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/plugin-scheduled-tasks)
13
+
14
+ </div>
15
+
16
+ ## Description
17
+
18
+ Many bots have features that need to run periodically, such as uploading analytics data, reminders for users, birthdays, scheduled giveaways, undoing moderation actions, and more. Several implemented solutions exist for this, but as with many time-based processing attempts, they are often flawed and unreliable. This plugin is our solution, enabling you to schedule tasks and save them in services like Redis and SQS with ease.
19
+
20
+ ## Features
21
+
22
+ - Full TypeScript support
23
+ - Includes ESM entrypoint
24
+
25
+ ## Installation
26
+
27
+ `@sapphire/plugin-scheduled-tasks` depends on the following packages. Be sure to install these along with this package!
28
+
29
+ - [`@sapphire/framework`](https://www.npmjs.com/package/@sapphire/framework)
30
+
31
+ In case you want to use bull as your provider:
32
+
33
+ - [`bull`](https://www.npmjs.com/package/bull)
34
+
35
+ In case you want to use sqs as your provider:
36
+
37
+ - [`sqs-consumer`](https://www.npmjs.com/package/sqs-consumer)
38
+ - [`sqs-producer`](https://www.npmjs.com/package/sqs-producer)
39
+
40
+ You can use the following command to install this package with bull, or replace `npm install` with your package manager of choice.
41
+
42
+ ```sh
43
+ npm install @sapphire/plugin-scheduled-tasks @sapphire/framework bull
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Usage
49
+
50
+ This registers the necessary options and methods in the Sapphire client to be able to use the schedule plugin.
51
+
52
+ ```typescript
53
+ // Main bot file
54
+ // Be sure to register the plugin before instantiating the client.
55
+ import { ScheduledTaskRedisStrategy } from '@sapphire/plugin-scheduled-tasks/register-redis';
56
+
57
+ // Or if you want to use sqs
58
+ import { ScheduledTaskSQSStrategy } from '@sapphire/plugin-scheduled-tasks/register-sqs';
59
+ ```
60
+
61
+ Then, you can pass the imported Strategy into the configuration options in your SapphireClient extension class or initializer. This will either be located in your new SapphireClient constructor call, or super in your constructor method if you use an extension class.
62
+
63
+ ```typescript
64
+ const options = {
65
+ ...otherClientOptionsGoHere,
66
+ tasks: {
67
+ strategy: new ScheduledTaskRedisStrategy(),
68
+ // or with sqs
69
+ strategy: new ScheduledTaskSQSStrategy({
70
+ /* you can add your SQS options here */
71
+ })
72
+ }
73
+ };
74
+ ```
75
+
76
+ In order to use the scheduled tasks anywhere other than a piece (commands, arguments, preconditions, etc.), you must first import the `container` property of `@sapphire/framework`. For pieces, you can simply use `this.container.tasks` to access this plugin's methods.
77
+
78
+ This is a simple example that creates a task to be run in 2 seconds from a service.
79
+
80
+ ```typescript
81
+ import { container } from '@sapphire/framework';
82
+
83
+ export class MyAwesomeService {
84
+ public createAwesomeTask() {
85
+ container.tasks.create('name', { id: '123' }, 2000);
86
+ }
87
+ }
88
+ ```
89
+
90
+ Here is an example mute command, demonstrating the use of `this.container.tasks` from within a piece by omitting the explicit import.
91
+
92
+ ```typescript
93
+ // mute command
94
+
95
+ import { Command, CommandOptions, PieceContext } from '@sapphire/framework';
96
+ import type { Message } from 'discord.js';
97
+
98
+ export class MuteCommand extends Command {
99
+ public constructor(context: PieceContext) {
100
+ super(context, {
101
+ description: 'Mute a user'
102
+ });
103
+ }
104
+
105
+ public async run(message: Message) {
106
+ // create a task to unmute the user in 1 minute
107
+ this.container.tasks.create('unmute', { authorId: message.author.id }, 60000);
108
+ }
109
+ }
110
+ ```
111
+
112
+ ### Create a task handler
113
+
114
+ Scheduled tasks use their own store, like other types of pieces. You can create a directory alongside your commands directory named `scheduled-tasks` and place your tasks there, but they must inherit from `ScheduledTask`, like so.
115
+
116
+ #### Manual task example
117
+
118
+ ##### Creating the Piece:
119
+
120
+ ```typescript
121
+ import type { PieceContext } from '@sapphire/framework';
122
+ import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
123
+
124
+ export class ManualTask extends ScheduledTask {
125
+ public constructor(context: PieceContext) {
126
+ super(context);
127
+ }
128
+
129
+ public async run(payload: unknown) {
130
+ this.container.logger.info('I ran!', payload);
131
+ }
132
+ }
133
+
134
+ declare module '@sapphire/framework' {
135
+ interface ScheduledTasks {
136
+ manual: never;
137
+ }
138
+ }
139
+ ```
140
+
141
+ ##### Using Manual Tasks
142
+
143
+ ```typescript
144
+ container.tasks.create('manual', payload, 5000);
145
+ ```
146
+
147
+ #### Cron Task Example
148
+
149
+ Cron jobs are currently only supported by the Redis strategy.
150
+
151
+ ##### Creating the Piece:
152
+
153
+ ```typescript
154
+ import type { PieceContext } from '@sapphire/framework';
155
+ import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
156
+
157
+ export class CronTask extends ScheduledTask {
158
+ public constructor(context: PieceContext) {
159
+ super(context, {
160
+ cron: '0 * * * *'
161
+ });
162
+ }
163
+
164
+ public async run() {
165
+ this.container.logger.info('I run every hour at *:00');
166
+ }
167
+ }
168
+
169
+ declare module '@sapphire/framework' {
170
+ interface ScheduledTasks {
171
+ cron: never;
172
+ }
173
+ }
174
+ ```
175
+
176
+ ##### Using Cron tasks
177
+
178
+ Cron & Interval tasks are loaded automatically.
179
+
180
+ #### Interval task example
181
+
182
+ ##### Creating the Piece:
183
+
184
+ ```typescript
185
+ import type { PieceContext } from '@sapphire/framework';
186
+ import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
187
+
188
+ export class IntervalTask extends ScheduledTask {
189
+ public constructor(context: PieceContext) {
190
+ super(context, {
191
+ interval: 60 * 1000 // 60 seconds
192
+ });
193
+ }
194
+
195
+ public async run() {
196
+ this.container.logger.info('I run every minute');
197
+ }
198
+ }
199
+
200
+ declare module '@sapphire/framework' {
201
+ interface ScheduledTasks {
202
+ interval: never;
203
+ }
204
+ }
205
+ ```
206
+
207
+ ##### Using Interval tasks
208
+
209
+ Cron & Interval tasks are loaded automatically.
210
+
211
+ ## Buy us some doughnuts
212
+
213
+ Sapphire Community is and always will be open source, even if we don't get donations. That being said, we know there are amazing people who may still want to donate just to show their appreciation. Thank you very much in advance!
214
+
215
+ We accept donations through Open Collective, Ko-fi, Paypal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
216
+
217
+ | Donate With | Address |
218
+ | :-------------: | :-------------------------------------------------: |
219
+ | Open Collective | [Click Here](https://sapphirejs.dev/opencollective) |
220
+ | Ko-fi | [Click Here](https://sapphirejs.dev/kofi) |
221
+ | Patreon | [Click Here](https://sapphirejs.dev/patreon) |
222
+ | PayPal | [Click Here](https://sapphirejs.dev/paypal) |
223
+
224
+ ## Contributors ✨
225
+
226
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
227
+
228
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
229
+ <!-- prettier-ignore-start -->
230
+ <!-- markdownlint-disable -->
231
+ <table>
232
+ <tr>
233
+ <td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Favna" title="Code">💻</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#projectManagement-Favna" title="Project Management">📆</a></td>
234
+ <td align="center"><a href="https://quantumlytangled.com"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnic</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=QuantumlyTangled" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=QuantumlyTangled" title="Documentation">📖</a></td>
235
+ <td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio Román</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kyranet" title="Code">💻</a></td>
236
+ <td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">👀</a></td>
237
+ <td align="center"><a href="https://github.com/apps/depfu"><img src="https://avatars3.githubusercontent.com/in/715?v=4?s=100" width="100px;" alt=""/><br /><sub><b>depfu[bot]</b></sub></a><br /><a href="#maintenance-depfu[bot]" title="Maintenance">🚧</a></td>
238
+ <td align="center"><a href="https://github.com/apps/dependabot"><img src="https://avatars0.githubusercontent.com/in/29110?v=4?s=100" width="100px;" alt=""/><br /><sub><b>dependabot[bot]</b></sub></a><br /><a href="#maintenance-dependabot[bot]" title="Maintenance">🚧</a></td>
239
+ <td align="center"><a href="https://github.com/apps/allcontributors"><img src="https://avatars0.githubusercontent.com/in/23186?v=4?s=100" width="100px;" alt=""/><br /><sub><b>allcontributors[bot]</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=allcontributors[bot]" title="Documentation">📖</a></td>
240
+ </tr>
241
+ <tr>
242
+ <td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">💻</a></td>
243
+ <td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Stitch07" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/issues?q=author%3AStitch07" title="Bug reports">🐛</a></td>
244
+ <td align="center"><a href="https://github.com/PlatinBae"><img src="https://avatars.githubusercontent.com/u/50950966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PlatinBae</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=PlatinBae" title="Documentation">📖</a></td>
245
+ <td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Code">💻</a> <a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Documentation">📖</a></td>
246
+ </tr>
247
+ </table>
248
+
249
+ <!-- markdownlint-restore -->
250
+ <!-- prettier-ignore-end -->
251
+
252
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
253
+
254
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
@@ -0,0 +1,21 @@
1
+ import type { ScheduledTaskHandler } from './lib/ScheduledTaskHandler';
2
+ import type { ScheduledTaskStore } from './lib/structures/ScheduledTaskStore';
3
+ import type { ScheduledTasksOptions } from './lib/types/ScheduledTasksOptions';
4
+ export * from './lib/ScheduledTaskHandler';
5
+ export * from './lib/structures/ScheduledTask';
6
+ export * from './lib/structures/ScheduledTaskStore';
7
+ export * from './lib/types';
8
+ declare module '@sapphire/pieces' {
9
+ interface Container {
10
+ tasks: ScheduledTaskHandler;
11
+ }
12
+ interface StoreRegistryEntries {
13
+ 'scheduled-tasks': ScheduledTaskStore;
14
+ }
15
+ }
16
+ declare module 'discord.js' {
17
+ interface ClientOptions {
18
+ tasks?: ScheduledTasksOptions;
19
+ }
20
+ }
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAE5B,OAAO,QAAQ,kBAAkB,CAAC;IACjC,UAAU,SAAS;QAClB,KAAK,EAAE,oBAAoB,CAAC;KAC5B;IAED,UAAU,oBAAoB;QAC7B,iBAAiB,EAAE,kBAAkB,CAAC;KACtC;CACD;AAED,OAAO,QAAQ,YAAY,CAAC;IAC3B,UAAiB,aAAa;QAC7B,KAAK,CAAC,EAAE,qBAAqB,CAAC;KAC9B;CACD"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./lib/ScheduledTaskHandler"), exports);
5
+ (0, tslib_1.__exportStar)(require("./lib/structures/ScheduledTask"), exports);
6
+ (0, tslib_1.__exportStar)(require("./lib/structures/ScheduledTaskStore"), exports);
7
+ (0, tslib_1.__exportStar)(require("./lib/types"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,0EAA2C;AAC3C,8EAA+C;AAC/C,mFAAoD;AACpD,2DAA4B"}
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import mod from "./index.js";
2
+
3
+ export default mod;
4
+ export const ScheduledTask = mod.ScheduledTask;
5
+ export const ScheduledTaskHandler = mod.ScheduledTaskHandler;
6
+ export const ScheduledTaskStore = mod.ScheduledTaskStore;
@@ -0,0 +1,12 @@
1
+ import type { Awaitable } from '@sapphire/utilities';
2
+ import type { ScheduledTaskBaseStrategy, ScheduledTasksOptions, ScheduledTasksTaskOptions } from './types';
3
+ export declare class ScheduledTaskHandler {
4
+ readonly strategy: ScheduledTaskBaseStrategy;
5
+ constructor(options: ScheduledTasksOptions | undefined);
6
+ connect(): Promise<void>;
7
+ create(task: string, payload: unknown, options?: ScheduledTasksTaskOptions | number): void;
8
+ createRepeated(): void;
9
+ run(task: string, payload: unknown): Awaitable<unknown>;
10
+ private get store();
11
+ }
12
+ //# sourceMappingURL=ScheduledTaskHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskHandler.d.ts","sourceRoot":"","sources":["../../src/lib/ScheduledTaskHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAE3G,qBAAa,oBAAoB;IAChC,SAAgB,QAAQ,EAAE,yBAAyB,CAAC;gBAEjC,OAAO,EAAE,qBAAqB,GAAG,SAAS;IAIhD,OAAO;IAIb,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM;IAWnF,cAAc;IAkBd,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;IAM9D,OAAO,KAAK,KAAK,GAEhB;CACD"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTaskHandler = void 0;
4
+ const framework_1 = require("@sapphire/framework");
5
+ const ScheduledTaskRedisStrategy_1 = require("./strategies/ScheduledTaskRedisStrategy");
6
+ class ScheduledTaskHandler {
7
+ constructor(options) {
8
+ Object.defineProperty(this, "strategy", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: void 0
13
+ });
14
+ this.strategy = options?.strategy ?? new ScheduledTaskRedisStrategy_1.ScheduledTaskRedisStrategy();
15
+ }
16
+ async connect() {
17
+ await this.strategy.connect();
18
+ }
19
+ create(task, payload, options) {
20
+ if (typeof options === 'number') {
21
+ options = {
22
+ type: 'default',
23
+ delay: options
24
+ };
25
+ }
26
+ return this.strategy.create(task, payload, options);
27
+ }
28
+ createRepeated() {
29
+ const { store } = this;
30
+ return this.strategy.createRepeated(store.repeatedTasks.map((piece) => ({
31
+ name: piece.name,
32
+ options: {
33
+ type: 'repeated',
34
+ ...(piece.interval
35
+ ? {
36
+ interval: piece.interval
37
+ }
38
+ : { cron: piece.cron })
39
+ }
40
+ })));
41
+ }
42
+ run(task, payload) {
43
+ const piece = this.store.get(task);
44
+ return piece?.run(payload);
45
+ }
46
+ get store() {
47
+ return framework_1.container.client.stores.get('scheduled-tasks');
48
+ }
49
+ }
50
+ exports.ScheduledTaskHandler = ScheduledTaskHandler;
51
+ //# sourceMappingURL=ScheduledTaskHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskHandler.js","sourceRoot":"","sources":["../../src/lib/ScheduledTaskHandler.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEhD,wFAAqF;AAIrF,MAAa,oBAAoB;IAGhC,YAAmB,OAA0C;QAF7D;;;;;WAAoD;QAGnD,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,IAAI,uDAA0B,EAAE,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,OAAO;QACnB,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,OAAgB,EAAE,OAA4C;QACzF,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAChC,OAAO,GAAG;gBACT,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,OAAO;aACd,CAAC;SACF;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAEM,cAAc;QACpB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAEvB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAClC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE;gBACR,IAAI,EAAE,UAAU;gBAChB,GAAG,CAAC,KAAK,CAAC,QAAQ;oBACjB,CAAC,CAAC;wBACA,QAAQ,EAAE,KAAK,CAAC,QAAQ;qBACvB;oBACH,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAK,EAAE,CAAC;aACzB;SACD,CAAC,CAAC,CACH,CAAC;IACH,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,OAAgB;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEnC,OAAO,KAAK,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;IAED,IAAY,KAAK;QAChB,OAAO,qBAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC;CACD;AAjDD,oDAiDC"}
@@ -0,0 +1,22 @@
1
+ import Bull, { QueueOptions } from 'bull';
2
+ import type { ScheduledTaskCreateRepeatedTask, ScheduledTasksTaskOptions } from '../types';
3
+ import type { ScheduledTaskBaseStrategy } from '../types/ScheduledTaskBaseStrategy';
4
+ export interface ScheduledTaskRedisStrategyOptions {
5
+ queue?: string;
6
+ bull?: QueueOptions;
7
+ }
8
+ export interface ScheduledTaskRedisStrategyJob {
9
+ task: string;
10
+ payload?: unknown;
11
+ }
12
+ export declare class ScheduledTaskRedisStrategy implements ScheduledTaskBaseStrategy {
13
+ readonly options: QueueOptions;
14
+ readonly queue: string;
15
+ private bullClient;
16
+ constructor(options?: ScheduledTaskRedisStrategyOptions);
17
+ connect(): Promise<void>;
18
+ create(task: string, payload?: unknown, options?: ScheduledTasksTaskOptions): Promise<Bull.Job<any>> | undefined;
19
+ createRepeated(tasks: ScheduledTaskCreateRepeatedTask[]): Promise<void>;
20
+ run(task: string, payload: unknown): unknown;
21
+ }
22
+ //# sourceMappingURL=ScheduledTaskRedisStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskRedisStrategy.d.ts","sourceRoot":"","sources":["../../../src/lib/strategies/ScheduledTaskRedisStrategy.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,EAAE,EAA0B,YAAY,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAEpF,MAAM,WAAW,iCAAiC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,0BAA2B,YAAW,yBAAyB;IAC3E,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAE9B,OAAO,CAAC,UAAU,CAAS;gBAER,OAAO,CAAC,EAAE,iCAAiC;IAKjD,OAAO;IAKb,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB;IA4BrE,cAAc,CAAC,KAAK,EAAE,+BAA+B,EAAE;IAM7D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;CAGzC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTaskRedisStrategy = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const framework_1 = require("@sapphire/framework");
6
+ const bull_1 = (0, tslib_1.__importDefault)(require("bull"));
7
+ class ScheduledTaskRedisStrategy {
8
+ constructor(options) {
9
+ Object.defineProperty(this, "options", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ Object.defineProperty(this, "queue", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ Object.defineProperty(this, "bullClient", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: void 0
26
+ });
27
+ this.queue = options?.queue ?? 'scheduled-tasks';
28
+ this.options = options?.bull ?? {};
29
+ }
30
+ async connect() {
31
+ this.bullClient = new bull_1.default(this.queue, this.options);
32
+ await this.bullClient.process((job) => this.run(job?.data?.task, job?.data?.payload));
33
+ }
34
+ create(task, payload, options) {
35
+ if (!this.bullClient) {
36
+ return;
37
+ }
38
+ let bullOptions = { delay: options?.delay };
39
+ if (options?.type === 'repeated') {
40
+ bullOptions = {
41
+ repeat: options?.interval
42
+ ? {
43
+ every: options.interval
44
+ }
45
+ : {
46
+ cron: options.cron
47
+ }
48
+ };
49
+ }
50
+ return this.bullClient.add({
51
+ task,
52
+ payload
53
+ }, bullOptions);
54
+ }
55
+ async createRepeated(tasks) {
56
+ for (const task of tasks) {
57
+ await this.create(task.name, null, task.options);
58
+ }
59
+ }
60
+ run(task, payload) {
61
+ return framework_1.container.tasks.run(task, payload);
62
+ }
63
+ }
64
+ exports.ScheduledTaskRedisStrategy = ScheduledTaskRedisStrategy;
65
+ //# sourceMappingURL=ScheduledTaskRedisStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskRedisStrategy.js","sourceRoot":"","sources":["../../../src/lib/strategies/ScheduledTaskRedisStrategy.ts"],"names":[],"mappings":";;;;AAAA,mDAAgD;AAChD,6DAAkE;AAclE,MAAa,0BAA0B;IAMtC,YAAmB,OAA2C;QAL9D;;;;;WAAsC;QACtC;;;;;WAA8B;QAE9B;;;;;WAA2B;QAG1B,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,iBAAiB,CAAC;QACjD,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,OAAO;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,cAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAuC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3H,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,OAAiB,EAAE,OAAmC;QACjF,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACrB,OAAO;SACP;QAED,IAAI,WAAW,GAAe,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAExD,IAAI,OAAO,EAAE,IAAI,KAAK,UAAU,EAAE;YACjC,WAAW,GAAG;gBACb,MAAM,EAAE,OAAO,EAAE,QAAQ;oBACxB,CAAC,CAAC;wBACA,KAAK,EAAE,OAAO,CAAC,QAAS;qBACvB;oBACH,CAAC,CAAC;wBACA,IAAI,EAAE,OAAO,CAAC,IAAK;qBAClB;aACJ,CAAC;SACF;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CACzB;YACC,IAAI;YACJ,OAAO;SACP,EACD,WAAW,CACX,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,KAAwC;QACnE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACzB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SACjD;IACF,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,OAAgB;QACxC,OAAO,qBAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACD;AArDD,gEAqDC"}
@@ -0,0 +1,20 @@
1
+ import { ConsumerOptions } from 'sqs-consumer';
2
+ import type { ScheduledTaskCreateRepeatedTask, ScheduledTasksTaskOptions } from '../types';
3
+ import type { ScheduledTaskBaseStrategy } from '../types/ScheduledTaskBaseStrategy';
4
+ export interface ScheduledTaskSQSStrategyMessageBody {
5
+ task: string;
6
+ payload?: unknown;
7
+ options: ScheduledTasksTaskOptions;
8
+ }
9
+ export declare class ScheduledTaskSQSStrategy implements ScheduledTaskBaseStrategy {
10
+ readonly options: ConsumerOptions;
11
+ private producer;
12
+ constructor(options: ConsumerOptions);
13
+ connect(): void;
14
+ create(task: string, payload?: unknown, options?: ScheduledTasksTaskOptions): Promise<import("aws-sdk/clients/sqs").SendMessageBatchResultEntryList>;
15
+ createRepeated(tasks: ScheduledTaskCreateRepeatedTask[]): Promise<void>;
16
+ run(task: string, payload: unknown): unknown;
17
+ private handleMessage;
18
+ private handleBatch;
19
+ }
20
+ //# sourceMappingURL=ScheduledTaskSQSStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskSQSStrategy.d.ts","sourceRoot":"","sources":["../../../src/lib/strategies/ScheduledTaskSQSStrategy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,eAAe,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,+BAA+B,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAEpF,MAAM,WAAW,mCAAmC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,yBAAyB,CAAC;CACnC;AAED,qBAAa,wBAAyB,YAAW,yBAAyB;IACzE,SAAgB,OAAO,EAAE,eAAe,CAAC;IAEzC,OAAO,CAAC,QAAQ,CAAW;gBAER,OAAO,EAAE,eAAe;IAKpC,OAAO;IAUP,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAqBrE,cAAc,CAAC,KAAK,EAAE,+BAA+B,EAAE;IAM7D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;YAI3B,aAAa;YAWb,WAAW;CAOzB"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTaskSQSStrategy = void 0;
4
+ const framework_1 = require("@sapphire/framework");
5
+ const crypto_1 = require("crypto");
6
+ const sqs_consumer_1 = require("sqs-consumer");
7
+ const sqs_producer_1 = require("sqs-producer");
8
+ class ScheduledTaskSQSStrategy {
9
+ constructor(options) {
10
+ Object.defineProperty(this, "options", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "producer", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ this.options = options;
23
+ this.producer = sqs_producer_1.Producer.create(this.options);
24
+ }
25
+ connect() {
26
+ const consumer = sqs_consumer_1.Consumer.create({
27
+ ...this.options,
28
+ handleMessage: this.handleMessage.bind(this),
29
+ handleMessageBatch: this.handleBatch.bind(this)
30
+ });
31
+ consumer.start();
32
+ }
33
+ create(task, payload, options) {
34
+ if (options?.cron) {
35
+ throw new Error('SQS does not support cron notation.');
36
+ }
37
+ let delay = (options?.delay ?? 0) / 1000;
38
+ if (options?.type === 'repeated') {
39
+ delay = options.interval / 1000;
40
+ }
41
+ return this.producer.send({
42
+ id: `${task}-${(0, crypto_1.randomBytes)(6)}`,
43
+ body: JSON.stringify({
44
+ task,
45
+ payload,
46
+ options
47
+ }),
48
+ delaySeconds: delay
49
+ });
50
+ }
51
+ async createRepeated(tasks) {
52
+ for (const task of tasks) {
53
+ await this.create(task.name, null, task.options);
54
+ }
55
+ }
56
+ run(task, payload) {
57
+ return framework_1.container.tasks.run(task, payload);
58
+ }
59
+ async handleMessage(message) {
60
+ const data = JSON.parse(message.Body);
61
+ await this.run(data.task, data.payload);
62
+ if (data.options.type === 'repeated') {
63
+ await this.create(data.task, data.payload, data.options);
64
+ }
65
+ }
66
+ async handleBatch(messages) {
67
+ for (const message of messages) {
68
+ await this.handleMessage(message);
69
+ }
70
+ }
71
+ }
72
+ exports.ScheduledTaskSQSStrategy = ScheduledTaskSQSStrategy;
73
+ //# sourceMappingURL=ScheduledTaskSQSStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskSQSStrategy.js","sourceRoot":"","sources":["../../../src/lib/strategies/ScheduledTaskSQSStrategy.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,mCAAqC;AACrC,+CAAyD;AACzD,+CAAwC;AAUxC,MAAa,wBAAwB;IAKpC,YAAmB,OAAwB;QAJ3C;;;;;WAAyC;QAEzC;;;;;WAA2B;QAG1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,uBAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,OAAO;QACb,MAAM,QAAQ,GAAG,uBAAQ,CAAC,MAAM,CAAC;YAChC,GAAG,IAAI,CAAC,OAAO;YACf,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5C,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/C,CAAC,CAAC;QAEH,QAAQ,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,IAAY,EAAE,OAAiB,EAAE,OAAmC;QACjF,IAAI,OAAO,EAAE,IAAI,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACvD;QAED,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QACzC,IAAI,OAAO,EAAE,IAAI,KAAK,UAAU,EAAE;YACjC,KAAK,GAAG,OAAO,CAAC,QAAS,GAAG,IAAI,CAAC;SACjC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACzB,EAAE,EAAE,GAAG,IAAI,IAAI,IAAA,oBAAW,EAAC,CAAC,CAAC,EAAE;YAC/B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,IAAI;gBACJ,OAAO;gBACP,OAAO;aACP,CAAC;YACF,YAAY,EAAE,KAAK;SACnB,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,KAAwC;QACnE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACzB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SACjD;IACF,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,OAAgB;QACxC,OAAO,qBAAS,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAEO,KAAK,CAAC,aAAa,CAC1B,OAAkE;QAElE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAK,CAAwC,CAAC;QAC9E,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAExC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE;YACrC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SACzD;IACF,CAAC;IAEO,KAAK,CAAC,WAAW,CACxB,QAAwE;QAExE,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC/B,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SAClC;IACF,CAAC;CACD;AArED,4DAqEC"}
@@ -0,0 +1,15 @@
1
+ import { Piece, PieceContext, PieceOptions } from '@sapphire/pieces';
2
+ import type { Awaitable } from '@sapphire/utilities';
3
+ export declare abstract class ScheduledTask extends Piece {
4
+ readonly interval: number | null;
5
+ readonly cron: string | null;
6
+ constructor(context: PieceContext, options: ScheduledTaskOptions);
7
+ abstract run(payload: unknown): Awaitable<unknown>;
8
+ }
9
+ export interface ScheduledTasks {
10
+ }
11
+ export interface ScheduledTaskOptions extends PieceOptions {
12
+ interval?: number | null;
13
+ cron?: string | null;
14
+ }
15
+ //# sourceMappingURL=ScheduledTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTask.d.ts","sourceRoot":"","sources":["../../../src/lib/structures/ScheduledTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,8BAAsB,aAAc,SAAQ,KAAK;IAChD,SAAgB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAgB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEjB,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,oBAAoB;aAMvD,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;CACzD;AAED,MAAM,WAAW,cAAc;CAAG;AAElC,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTask = void 0;
4
+ const pieces_1 = require("@sapphire/pieces");
5
+ class ScheduledTask extends pieces_1.Piece {
6
+ constructor(context, options) {
7
+ super(context, options);
8
+ Object.defineProperty(this, "interval", {
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true,
12
+ value: void 0
13
+ });
14
+ Object.defineProperty(this, "cron", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: void 0
19
+ });
20
+ this.interval = options.interval ?? null;
21
+ this.cron = options.cron ?? null;
22
+ }
23
+ }
24
+ exports.ScheduledTask = ScheduledTask;
25
+ //# sourceMappingURL=ScheduledTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTask.js","sourceRoot":"","sources":["../../../src/lib/structures/ScheduledTask.ts"],"names":[],"mappings":";;;AAAA,6CAAqE;AAGrE,MAAsB,aAAc,SAAQ,cAAK;IAIhD,YAAmB,OAAqB,EAAE,OAA6B;QACtE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAJzB;;;;;WAAwC;QACxC;;;;;WAAoC;QAInC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;IAClC,CAAC;CAGD;AAXD,sCAWC"}
@@ -0,0 +1,10 @@
1
+ import { Store } from '@sapphire/pieces';
2
+ import { ScheduledTask } from './ScheduledTask';
3
+ export declare class ScheduledTaskStore extends Store<ScheduledTask> {
4
+ readonly repeatedTasks: ScheduledTask[];
5
+ constructor();
6
+ set(key: string, value: ScheduledTask): this;
7
+ delete(key: string): boolean;
8
+ clear(): void;
9
+ }
10
+ //# sourceMappingURL=ScheduledTaskStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskStore.d.ts","sourceRoot":"","sources":["../../../src/lib/structures/ScheduledTaskStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,qBAAa,kBAAmB,SAAQ,KAAK,CAAC,aAAa,CAAC;IAC3D,SAAgB,aAAa,EAAE,aAAa,EAAE,CAAM;;IAM7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAQ5C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAS5B,KAAK,IAAI,IAAI;CAIpB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTaskStore = void 0;
4
+ const pieces_1 = require("@sapphire/pieces");
5
+ const ScheduledTask_1 = require("./ScheduledTask");
6
+ class ScheduledTaskStore extends pieces_1.Store {
7
+ constructor() {
8
+ super(ScheduledTask_1.ScheduledTask, { name: 'scheduled-tasks' });
9
+ Object.defineProperty(this, "repeatedTasks", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: []
14
+ });
15
+ }
16
+ set(key, value) {
17
+ if (value.interval !== null || value.cron !== null) {
18
+ this.repeatedTasks.push(value);
19
+ }
20
+ return super.set(key, value);
21
+ }
22
+ delete(key) {
23
+ const index = this.repeatedTasks.findIndex((task) => task.name === key);
24
+ // If the scheduled task was found, remove it
25
+ if (index !== -1)
26
+ this.repeatedTasks.splice(index, 1);
27
+ return super.delete(key);
28
+ }
29
+ clear() {
30
+ this.repeatedTasks.length = 0;
31
+ return super.clear();
32
+ }
33
+ }
34
+ exports.ScheduledTaskStore = ScheduledTaskStore;
35
+ //# sourceMappingURL=ScheduledTaskStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskStore.js","sourceRoot":"","sources":["../../../src/lib/structures/ScheduledTaskStore.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,mDAAgD;AAEhD,MAAa,kBAAmB,SAAQ,cAAoB;IAG3D;QACC,KAAK,CAAC,6BAAoB,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAH1D;;;;mBAAiD,EAAE;WAAC;IAIpD,CAAC;IAEM,GAAG,CAAC,GAAW,EAAE,KAAoB;QAC3C,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;YACnD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC/B;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEM,MAAM,CAAC,GAAW;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC;QAExE,6CAA6C;QAC7C,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAEtD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC9B,OAAO,KAAK,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AA5BD,gDA4BC"}
@@ -0,0 +1,10 @@
1
+ import type { Awaitable } from '@sapphire/utilities';
2
+ import type { ScheduledTaskCreateRepeatedTask } from './ScheduledTaskCreateRepeatedTask';
3
+ import type { ScheduledTasksTaskOptions } from './ScheduledTasksTaskOptions';
4
+ export interface ScheduledTaskBaseStrategy {
5
+ connect(): Awaitable<void>;
6
+ create(task: string, payload: unknown, options?: ScheduledTasksTaskOptions): void;
7
+ createRepeated(tasks: ScheduledTaskCreateRepeatedTask[]): void;
8
+ run(task: string, payload: unknown): Awaitable<unknown>;
9
+ }
10
+ //# sourceMappingURL=ScheduledTaskBaseStrategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskBaseStrategy.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskBaseStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,MAAM,WAAW,yBAAyB;IACzC,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAClF,cAAc,CAAC,KAAK,EAAE,+BAA+B,EAAE,GAAG,IAAI,CAAC;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;CACxD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ScheduledTaskBaseStrategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskBaseStrategy.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskBaseStrategy.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { ScheduledTasksTaskOptions } from './ScheduledTasksTaskOptions';
2
+ export interface ScheduledTaskCreateRepeatedTask {
3
+ name: string;
4
+ options: ScheduledTasksTaskOptions;
5
+ }
6
+ //# sourceMappingURL=ScheduledTaskCreateRepeatedTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskCreateRepeatedTask.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskCreateRepeatedTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAE7E,MAAM,WAAW,+BAA+B;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,yBAAyB,CAAC;CACnC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ScheduledTaskCreateRepeatedTask.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTaskCreateRepeatedTask.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTaskCreateRepeatedTask.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ScheduledTaskBaseStrategy } from '.';
2
+ export interface ScheduledTasksOptions {
3
+ strategy: ScheduledTaskBaseStrategy;
4
+ }
5
+ //# sourceMappingURL=ScheduledTasksOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTasksOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTasksOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAC;AAEnD,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,yBAAyB,CAAC;CACpC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ScheduledTasksOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTasksOptions.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTasksOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ export declare type ScheduledTasksTaskOptions = {
2
+ type: 'default' | 'repeated';
3
+ } & ({
4
+ delay: number;
5
+ interval?: never;
6
+ cron?: never;
7
+ } | {
8
+ delay?: never;
9
+ interval: number;
10
+ cron?: never;
11
+ } | {
12
+ delay?: never;
13
+ interval?: never;
14
+ cron: string;
15
+ });
16
+ //# sourceMappingURL=ScheduledTasksTaskOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTasksTaskOptions.d.ts","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTasksTaskOptions.ts"],"names":[],"mappings":"AAAA,oBAAY,yBAAyB,GAAG;IACvC,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;CAC7B,GAAG,CACD;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjD;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CACnD,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ScheduledTasksTaskOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScheduledTasksTaskOptions.js","sourceRoot":"","sources":["../../../src/lib/types/ScheduledTasksTaskOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './ScheduledTaskBaseStrategy';
2
+ export * from './ScheduledTaskCreateRepeatedTask';
3
+ export * from './ScheduledTasksOptions';
4
+ export * from './ScheduledTasksTaskOptions';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./ScheduledTaskBaseStrategy"), exports);
5
+ (0, tslib_1.__exportStar)(require("./ScheduledTaskCreateRepeatedTask"), exports);
6
+ (0, tslib_1.__exportStar)(require("./ScheduledTasksOptions"), exports);
7
+ (0, tslib_1.__exportStar)(require("./ScheduledTasksTaskOptions"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":";;;AAAA,2EAA4C;AAC5C,iFAAkD;AAClD,uEAAwC;AACxC,2EAA4C"}
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ import './register';
3
+ export * from './lib/strategies/ScheduledTaskRedisStrategy';
4
+ //# sourceMappingURL=register-redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-redis.d.ts","sourceRoot":"","sources":["../src/register-redis.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AACjB,OAAO,YAAY,CAAC;AAEpB,cAAc,6CAA6C,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ require("./index");
5
+ require("./register");
6
+ (0, tslib_1.__exportStar)(require("./lib/strategies/ScheduledTaskRedisStrategy"), exports);
7
+ //# sourceMappingURL=register-redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-redis.js","sourceRoot":"","sources":["../src/register-redis.ts"],"names":[],"mappings":";;;AAAA,mBAAiB;AACjB,sBAAoB;AAEpB,2FAA4D"}
@@ -0,0 +1,4 @@
1
+ import mod from "./register-redis.js";
2
+
3
+ export default mod;
4
+ export const ScheduledTaskRedisStrategy = mod.ScheduledTaskRedisStrategy;
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ import './register';
3
+ export * from './lib/strategies/ScheduledTaskSQSStrategy';
4
+ //# sourceMappingURL=register-sqs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-sqs.d.ts","sourceRoot":"","sources":["../src/register-sqs.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AACjB,OAAO,YAAY,CAAC;AAEpB,cAAc,2CAA2C,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ require("./index");
5
+ require("./register");
6
+ (0, tslib_1.__exportStar)(require("./lib/strategies/ScheduledTaskSQSStrategy"), exports);
7
+ //# sourceMappingURL=register-sqs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-sqs.js","sourceRoot":"","sources":["../src/register-sqs.ts"],"names":[],"mappings":";;;AAAA,mBAAiB;AACjB,sBAAoB;AAEpB,yFAA0D"}
@@ -0,0 +1,4 @@
1
+ import mod from "./register-sqs.js";
2
+
3
+ export default mod;
4
+ export const ScheduledTaskSQSStrategy = mod.ScheduledTaskSQSStrategy;
@@ -0,0 +1,21 @@
1
+ import { Plugin, postInitialization, postLogin, preGenericsInitialization, SapphireClient } from '@sapphire/framework';
2
+ import type { ClientOptions } from 'discord.js';
3
+ /**
4
+ * @since 1.0.0
5
+ */
6
+ export declare class ScheduledTasksPlugin extends Plugin {
7
+ service: string | undefined;
8
+ /**
9
+ * @since 1.0.0
10
+ */
11
+ static [preGenericsInitialization](this: SapphireClient, options: ClientOptions): void;
12
+ /**
13
+ * @since 1.0.0
14
+ */
15
+ static [postInitialization](this: SapphireClient): void;
16
+ /**
17
+ * @since 1.0.0
18
+ */
19
+ static [postLogin](this: SapphireClient): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAClI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,MAAM;IACxC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;;OAEG;WACW,CAAC,yBAAyB,CAAC,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7F;;OAEG;WACW,CAAC,kBAAkB,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAI9D;;OAEG;WACiB,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAIpE"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduledTasksPlugin = void 0;
4
+ const framework_1 = require("@sapphire/framework");
5
+ const ScheduledTaskHandler_1 = require("./lib/ScheduledTaskHandler");
6
+ const ScheduledTaskStore_1 = require("./lib/structures/ScheduledTaskStore");
7
+ /**
8
+ * @since 1.0.0
9
+ */
10
+ class ScheduledTasksPlugin extends framework_1.Plugin {
11
+ constructor() {
12
+ super(...arguments);
13
+ Object.defineProperty(this, "service", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ }
20
+ /**
21
+ * @since 1.0.0
22
+ */
23
+ static [framework_1.preGenericsInitialization](options) {
24
+ framework_1.container.tasks = new ScheduledTaskHandler_1.ScheduledTaskHandler(options.tasks);
25
+ }
26
+ /**
27
+ * @since 1.0.0
28
+ */
29
+ static [framework_1.postInitialization]() {
30
+ this.stores.register(new ScheduledTaskStore_1.ScheduledTaskStore());
31
+ }
32
+ /**
33
+ * @since 1.0.0
34
+ */
35
+ static async [framework_1.postLogin]() {
36
+ await framework_1.container.tasks.connect();
37
+ await framework_1.container.tasks.createRepeated();
38
+ }
39
+ }
40
+ exports.ScheduledTasksPlugin = ScheduledTasksPlugin;
41
+ framework_1.SapphireClient.plugins.registerPreGenericsInitializationHook(ScheduledTasksPlugin[framework_1.preGenericsInitialization], 'Scheduled-Task-PreGenericsInitialization');
42
+ framework_1.SapphireClient.plugins.registerPostInitializationHook(ScheduledTasksPlugin[framework_1.postInitialization], 'Scheduled-Task-PostInitialization');
43
+ framework_1.SapphireClient.plugins.registerPostLoginHook(ScheduledTasksPlugin[framework_1.postLogin], 'Scheduled-Task-PostLogin');
44
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":";;;AAAA,mDAAkI;AAElI,qEAAkE;AAClE,4EAAyE;AAEzE;;GAEG;AACH,MAAa,oBAAqB,SAAQ,kBAAM;IAAhD;;QACC;;;;;WAAmC;IAsBpC,CAAC;IArBA;;OAEG;IACI,MAAM,CAAC,CAAC,qCAAyB,CAAC,CAAuB,OAAsB;QACrF,qBAAS,CAAC,KAAK,GAAG,IAAI,2CAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,CAAC,8BAAkB,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,uCAAkB,EAAE,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAS,CAAC;QAC9B,MAAM,qBAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,qBAAS,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;CACD;AAvBD,oDAuBC;AAED,0BAAc,CAAC,OAAO,CAAC,qCAAqC,CAC3D,oBAAoB,CAAC,qCAAyB,CAAC,EAC/C,0CAA0C,CAC1C,CAAC;AAEF,0BAAc,CAAC,OAAO,CAAC,8BAA8B,CAAC,oBAAoB,CAAC,8BAAkB,CAAC,EAAE,mCAAmC,CAAC,CAAC;AAErI,0BAAc,CAAC,OAAO,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,qBAAS,CAAC,EAAE,0BAA0B,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@sapphire/plugin-scheduled-tasks",
3
+ "version": "0.1.0-next.65d5f04.0",
4
+ "description": "Plugin for @sapphire/framework to have scheduled tasks",
5
+ "author": "@sapphire",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/index.d.ts",
10
+ "typedocMain": "src/index.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js"
15
+ },
16
+ "./register-redis": {
17
+ "import": "./register-redis.mjs",
18
+ "require": "./register-redis.js"
19
+ },
20
+ "./register-sqs": {
21
+ "import": "./register-sqs.mjs",
22
+ "require": "./register-sqs.js"
23
+ }
24
+ },
25
+ "sideEffects": [
26
+ "./dist/register-redis.js",
27
+ "./dist/register-sqs.js",
28
+ "./register-redis.js",
29
+ "./register-redis.mjs",
30
+ "./register-sqs.js",
31
+ "./register-sqs.mjs"
32
+ ],
33
+ "homepage": "https://github.com/sapphiredev/plugins/tree/main/packages/scheduled-tasks",
34
+ "scripts": {
35
+ "test": "jest",
36
+ "lint": "eslint src --ext ts --fix",
37
+ "build": "tsc -b src && yarn esm:register-redis && yarn esm:register-sqs && yarn esm:default",
38
+ "esm:register-redis": "gen-esm-wrapper dist/register-redis.js dist/register-redis.mjs",
39
+ "esm:register-sqs": "gen-esm-wrapper dist/register-sqs.js dist/register-sqs.mjs",
40
+ "esm:default": "gen-esm-wrapper dist/index.js dist/index.mjs",
41
+ "prepublishOnly": "yarn build"
42
+ },
43
+ "dependencies": {
44
+ "@sapphire/time-utilities": "^1.3.8",
45
+ "tslib": "^2.3.1"
46
+ },
47
+ "devDependencies": {
48
+ "@types/bull": "^3.15.5",
49
+ "bull": "^3.29.2",
50
+ "sqs-consumer": "^5.6.0",
51
+ "sqs-producer": "^2.1.0"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/sapphiredev/plugins.git",
56
+ "directory": "packages/scheduled-tasks"
57
+ },
58
+ "files": [
59
+ "dist",
60
+ "!dist/*.tsbuildinfo",
61
+ "register-redis.*",
62
+ "register-sqs.*"
63
+ ],
64
+ "engines": {
65
+ "node": ">=v14.18.0",
66
+ "npm": ">=7.24.1"
67
+ },
68
+ "keywords": [
69
+ "sapphiredev",
70
+ "plugin",
71
+ "bot",
72
+ "typescript",
73
+ "ts",
74
+ "yarn",
75
+ "discord",
76
+ "sapphire"
77
+ ],
78
+ "bugs": {
79
+ "url": "https://github.com/sapphiredev/plugins/issues"
80
+ },
81
+ "publishConfig": {
82
+ "access": "public"
83
+ },
84
+ "gitHead": "65d5f04bdaf9f1b8df0bc3a2ddf0413ca7a4a631"
85
+ }
@@ -0,0 +1 @@
1
+ export * from './dist/register-redis';
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const tslib = require('tslib');
3
+
4
+ tslib.__exportStar(require('./dist/register-redis.js'), exports);
@@ -0,0 +1 @@
1
+ export * from './dist/register-redis.mjs';
@@ -0,0 +1 @@
1
+ export * from './dist/register-sqs';
@@ -0,0 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ const tslib = require('tslib');
3
+
4
+ tslib.__exportStar(require('./dist/register-sqs.js'), exports);
@@ -0,0 +1 @@
1
+ export * from './dist/register-sqs.mjs';