zumito-framework 1.1.19 → 1.1.20

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.
@@ -37,7 +37,8 @@ export declare class ZumitoFramework {
37
37
  * });
38
38
  * @public
39
39
  */
40
- constructor(settings: FrameworkSettings);
40
+ constructor(settings: FrameworkSettings, callback?: Function);
41
+ initialize(): Promise<void>;
41
42
  startApiServer(): void;
42
43
  private registerModules;
43
44
  private registerModule;
@@ -49,22 +49,34 @@ class ZumitoFramework {
49
49
  * });
50
50
  * @public
51
51
  */
52
- constructor(settings) {
52
+ constructor(settings, callback) {
53
53
  this.settings = settings;
54
54
  this.modules = new Map();
55
55
  this.commands = new Map();
56
56
  this.events = new Map();
57
57
  this.translations = new Map();
58
- mongoose.connect(settings.mongoQueryString, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => {
59
- console.log('[✅] DB connection successful');
58
+ this.initialize().then(() => {
59
+ if (callback)
60
+ callback();
60
61
  }).catch(err => {
61
- console.error("Database connection error:", err.message);
62
- process.exit(1);
62
+ console.error(err);
63
63
  });
64
- this.database = mongoose.connection;
64
+ }
65
+ async initialize() {
66
+ try {
67
+ await mongoose.connect(this.settings.mongoQueryString, { useNewUrlParser: true, useUnifiedTopology: true });
68
+ }
69
+ catch (err) {
70
+ console.error("[❎] Database connection error:", err.message);
71
+ process.exit(1);
72
+ }
73
+ finally {
74
+ console.log('[✅] Database connection successful');
75
+ this.database = mongoose.connection;
76
+ }
77
+ this.initializeDiscordClient();
65
78
  this.startApiServer();
66
79
  this.registerModules();
67
- this.initializeDiscordClient();
68
80
  }
69
81
  startApiServer() {
70
82
  this.app = express();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "description": "Discord.js bot framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",