zumito-framework 1.1.79 → 1.1.81
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/ZumitoFramework.d.ts +2 -1
- package/dist/ZumitoFramework.js +4 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/types/Module.d.ts +0 -4
- package/dist/types/Module.js +0 -27
- package/package.json +4 -4
- package/dist/types/FrameworkRouter.d.ts +0 -6
- package/dist/types/FrameworkRouter.js +0 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Client, GuildMember, TextChannel } from 'discord.js';
|
|
2
3
|
import { Command } from './types/Command.js';
|
|
3
4
|
import { DatabaseModel } from './types/DatabaseModel.js';
|
|
@@ -64,7 +65,7 @@ export declare class ZumitoFramework {
|
|
|
64
65
|
* @see {@link TranslationManager}
|
|
65
66
|
*/
|
|
66
67
|
translations: TranslationManager;
|
|
67
|
-
routes:
|
|
68
|
+
routes: any;
|
|
68
69
|
/**
|
|
69
70
|
* The database models loaded in the framework.
|
|
70
71
|
* @type {Array<DatabaseModel>}
|
package/dist/ZumitoFramework.js
CHANGED
|
@@ -131,7 +131,6 @@ export class ZumitoFramework {
|
|
|
131
131
|
this.events = new Map();
|
|
132
132
|
this.translations = new TranslationManager();
|
|
133
133
|
this.models = [];
|
|
134
|
-
this.routes = new Map();
|
|
135
134
|
this.eventManager = new EventManager();
|
|
136
135
|
if (settings.logLevel) {
|
|
137
136
|
console.logLevel = settings.logLevel;
|
|
@@ -210,9 +209,6 @@ export class ZumitoFramework {
|
|
|
210
209
|
//Route Prefixes
|
|
211
210
|
//this.app.use("/", indexRouter);
|
|
212
211
|
//this.app.use("/api/", apiRouter);
|
|
213
|
-
this.routes.forEach((router, path) => {
|
|
214
|
-
this.app.use(path, router);
|
|
215
|
-
});
|
|
216
212
|
// throw 404 if URL not found
|
|
217
213
|
this.app.all('*', function (req, res) {
|
|
218
214
|
return ApiResponse.notFoundResponse(res, 'Page not found');
|
|
@@ -304,8 +300,12 @@ export class ZumitoFramework {
|
|
|
304
300
|
moduleInstance.getModels().forEach((model) => {
|
|
305
301
|
this.models.push(model);
|
|
306
302
|
});
|
|
303
|
+
/*
|
|
304
|
+
|
|
307
305
|
// Register module routes
|
|
308
306
|
this.routes = new Map([...this.routes, ...moduleInstance.getRoutes()]);
|
|
307
|
+
|
|
308
|
+
*/
|
|
309
309
|
}
|
|
310
310
|
/**
|
|
311
311
|
* Initializes the Discord client using the Discord.js library.
|
package/dist/index.d.ts
CHANGED
|
@@ -21,5 +21,4 @@ import { TranslationManager } from './TranslationManager.js';
|
|
|
21
21
|
import { ZumitoFramework } from './ZumitoFramework.js';
|
|
22
22
|
import * as discord from 'discord.js';
|
|
23
23
|
import { EventParameters } from './types/EventParameters.js';
|
|
24
|
-
|
|
25
|
-
export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition, CommandChoiceDefinition, ButtonPressed, ButtonPressedParams, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, PresenceDataRule, RuledPresenceData, StatusManagerOptions, discord, EventParameters, FrameworkRouter, };
|
|
24
|
+
export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition, CommandChoiceDefinition, ButtonPressed, ButtonPressedParams, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, PresenceDataRule, RuledPresenceData, StatusManagerOptions, discord, EventParameters, };
|
package/dist/index.js
CHANGED
|
@@ -13,5 +13,4 @@ import { Translation } from './types/Translation.js';
|
|
|
13
13
|
import { TranslationManager } from './TranslationManager.js';
|
|
14
14
|
import { ZumitoFramework } from './ZumitoFramework.js';
|
|
15
15
|
import * as discord from 'discord.js';
|
|
16
|
-
|
|
17
|
-
export { ZumitoFramework, Command, Module, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, CommandType, ButtonPressed, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, discord, FrameworkRouter, };
|
|
16
|
+
export { ZumitoFramework, Command, Module, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, CommandType, ButtonPressed, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, discord, };
|
package/dist/types/Module.d.ts
CHANGED
|
@@ -2,14 +2,12 @@ import { ZumitoFramework } from '../ZumitoFramework.js';
|
|
|
2
2
|
import { Command } from './Command.js';
|
|
3
3
|
import { FrameworkEvent } from './FrameworkEvent.js';
|
|
4
4
|
import { DatabaseModel } from './DatabaseModel.js';
|
|
5
|
-
import { Request, Response } from 'express';
|
|
6
5
|
export declare abstract class Module {
|
|
7
6
|
protected path: string;
|
|
8
7
|
protected framework: ZumitoFramework;
|
|
9
8
|
protected commands: Map<string, Command>;
|
|
10
9
|
protected events: Map<string, FrameworkEvent>;
|
|
11
10
|
protected models: Array<DatabaseModel>;
|
|
12
|
-
protected routes: Map<string, (req: Request, res: Response) => void>;
|
|
13
11
|
constructor(path: any, framework: any);
|
|
14
12
|
initialize(): Promise<void>;
|
|
15
13
|
registerCommands(): Promise<void>;
|
|
@@ -27,6 +25,4 @@ export declare abstract class Module {
|
|
|
27
25
|
parseTranslation(path: string, lang: string, json: any): any;
|
|
28
26
|
registerModels(): Promise<void>;
|
|
29
27
|
getModels(): Array<DatabaseModel>;
|
|
30
|
-
registerRoutes(subpath?: string): Promise<void>;
|
|
31
|
-
getRoutes(): Map<string, (req: Request, res: Response) => void>;
|
|
32
28
|
}
|
package/dist/types/Module.js
CHANGED
|
@@ -4,14 +4,12 @@ import boxen from 'boxen';
|
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { ButtonInteraction, CommandInteraction, ModalSubmitInteraction, StringSelectMenuInteraction, } from 'discord.js';
|
|
7
|
-
import { FrameworkRouter } from "./FrameworkRouter.js";
|
|
8
7
|
export class Module {
|
|
9
8
|
path;
|
|
10
9
|
framework;
|
|
11
10
|
commands = new Map();
|
|
12
11
|
events = new Map();
|
|
13
12
|
models = [];
|
|
14
|
-
routes = new Map();
|
|
15
13
|
constructor(path, framework) {
|
|
16
14
|
this.path = path;
|
|
17
15
|
this.framework = framework;
|
|
@@ -21,7 +19,6 @@ export class Module {
|
|
|
21
19
|
await this.registerEvents();
|
|
22
20
|
await this.registerTranslations();
|
|
23
21
|
await this.registerModels();
|
|
24
|
-
await this.registerRoutes();
|
|
25
22
|
}
|
|
26
23
|
async registerCommands() {
|
|
27
24
|
if (fs.existsSync(path.join(this.path, 'commands'))) {
|
|
@@ -210,28 +207,4 @@ export class Module {
|
|
|
210
207
|
getModels() {
|
|
211
208
|
return this.models;
|
|
212
209
|
}
|
|
213
|
-
async registerRoutes(subpath = '') {
|
|
214
|
-
if (!fs.existsSync(path.join(this.path, 'routes', subpath)))
|
|
215
|
-
return;
|
|
216
|
-
const files = fs.readdirSync(path.join(this.path, 'routes', subpath));
|
|
217
|
-
for (const file of files) {
|
|
218
|
-
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
|
219
|
-
const Router = await import('file://' + `${this.path}/routes/${subpath}/${file}`).then(r => Object.values(r)[0]);
|
|
220
|
-
if (Router.prototype instanceof FrameworkRouter) {
|
|
221
|
-
const router = new Router(subpath ? '/' + subpath : '');
|
|
222
|
-
this.routes = new Map([...this.routes, ...router.getRoutes()]);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
console.warn(`[🔄🟡 ] ${subpath}/${file} is not a valid router on module ${this.constructor.name} \n It must extend the FrameworkRouter class instead of ${Router.prototype}`);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
else if (fs.lstatSync(path.join(this.path, 'routes', subpath, file)).isDirectory()) {
|
|
230
|
-
await this.registerRoutes(path.join(subpath, file));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
getRoutes() {
|
|
235
|
-
return this.routes;
|
|
236
|
-
}
|
|
237
210
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zumito-framework",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.81",
|
|
4
4
|
"description": "Discord.js bot framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"chokidar": "^3.5.3",
|
|
30
30
|
"cookie-parser": "^1.4.6",
|
|
31
31
|
"cors": "^2.8.5",
|
|
32
|
-
"discord.js": "^14.
|
|
32
|
+
"discord.js": "^14.14.1",
|
|
33
33
|
"error-stack-parser": "^2.1.4",
|
|
34
34
|
"express": "^4.18.1",
|
|
35
35
|
"leven": "^4.0.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"eslint-plugin-check-file": "^2.2.0",
|
|
47
47
|
"eslint-plugin-prettier": "^4.2.1",
|
|
48
48
|
"prettier": "^2.8.3",
|
|
49
|
-
"typedoc": "^0.
|
|
50
|
-
"typescript": "^
|
|
49
|
+
"typedoc": "^0.25.4",
|
|
50
|
+
"typescript": "^5.3.3"
|
|
51
51
|
},
|
|
52
52
|
"type": "module",
|
|
53
53
|
"exports": {
|