@open-discord-bots/framework 0.4.0 → 0.4.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/dist/api/main.js +1 -1
- package/dist/api/modules/base.d.ts +17 -9
- package/dist/api/modules/base.js +24 -13
- package/package.json +1 -1
package/dist/api/main.js
CHANGED
|
@@ -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.4.
|
|
47
|
+
this.versions.add(ODVersion.fromString("opendiscord:api", "v0.4.1"));
|
|
48
48
|
this.versions.add(ODVersion.fromString("opendiscord:livestatus", "v2.0.0"));
|
|
49
49
|
this.debugfile = managers.debugfile;
|
|
50
50
|
this.console = managers.console;
|
|
@@ -243,6 +243,14 @@ export declare class ODVersion extends ODManagerData {
|
|
|
243
243
|
/**Check if this version is matches the minor version (`vX.X.X`) of the provided `requirement`. */
|
|
244
244
|
minor(requirement: string | ODVersion): boolean;
|
|
245
245
|
}
|
|
246
|
+
export interface ODVersionMigrationFunctions {
|
|
247
|
+
/**The migration to run before any part of the bot is started (pure node.js). */
|
|
248
|
+
beforeStartupMigrate?: () => void | Promise<void>;
|
|
249
|
+
/**The migration to run in the Open Discord migration context (incl. flags, configs, database). */
|
|
250
|
+
contextMigrate?: () => void | Promise<void>;
|
|
251
|
+
/**The migration to run when the bot starts like normal (incl. plugins) */
|
|
252
|
+
afterStartupMigrate?: () => void | Promise<void>;
|
|
253
|
+
}
|
|
246
254
|
/**## ODVersionMigration `class`
|
|
247
255
|
* This class is used to manage data migration between Open Ticket versions.
|
|
248
256
|
*
|
|
@@ -251,15 +259,15 @@ export declare class ODVersion extends ODManagerData {
|
|
|
251
259
|
export declare class ODVersionMigration {
|
|
252
260
|
/**The version to migrate data to */
|
|
253
261
|
version: ODVersion;
|
|
254
|
-
/**The migration
|
|
255
|
-
private
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
/**Run this
|
|
260
|
-
|
|
261
|
-
/**Run this
|
|
262
|
-
|
|
262
|
+
/**The migration functions */
|
|
263
|
+
private functions;
|
|
264
|
+
constructor(version: ODVersion, functions: ODVersionMigrationFunctions);
|
|
265
|
+
/**Run this migration before any other part of the bot is started (pure node.js). */
|
|
266
|
+
migrateBeforeStartup(): Promise<boolean>;
|
|
267
|
+
/**Run this migration in the Open Discord migration context (incl. flags, configs, database). */
|
|
268
|
+
migrateInContext(): Promise<boolean>;
|
|
269
|
+
/**Run this migration when the bot starts like normal (incl. plugins) */
|
|
270
|
+
migrateAfterStartup(): Promise<boolean>;
|
|
263
271
|
}
|
|
264
272
|
/**## ODHTTPGetRequest `class`
|
|
265
273
|
* This is a class that can help you with creating simple HTTP GET requests.
|
package/dist/api/modules/base.js
CHANGED
|
@@ -505,19 +505,17 @@ export class ODVersion extends ODManagerData {
|
|
|
505
505
|
export class ODVersionMigration {
|
|
506
506
|
/**The version to migrate data to */
|
|
507
507
|
version;
|
|
508
|
-
/**The migration
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
migrateAfterInitFunc;
|
|
512
|
-
constructor(version, migrateFunc, migrateAfterInitFunc) {
|
|
508
|
+
/**The migration functions */
|
|
509
|
+
functions;
|
|
510
|
+
constructor(version, functions) {
|
|
513
511
|
this.version = version;
|
|
514
|
-
this.
|
|
515
|
-
this.migrateAfterInitFunc = migrateAfterInitFunc;
|
|
512
|
+
this.functions = functions;
|
|
516
513
|
}
|
|
517
|
-
/**Run this
|
|
518
|
-
async
|
|
514
|
+
/**Run this migration before any other part of the bot is started (pure node.js). */
|
|
515
|
+
async migrateBeforeStartup() {
|
|
519
516
|
try {
|
|
520
|
-
|
|
517
|
+
if (this.functions.beforeStartupMigrate)
|
|
518
|
+
await this.functions.beforeStartupMigrate();
|
|
521
519
|
return true;
|
|
522
520
|
}
|
|
523
521
|
catch (err) {
|
|
@@ -525,10 +523,23 @@ export class ODVersionMigration {
|
|
|
525
523
|
return false;
|
|
526
524
|
}
|
|
527
525
|
}
|
|
528
|
-
/**Run this
|
|
529
|
-
async
|
|
526
|
+
/**Run this migration in the Open Discord migration context (incl. flags, configs, database). */
|
|
527
|
+
async migrateInContext() {
|
|
530
528
|
try {
|
|
531
|
-
|
|
529
|
+
if (this.functions.contextMigrate)
|
|
530
|
+
await this.functions.contextMigrate();
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
catch (err) {
|
|
534
|
+
process.emit("uncaughtException", err);
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
/**Run this migration when the bot starts like normal (incl. plugins) */
|
|
539
|
+
async migrateAfterStartup() {
|
|
540
|
+
try {
|
|
541
|
+
if (this.functions.afterStartupMigrate)
|
|
542
|
+
await this.functions.afterStartupMigrate();
|
|
532
543
|
return true;
|
|
533
544
|
}
|
|
534
545
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-discord-bots/framework",
|
|
3
3
|
"author": "DJj123dj",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.1",
|
|
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",
|