@open-discord-bots/framework 0.5.2 → 0.5.4

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.
@@ -4,7 +4,6 @@ export * from "./modules/base.js";
4
4
  export * from "./modules/builder.js";
5
5
  export * from "./modules/checker.js";
6
6
  export * from "./modules/client.js";
7
- export * from "./modules/code.js";
8
7
  export * from "./modules/component.js";
9
8
  export * from "./modules/config.js";
10
9
  export * from "./modules/console.js";
@@ -24,5 +23,6 @@ export * from "./modules/session.js";
24
23
  export * from "./modules/startscreen.js";
25
24
  export * from "./modules/state.js";
26
25
  export * from "./modules/statistic.js";
26
+ export * from "./modules/task.js";
27
27
  export * from "./modules/verifybar.js";
28
28
  export * from "./modules/worker.js";
package/dist/api/index.js CHANGED
@@ -6,7 +6,6 @@ export * from "./modules/base.js";
6
6
  export * from "./modules/builder.js";
7
7
  export * from "./modules/checker.js";
8
8
  export * from "./modules/client.js";
9
- export * from "./modules/code.js";
10
9
  export * from "./modules/component.js";
11
10
  export * from "./modules/config.js";
12
11
  export * from "./modules/console.js";
@@ -26,5 +25,6 @@ export * from "./modules/session.js";
26
25
  export * from "./modules/startscreen.js";
27
26
  export * from "./modules/state.js";
28
27
  export * from "./modules/statistic.js";
28
+ export * from "./modules/task.js";
29
29
  export * from "./modules/verifybar.js";
30
30
  export * from "./modules/worker.js";
@@ -17,7 +17,7 @@ import { ODPermissionManager } from "./modules/permission.js";
17
17
  import { ODCooldownManager } from "./modules/cooldown.js";
18
18
  import { ODHelpMenuManager } from "./modules/helpmenu.js";
19
19
  import { ODStatisticManager } from "./modules/statistic.js";
20
- import { ODCodeManager } from "./modules/code.js";
20
+ import { ODTaskManager } from "./modules/task.js";
21
21
  import { ODPostManager } from "./modules/post.js";
22
22
  import { ODClientManager } from "./modules/client.js";
23
23
  import { ODSharedFuseManager } from "./modules/fuse.js";
