zumito-framework 1.1.17 → 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;
|
package/dist/ZumitoFramework.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ZumitoFramework = void 0;
|
|
4
4
|
const Module_1 = require("./types/Module");
|
|
5
5
|
const ApiResponse_1 = require("./definitions/ApiResponse");
|
|
6
|
+
const baseModule_1 = require("./baseModule");
|
|
6
7
|
const express = require("express");
|
|
7
8
|
const fs = require('fs');
|
|
8
9
|
const path = require('path');
|
|
@@ -48,22 +49,34 @@ class ZumitoFramework {
|
|
|
48
49
|
* });
|
|
49
50
|
* @public
|
|
50
51
|
*/
|
|
51
|
-
constructor(settings) {
|
|
52
|
+
constructor(settings, callback) {
|
|
52
53
|
this.settings = settings;
|
|
53
54
|
this.modules = new Map();
|
|
54
55
|
this.commands = new Map();
|
|
55
56
|
this.events = new Map();
|
|
56
57
|
this.translations = new Map();
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
this.initialize().then(() => {
|
|
59
|
+
if (callback)
|
|
60
|
+
callback();
|
|
59
61
|
}).catch(err => {
|
|
60
|
-
console.error(
|
|
61
|
-
process.exit(1);
|
|
62
|
+
console.error(err);
|
|
62
63
|
});
|
|
63
|
-
|
|
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();
|
|
64
78
|
this.startApiServer();
|
|
65
79
|
this.registerModules();
|
|
66
|
-
this.initializeDiscordClient();
|
|
67
80
|
}
|
|
68
81
|
startApiServer() {
|
|
69
82
|
this.app = express();
|
|
@@ -106,7 +119,7 @@ class ZumitoFramework {
|
|
|
106
119
|
}
|
|
107
120
|
else
|
|
108
121
|
return;
|
|
109
|
-
this.registerModule(__dirname, 'baseModule',
|
|
122
|
+
this.registerModule(__dirname, 'baseModule', baseModule_1.baseModule);
|
|
110
123
|
fs.readdirSync(modulesFolder).forEach(file => {
|
|
111
124
|
this.registerModule(modulesFolder, file);
|
|
112
125
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.baseModule = void 0;
|
|
4
|
+
const Module_1 = require("../types/Module");
|
|
5
|
+
const interactionCreate_1 = require("./events/discord/interactionCreate");
|
|
6
|
+
const messageCreate_1 = require("./events/discord/messageCreate");
|
|
7
|
+
class baseModule extends Module_1.Module {
|
|
8
|
+
constructor(modulePath, framework) {
|
|
9
|
+
super(modulePath, framework);
|
|
10
|
+
}
|
|
11
|
+
registerEvents() {
|
|
12
|
+
this.events.set('interactionCreate', new interactionCreate_1.InteractionCreate());
|
|
13
|
+
this.events.set('messageCreate', new messageCreate_1.MessageCreate());
|
|
14
|
+
this.events.forEach(event => {
|
|
15
|
+
this.registerDiscordEvent(event);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.baseModule = baseModule;
|