zumito-framework 1.1.22 → 1.1.26
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/types/Module.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare abstract class Module {
|
|
|
7
7
|
protected commands: Map<string, Command>;
|
|
8
8
|
protected events: Map<string, FrameworkEvent>;
|
|
9
9
|
protected translations: Map<string, string>;
|
|
10
|
+
protected models: Map<string, any>;
|
|
10
11
|
constructor(path: any, framework: any);
|
|
11
12
|
registerCommands(): void;
|
|
12
13
|
getCommands(): Map<string, Command>;
|
|
@@ -17,4 +18,6 @@ export declare abstract class Module {
|
|
|
17
18
|
registerTranslations(): void;
|
|
18
19
|
getTranslations(): Map<string, string>;
|
|
19
20
|
parseTranslation(path: string, json: any): any;
|
|
21
|
+
registerModels(): void;
|
|
22
|
+
getModels(): Map<string, any>;
|
|
20
23
|
}
|
package/dist/types/Module.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Module = void 0;
|
|
4
|
+
const mongoose = require("mongoose");
|
|
4
5
|
const fs = require('fs');
|
|
5
6
|
const path = require('path');
|
|
6
7
|
class Module {
|
|
@@ -9,6 +10,7 @@ class Module {
|
|
|
9
10
|
commands = new Map();
|
|
10
11
|
events = new Map();
|
|
11
12
|
translations = new Map();
|
|
13
|
+
models = new Map();
|
|
12
14
|
constructor(path, framework) {
|
|
13
15
|
this.path = path;
|
|
14
16
|
this.framework = framework;
|
|
@@ -68,7 +70,7 @@ class Module {
|
|
|
68
70
|
client: this.framework.client,
|
|
69
71
|
};
|
|
70
72
|
args.forEach(arg => {
|
|
71
|
-
finalArgs[arg.constructor.name] = arg;
|
|
73
|
+
finalArgs[arg.constructor.name.toLowerCase()] = arg;
|
|
72
74
|
});
|
|
73
75
|
return finalArgs;
|
|
74
76
|
}
|
|
@@ -95,8 +97,23 @@ class Module {
|
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
else {
|
|
98
|
-
this.translations.set(path, json);
|
|
100
|
+
this.translations.set(path.slice(0, -1), json);
|
|
99
101
|
}
|
|
100
102
|
}
|
|
103
|
+
registerModels() {
|
|
104
|
+
if (!fs.existsSync(path.join(this.path, 'models')))
|
|
105
|
+
return;
|
|
106
|
+
fs.readdirSync(path.join(this.path, 'models')).forEach(file => {
|
|
107
|
+
if (file.endsWith('.json')) {
|
|
108
|
+
let modelName = file.slice(0, -5).charAt(0).toUpperCase() + file.slice(0, -5).slice(1);
|
|
109
|
+
let modelDefiniton = require(`${this.path}/models/${file}`);
|
|
110
|
+
const schema = new mongoose.Schema(modelDefiniton);
|
|
111
|
+
this.models.set(modelDefiniton.name, mongoose.model(modelName, schema));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
getModels() {
|
|
116
|
+
return this.models;
|
|
117
|
+
}
|
|
101
118
|
}
|
|
102
119
|
exports.Module = Module;
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Command, CommandParameters } from "zumito-framework";
|
|
2
2
|
|
|
3
|
-
export class
|
|
4
|
-
|
|
5
|
-
name: 'test';
|
|
3
|
+
export class {{command.charAt(0).toUpperCase() + command.slice(1)}} extends Command {
|
|
6
4
|
|
|
7
5
|
execute({ message, interaction, args, client, framework }: CommandParameters): void {
|
|
8
|
-
message.
|
|
9
|
-
content: "
|
|
6
|
+
(message || interaction).reply({
|
|
7
|
+
content: "Message content",
|
|
10
8
|
});
|
|
11
9
|
}
|
|
12
10
|
}
|