@@ -80,8 +80,8 @@ export interface ODMainManagers {
80
80
  helpmenu: ODHelpMenuManager;
81
81
  /**The manager that registers, saves & updates statistics in the database. */
82
82
  statistics: ODStatisticManager;
83
- /**A place where you can put general-purpose code which will start on startup of the bot. (Perfect for background tasks) */
84
- code: ODCodeManager;
83
+ /**A place to put general-purpose code and background tasks which will execute on startup. */
84
+ tasks: ODTaskManager;
85
85
  /**A collection of static Discord post channels. It allows the bot to find back log, transcript or configured channels based on a linked ID. */
86
86
  posts: ODPostManager;
87
87
  /**A system for tracking messages or linking metadata, states or progress to Discord messages (ID-based). Features automatic garbage collection. */
@@ -129,7 +129,7 @@ export declare abstract class ODMain implements ODMainManagers {
129
129
  readonly cooldowns: ODCooldownManager;
130
130
  readonly helpmenu: ODHelpMenuManager;
131
131
  readonly statistics: ODStatisticManager;
132
- readonly code: ODCodeManager;
132
+ readonly tasks: ODTaskManager;
133
133
  readonly posts: ODPostManager;
134
134
  readonly states: ODStateManager;
135
135
  readonly client: ODClientManager;
package/dist/api/main.js CHANGED
@@ -33,7 +33,7 @@ export class ODMain {
33
33
  cooldowns;
34
34
  helpmenu;
35
35
  statistics;
36
- code;
36
+ tasks;
37
37
  posts;
38
38
  states;
39
39
  client;
@@ -44,7 +44,7 @@ export class ODMain {
44
44
  constructor(managers, project) {
45
45
  this.project = project;
46
46
  this.versions = managers.versions;
47
- this.versions.add(ODVersion.fromString("opendiscord:api", "v0.5.2"));
47
+ this.versions.add(ODVersion.fromString("opendiscord:api", "v0.5.4"));
48
48
  this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
49
49
  this.debugfile = managers.debugfile;
50
50
  this.console = managers.console;
@@ -68,7 +68,7 @@ export class ODMain {
68
68
  this.cooldowns = managers.cooldowns;
69
69
  this.helpmenu = managers.helpmenu;
70
70
  this.statistics = managers.statistics;
71
- this.code = managers.code;
71
+ this.tasks = managers.tasks;
72
72
  this.posts = managers.posts;
73
73
  this.states = managers.states;
74
74
  this.sharedFuses = managers.sharedFuses;
@@ -97,6 +97,7 @@ export declare class ODJsonDatabase<IdList extends ODDatabaseIdConstraint = ODDa
97
97
  * const didOverwrite = database.setData("category","key","value") //value can be any of the valid types
98
98
  * //You need an ODJsonDatabase class named "database" for this example to work!
99
99
  */
100
+ set<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId, key: string, value: IdList[CategoryId]): ODOptionalPromise<boolean>;
100
101
  set(category: string, key: string, value: ODValidJsonType): ODOptionalPromise<boolean>;
101
102
  /**Get the value of `category` & `key`. Returns `undefined` when non-existent!
102
103
  * @example
@@ -110,8 +111,10 @@ export declare class ODJsonDatabase<IdList extends ODDatabaseIdConstraint = ODDa
110
111
  * const didExist = database.deleteData("category","key") //delete this value
111
112
  * //You need an ODJsonDatabase class named "database" for this example to work!
112
113
  */
114
+ delete<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId, key: string): ODOptionalPromise<boolean>;
113
115
  delete(category: string, key: string): ODOptionalPromise<boolean>;
114
116
  /**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
117
+ exists(category: keyof ODNoGeneric<IdList>, key: string): ODOptionalPromise<boolean>;
115
118
  exists(category: string, key: string): ODOptionalPromise<boolean>;
116
119
  /**Get all values in `category`. Returns `undefined` when non-existent! */
117
120
  getCategory<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId): ODOptionalPromise<{
@@ -145,6 +148,7 @@ export declare class ODFormattedJsonDatabase<IdList extends ODDatabaseIdConstrai
145
148
  * const didOverwrite = database.setData("category","key","value") //value can be any of the valid types
146
149
  * //You need an ODFormattedJsonDatabase class named "database" for this example to work!
147
150
  */
151
+ set<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId, key: string, value: IdList[CategoryId]): ODOptionalPromise<boolean>;
148
152
  set(category: string, key: string, value: ODValidJsonType): ODOptionalPromise<boolean>;
149
153
  /**Get the value of `category` & `key`. Returns `undefined` when non-existent!
150
154
  * @example
@@ -158,8 +162,10 @@ export declare class ODFormattedJsonDatabase<IdList extends ODDatabaseIdConstrai
158
162
  * const didExist = database.deleteData("category","key") //delete this value
159
163
  * //You need an ODFormattedJsonDatabase class named "database" for this example to work!
160
164
  */
165
+ delete<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId, key: string): ODOptionalPromise<boolean>;
161
166
  delete(category: string, key: string): ODOptionalPromise<boolean>;
162
167
  /**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
168
+ exists(category: keyof ODNoGeneric<IdList>, key: string): ODOptionalPromise<boolean>;
163
169
  exists(category: string, key: string): ODOptionalPromise<boolean>;
164
170
  /**Get all values in `category`. Returns `undefined` when non-existent! */
165
171
  getCategory<CategoryId extends keyof ODNoGeneric<IdList>>(category: CategoryId): ODOptionalPromise<{
@@ -65,11 +65,6 @@ export class ODJsonDatabase extends ODDatabase {
65
65
  init() {
66
66
  this.#system.getData();
67
67
  }
68
- /**Set/overwrite the value of `category` & `key`. Returns `true` when overwritten!
69
- * @example
70
- * const didOverwrite = database.setData("category","key","value") //value can be any of the valid types
71
- * //You need an ODJsonDatabase class named "database" for this example to work!
72
- */
73
68
  set(category, key, value) {
74
69
  const currentList = this.#system.getData();
75
70
  const currentData = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -88,11 +83,6 @@ export class ODJsonDatabase extends ODDatabase {
88
83
  const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
89
84
  return tempresult ? tempresult.value : undefined;
90
85
  }
91
- /**Remove the value of `category` & `key`. Returns `undefined` when non-existent!
92
- * @example
93
- * const didExist = database.deleteData("category","key") //delete this value
94
- * //You need an ODJsonDatabase class named "database" for this example to work!
95
- */
96
86
  delete(category, key) {
97
87
  const currentList = this.#system.getData();
98
88
  const currentData = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -101,7 +91,6 @@ export class ODJsonDatabase extends ODDatabase {
101
91
  this.#system.setData(currentList);
102
92
  return currentData ? true : false;
103
93
  }
104
- /**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
105
94
  exists(category, key) {
106
95
  const currentList = this.#system.getData();
107
96
  const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -160,11 +149,6 @@ export class ODFormattedJsonDatabase extends ODDatabase {
160
149
  init() {
161
150
  this.#system.getData();
162
151
  }
163
- /**Set/overwrite the value of `category` & `key`. Returns `true` when overwritten!
164
- * @example
165
- * const didOverwrite = database.setData("category","key","value") //value can be any of the valid types
166
- * //You need an ODFormattedJsonDatabase class named "database" for this example to work!
167
- */
168
152
  set(category, key, value) {
169
153
  const currentList = this.#system.getData();
170
154
  const currentData = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -183,11 +167,6 @@ export class ODFormattedJsonDatabase extends ODDatabase {
183
167
  const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
184
168
  return tempresult ? tempresult.value : undefined;
185
169
  }
186
- /**Remove the value of `category` & `key`. Returns `undefined` when non-existent!
187
- * @example
188
- * const didExist = database.deleteData("category","key") //delete this value
189
- * //You need an ODFormattedJsonDatabase class named "database" for this example to work!
190
- */
191
170
  delete(category, key) {
192
171
  const currentList = this.#system.getData();
193
172
  const currentData = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -196,7 +175,6 @@ export class ODFormattedJsonDatabase extends ODDatabase {
196
175
  this.#system.setData(currentList);
197
176
  return currentData ? true : false;
198
177
  }
199
- /**Check if a value of `category` & `key` exists. Returns `false` when non-existent! */
200
178
  exists(category, key) {
201
179
  const currentList = this.#system.getData();
202
180
  const tempresult = currentList.find((d) => (d.category === category) && (d.key === key));
@@ -198,10 +198,10 @@ export interface ODSharedFuseList {
198
198
  statisticLoading: boolean;
199
199
  /**Initiate the default Open Discord statistics. */
200
200
  statisticInitiating: boolean;
201
- /**Load the default Open Discord code/functions. */
202
- codeLoading: boolean;
203
- /**Execute the default Open Discord code/functions. */
204
- codeExecution: boolean;
201
+ /**Load the default Open Discord task/functions. */
202
+ taskLoading: boolean;
203
+ /**Execute the default Open Discord task/functions. */
204
+ taskExecution: boolean;
205
205
  /**Load the default Open Discord livestatus. */
206
206
  liveStatusLoading: boolean;
207
207
  /**Load the default Open Discord startscreen. */
@@ -110,8 +110,8 @@ export class ODSharedFuseManager extends ODFuseManager {
110
110
  statisticScopesLoading: true,
111
111
  statisticLoading: true,
112
112
  statisticInitiating: true,
113
- codeLoading: true,
114
- codeExecution: true,
113
+ taskLoading: true,
114
+ taskExecution: true,
115
115
  liveStatusLoading: true,
116
116
  startScreenLoading: true,
117
117
  startScreenRendering: true,
@@ -0,0 +1,43 @@
1
+ import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
2
+ import { ODDebugger } from "./console.js";
3
+ /**## ODTask `class`
4
+ * This is an Open Discord task runner.
5
+ *
6
+ * Use this to execute a function just before the startup screen. (with more than 90% of the code already loaded)
7
+ * You can also specify a priority to change the execution order.
8
+ * In Open Ticket, this is used for the following processes:
9
+ * - Autoclose/delete
10
+ * - Database syncronisation (with tickets, statistics & used options)
11
+ * - Panel auto-update
12
+ * - Database Garbage Collection (removing tickets that don't exist anymore)
13
+ * - And more!
14
+ */
15
+ export declare class ODTask extends ODManagerData {
16
+ /**The priority of this task */
17
+ priority: number;
18
+ /**The main function of this task */
19
+ func: () => void | Promise<void>;
20
+ constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
21
+ }
22
+ /**## ODTaskManagerIdConstraint `type`
23
+ * The constraint/layout for id mappings/interfaces of the `ODTaskManager` class.
24
+ */
25
+ export type ODTaskManagerIdConstraint = Record<string, ODTask>;
26
+ /**## ODTaskManager `class`
27
+ * This is an Open Discord task manager.
28
+ *
29
+ * It manages & executes `ODTask`'s in the correct order.
30
+ *
31
+ * Register functions/tasks that execute just before the startup screen. (with more than 90% of the code already loaded)
32
+ */
33
+ export declare class ODTaskManager<IdList extends ODTaskManagerIdConstraint = ODTaskManagerIdConstraint> extends ODManager<ODTask> {
34
+ constructor(debug: ODDebugger);
35
+ /**Execute all `ODTask` functions in order of their priority (high to low). */
36
+ execute(): Promise<void>;
37
+ get<TaskId extends keyof ODNoGeneric<IdList>>(id: TaskId): IdList[TaskId];
38
+ get(id: ODValidId): ODTask | null;
39
+ remove<TaskId extends keyof ODNoGeneric<IdList>>(id: TaskId): IdList[TaskId];
40
+ remove(id: ODValidId): ODTask | null;
41
+ exists(id: keyof ODNoGeneric<IdList>): boolean;
42
+ exists(id: ODValidId): boolean;
43
+ }
@@ -1,23 +1,23 @@
1
1
  ///////////////////////////////////////
2
- //CODE MODULE
2
+ //TASK MODULE
3
3
  ///////////////////////////////////////
4
4
  import { ODManager, ODManagerData } from "./base.js";
5
- /**## ODCode `class`
6
- * This is an Open Discord code runner.
5
+ /**## ODTask `class`
6
+ * This is an Open Discord task runner.
7
7
  *
8
- * Using this, you're able to execute a function just before the startup screen. (90% of the code is already loaded)
8
+ * Use this to execute a function just before the startup screen. (with more than 90% of the code already loaded)
9
9
  * You can also specify a priority to change the execution order.
10
- * In Open Discord, this is used for the following processes:
10
+ * In Open Ticket, this is used for the following processes:
11
11
  * - Autoclose/delete
12
12
  * - Database syncronisation (with tickets, statistics & used options)
13
13
  * - Panel auto-update
14
14
  * - Database Garbage Collection (removing tickets that don't exist anymore)
15
15
  * - And more!
16
16
  */
17
- export class ODCode extends ODManagerData {
18
- /**The priority of this code */
17
+ export class ODTask extends ODManagerData {
18
+ /**The priority of this task */
19
19
  priority;
20
- /**The main function of this code */
20
+ /**The main function of this task */
21
21
  func;
22
22
  constructor(id, priority, func) {
23
23
  super(id);
@@ -25,18 +25,18 @@ export class ODCode extends ODManagerData {
25
25
  this.func = func;
26
26
  }
27
27
  }
28
- /**## ODCodeManager `class`
29
- * This is an Open Discord code manager.
28
+ /**## ODTaskManager `class`
29
+ * This is an Open Discord task manager.
30
30
  *
31
- * It manages & executes `ODCode`'s in the correct order.
31
+ * It manages & executes `ODTask`'s in the correct order.
32
32
  *
33
- * Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
33
+ * Register functions/tasks that execute just before the startup screen. (with more than 90% of the code already loaded)
34
34
  */
35
- export class ODCodeManager extends ODManager {
35
+ export class ODTaskManager extends ODManager {
36
36
  constructor(debug) {
37
- super(debug, "code");
37
+ super(debug, "task");
38
38
  }
39
- /**Execute all `ODCode` functions in order of their priority (high to low). */
39
+ /**Execute all `ODTask` functions in order of their priority (high to low). */
40
40
  async execute() {
41
41
  const derefArray = [...this.getAll()];
42
42
  const workers = derefArray.sort((a, b) => b.priority - a.priority);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@open-discord-bots/framework",
3
3
  "author": "DJj123dj",
4
- "version": "0.5.2",
4
+ "version": "0.5.4",
5
5
  "description": "The core framework of the popular open-source discord bots: Open Ticket & Open Moderation.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -1,43 +0,0 @@
1
- import { ODManager, ODManagerData, ODNoGeneric, ODValidId } from "./base.js";
2
- import { ODDebugger } from "./console.js";
3
- /**## ODCode `class`
4
- * This is an Open Discord code runner.
5
- *
6
- * Using this, you're able to execute a function just before the startup screen. (90% of the code is already loaded)
7
- * You can also specify a priority to change the execution order.
8
- * In Open Discord, this is used for the following processes:
9
- * - Autoclose/delete
10
- * - Database syncronisation (with tickets, statistics & used options)
11
- * - Panel auto-update
12
- * - Database Garbage Collection (removing tickets that don't exist anymore)
13
- * - And more!
14
- */
15
- export declare class ODCode extends ODManagerData {
16
- /**The priority of this code */
17
- priority: number;
18
- /**The main function of this code */
19
- func: () => void | Promise<void>;
20
- constructor(id: ODValidId, priority: number, func: () => void | Promise<void>);
21
- }
22
- /**## ODCodeManagerIdConstraint `type`
23
- * The constraint/layout for id mappings/interfaces of the `ODCodeManager` class.
24
- */
25
- export type ODCodeManagerIdConstraint = Record<string, ODCode>;
26
- /**## ODCodeManager `class`
27
- * This is an Open Discord code manager.
28
- *
29
- * It manages & executes `ODCode`'s in the correct order.
30
- *
31
- * Use this to register a function/code which executes just before the startup screen. (90% is already loaded)
32
- */
33
- export declare class ODCodeManager<IdList extends ODCodeManagerIdConstraint = ODCodeManagerIdConstraint> extends ODManager<ODCode> {
34
- constructor(debug: ODDebugger);
35
- /**Execute all `ODCode` functions in order of their priority (high to low). */
36
- execute(): Promise<void>;
37
- get<CodeId extends keyof ODNoGeneric<IdList>>(id: CodeId): IdList[CodeId];
38
- get(id: ODValidId): ODCode | null;
39
- remove<CodeId extends keyof ODNoGeneric<IdList>>(id: CodeId): IdList[CodeId];
40
- remove(id: ODValidId): ODCode | null;
41
- exists(id: keyof ODNoGeneric<IdList>): boolean;
42
- exists(id: ODValidId): boolean;
43
- }