zumito-framework 1.1.81 → 1.1.82
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 +13 -14
- package/dist/ZumitoFramework.js +18 -57
- package/dist/{types → definitions}/Module.d.ts +4 -7
- package/dist/definitions/Module.js +129 -0
- package/dist/{types → definitions}/Translation.d.ts +0 -1
- package/dist/{types → definitions}/Translation.js +0 -1
- package/dist/{types → definitions/commands}/Command.d.ts +1 -1
- package/dist/{types → definitions/commands}/CommandParameters.d.ts +1 -1
- package/dist/{types → definitions/parameters}/EventParameters.d.ts +1 -1
- package/dist/{types/Commands → definitions/parameters}/SelectMenu.d.ts +1 -1
- package/dist/{types → definitions/parameters}/SelectMenuParameters.d.ts +1 -1
- package/dist/index.d.ts +21 -21
- package/dist/index.js +13 -13
- package/dist/{baseModule → modules/core/baseModule}/events/discord/InteractionCreate.d.ts +3 -3
- package/dist/{baseModule → modules/core/baseModule}/events/discord/InteractionCreate.js +3 -3
- package/dist/{baseModule → modules/core/baseModule}/events/discord/MessageCreate.d.ts +2 -2
- package/dist/{baseModule → modules/core/baseModule}/events/discord/MessageCreate.js +6 -6
- package/dist/{baseModule → modules/core/baseModule}/models/Guild.d.ts +1 -1
- package/dist/{baseModule → modules/core/baseModule}/models/Guild.js +1 -1
- package/dist/services/CommandManager.d.ts +40 -0
- package/dist/services/CommandManager.js +160 -0
- package/dist/services/ModuleManager.d.ts +17 -0
- package/dist/services/ModuleManager.js +78 -0
- package/dist/{managers → services}/StatusManager.d.ts +1 -1
- package/dist/services/TranslationManager.d.ts +34 -0
- package/dist/services/TranslationManager.js +126 -0
- package/package.json +4 -4
- package/dist/TranslationManager.d.ts +0 -15
- package/dist/TranslationManager.js +0 -41
- package/dist/baseModule/index.d.ts +0 -7
- package/dist/baseModule/index.js +0 -20
- package/dist/types/Module.js +0 -210
- /package/dist/{types → definitions}/DatabaseModel.d.ts +0 -0
- /package/dist/{types → definitions}/DatabaseModel.js +0 -0
- /package/dist/{types → definitions}/FrameworkEvent.d.ts +0 -0
- /package/dist/{types → definitions}/FrameworkEvent.js +0 -0
- /package/dist/{types → definitions}/FrameworkSettings.d.ts +0 -0
- /package/dist/{types → definitions}/FrameworkSettings.js +0 -0
- /package/dist/{types → definitions}/StatusManagerOptions.d.ts +0 -0
- /package/dist/{types → definitions}/StatusManagerOptions.js +0 -0
- /package/dist/definitions/{ApiResponse.d.ts → api/ApiResponse.d.ts} +0 -0
- /package/dist/definitions/{ApiResponse.js → api/ApiResponse.js} +0 -0
- /package/dist/{types → definitions/commands}/Command.js +0 -0
- /package/dist/{types → definitions/commands}/CommandArgDefinition.d.ts +0 -0
- /package/dist/{types → definitions/commands}/CommandArgDefinition.js +0 -0
- /package/dist/{types → definitions/commands}/CommandArguments.d.ts +0 -0
- /package/dist/{types → definitions/commands}/CommandArguments.js +0 -0
- /package/dist/{types → definitions/commands}/CommandChoiceDefinition.d.ts +0 -0
- /package/dist/{types → definitions/commands}/CommandChoiceDefinition.js +0 -0
- /package/dist/{types → definitions/commands}/CommandParameters.js +0 -0
- /package/dist/{types → definitions/commands}/CommandType.d.ts +0 -0
- /package/dist/{types → definitions/commands}/CommandType.js +0 -0
- /package/dist/{types/Commands → definitions/parameters}/ButtonPressed.d.ts +0 -0
- /package/dist/{types/Commands → definitions/parameters}/ButtonPressed.js +0 -0
- /package/dist/{types/Commands → definitions/parameters}/ButtonPressedParams.d.ts +0 -0
- /package/dist/{types/Commands → definitions/parameters}/ButtonPressedParams.js +0 -0
- /package/dist/{types → definitions/parameters}/EventParameters.js +0 -0
- /package/dist/{types/Commands → definitions/parameters}/SelectMenu.js +0 -0
- /package/dist/{types → definitions/parameters}/SelectMenuParameters.js +0 -0
- /package/dist/{utils → services}/DatabaseConfigLoader.d.ts +0 -0
- /package/dist/{utils → services}/DatabaseConfigLoader.js +0 -0
- /package/dist/{utils → services}/EmojiFallback.d.ts +0 -0
- /package/dist/{utils → services}/EmojiFallback.js +0 -0
- /package/dist/{managers → services}/EmojiManager.d.ts +0 -0
- /package/dist/{managers → services}/EmojiManager.js +0 -0
- /package/dist/{managers → services}/EventManager.d.ts +0 -0
- /package/dist/{managers → services}/EventManager.js +0 -0
- /package/dist/{utils → services}/InteractionIdGenerator.d.ts +0 -0
- /package/dist/{utils → services}/InteractionIdGenerator.js +0 -0
- /package/dist/{managers → services}/StatusManager.js +0 -0
- /package/dist/{utils → services}/TextFormatter.d.ts +0 -0
- /package/dist/{utils → services}/TextFormatter.js +0 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Client, GuildMember, TextChannel } from 'discord.js';
|
|
3
|
-
import {
|
|
4
|
-
import { DatabaseModel } from './types/DatabaseModel.js';
|
|
2
|
+
import { DatabaseModel } from './definitions/DatabaseModel.js';
|
|
5
3
|
import { EventEmitter } from 'events';
|
|
6
|
-
import { FrameworkEvent } from './
|
|
7
|
-
import { FrameworkSettings } from './
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
4
|
+
import { FrameworkEvent } from './definitions/FrameworkEvent.js';
|
|
5
|
+
import { FrameworkSettings } from './definitions/FrameworkSettings.js';
|
|
6
|
+
import { StatusManager } from './services/StatusManager.js';
|
|
7
|
+
import { TranslationManager } from './services/TranslationManager.js';
|
|
8
|
+
import { EventManager } from './services/EventManager.js';
|
|
9
|
+
import { CommandManager } from './services/CommandManager.js';
|
|
10
|
+
import { ModuleManager } from './services/ModuleManager.js';
|
|
12
11
|
/**
|
|
13
12
|
* @class ZumitoFramework
|
|
14
13
|
* @description The main class of the framework.
|
|
@@ -39,18 +38,18 @@ export declare class ZumitoFramework {
|
|
|
39
38
|
*/
|
|
40
39
|
settings: FrameworkSettings;
|
|
41
40
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @type {
|
|
41
|
+
* Module manager instance
|
|
42
|
+
* @type {ModuleManager}
|
|
44
43
|
* @private
|
|
45
44
|
*/
|
|
46
|
-
modules:
|
|
45
|
+
modules: ModuleManager;
|
|
47
46
|
/**
|
|
48
47
|
* The commands loaded in the framework.
|
|
49
|
-
* @type {
|
|
48
|
+
* @type {CommandManager}
|
|
50
49
|
* @private
|
|
51
50
|
* @see {@link Command}
|
|
52
51
|
*/
|
|
53
|
-
commands:
|
|
52
|
+
commands: CommandManager;
|
|
54
53
|
/**
|
|
55
54
|
* The events loaded in the framework.
|
|
56
55
|
* @type {Map<string, FrameworkEvent>}
|
package/dist/ZumitoFramework.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as url from 'url';
|
|
3
3
|
import { Client, SlashCommandBuilder, } from 'discord.js';
|
|
4
|
-
import { ApiResponse } from './definitions/ApiResponse.js';
|
|
5
|
-
import { CommandType } from './
|
|
4
|
+
import { ApiResponse } from './definitions/api/ApiResponse.js';
|
|
5
|
+
import { CommandType } from './definitions/commands/CommandType.js';
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
|
-
import { Module } from './types/Module.js';
|
|
8
7
|
import { REST } from '@discordjs/rest';
|
|
9
8
|
import { Routes } from 'discord-api-types/v9';
|
|
10
|
-
import { StatusManager } from './
|
|
11
|
-
import { TranslationManager } from './TranslationManager.js';
|
|
12
|
-
import { baseModule } from './baseModule/index.js';
|
|
9
|
+
import { StatusManager } from './services/StatusManager.js';
|
|
10
|
+
import { TranslationManager } from './services/TranslationManager.js';
|
|
13
11
|
import { betterLogging } from 'better-logging';
|
|
14
12
|
import canario from 'canario';
|
|
15
13
|
import cookieParser from 'cookie-parser';
|
|
@@ -17,7 +15,9 @@ import cors from 'cors';
|
|
|
17
15
|
import express from 'express';
|
|
18
16
|
import http from 'http';
|
|
19
17
|
import path from 'path';
|
|
20
|
-
import { EventManager } from './
|
|
18
|
+
import { EventManager } from './services/EventManager.js';
|
|
19
|
+
import { CommandManager } from './services/CommandManager.js';
|
|
20
|
+
import { ModuleManager } from './services/ModuleManager.js';
|
|
21
21
|
// import better-logging
|
|
22
22
|
betterLogging(console);
|
|
23
23
|
/**
|
|
@@ -50,14 +50,14 @@ export class ZumitoFramework {
|
|
|
50
50
|
*/
|
|
51
51
|
settings;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @type {
|
|
53
|
+
* Module manager instance
|
|
54
|
+
* @type {ModuleManager}
|
|
55
55
|
* @private
|
|
56
56
|
*/
|
|
57
57
|
modules;
|
|
58
58
|
/**
|
|
59
59
|
* The commands loaded in the framework.
|
|
60
|
-
* @type {
|
|
60
|
+
* @type {CommandManager}
|
|
61
61
|
* @private
|
|
62
62
|
* @see {@link Command}
|
|
63
63
|
*/
|
|
@@ -126,8 +126,8 @@ export class ZumitoFramework {
|
|
|
126
126
|
*/
|
|
127
127
|
constructor(settings, callback) {
|
|
128
128
|
this.settings = settings;
|
|
129
|
-
this.modules = new
|
|
130
|
-
this.commands = new
|
|
129
|
+
this.modules = new ModuleManager(this);
|
|
130
|
+
this.commands = new CommandManager(this);
|
|
131
131
|
this.events = new Map();
|
|
132
132
|
this.translations = new TranslationManager();
|
|
133
133
|
this.models = [];
|
|
@@ -237,7 +237,7 @@ export class ZumitoFramework {
|
|
|
237
237
|
else
|
|
238
238
|
return;
|
|
239
239
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
240
|
-
await this.registerModule(__dirname, '
|
|
240
|
+
await this.registerModule(path.join(__dirname, 'modules', 'core'), 'baseModule');
|
|
241
241
|
const files = fs.readdirSync(modulesFolder);
|
|
242
242
|
for (const file of files) {
|
|
243
243
|
await this.registerModule(modulesFolder, file);
|
|
@@ -261,51 +261,12 @@ export class ZumitoFramework {
|
|
|
261
261
|
}
|
|
262
262
|
async registerModule(modulesFolder, moduleName, module) {
|
|
263
263
|
if (!module) {
|
|
264
|
-
|
|
265
|
-
module = await import('file://' + path.join(modulesFolder, moduleName, 'index.js'));
|
|
266
|
-
module = Object.values(module)[0];
|
|
267
|
-
}
|
|
268
|
-
else if (fs.existsSync(path.join(modulesFolder, moduleName, 'index.ts'))) {
|
|
269
|
-
module = await import('file://' + path.join(modulesFolder, moduleName, 'index.ts'));
|
|
270
|
-
module = Object.values(module)[0];
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
module = Module;
|
|
274
|
-
}
|
|
264
|
+
module = await this.modules.loadModuleFile(path.join(modulesFolder, moduleName));
|
|
275
265
|
}
|
|
276
266
|
// Create module instance
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
await moduleInstance.initialize();
|
|
281
|
-
this.modules.set(moduleName || moduleInstance.constructor.name, moduleInstance);
|
|
282
|
-
}
|
|
283
|
-
catch (err) {
|
|
284
|
-
console.error(`[📦🔴] Error loading module ${moduleName}: ${err.message}`);
|
|
285
|
-
console.error(err.stack);
|
|
286
|
-
}
|
|
287
|
-
// Register module commands
|
|
288
|
-
if (moduleInstance.getCommands()) {
|
|
289
|
-
moduleInstance.getCommands().forEach((command) => {
|
|
290
|
-
this.commands.set(command.name, command);
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
this.commands = new Map([
|
|
294
|
-
...this.commands,
|
|
295
|
-
...moduleInstance.getCommands(),
|
|
296
|
-
]);
|
|
297
|
-
// Register module events
|
|
298
|
-
this.events = new Map([...this.events, ...moduleInstance.getEvents()]);
|
|
299
|
-
// Register models
|
|
300
|
-
moduleInstance.getModels().forEach((model) => {
|
|
301
|
-
this.models.push(model);
|
|
302
|
-
});
|
|
303
|
-
/*
|
|
304
|
-
|
|
305
|
-
// Register module routes
|
|
306
|
-
this.routes = new Map([...this.routes, ...moduleInstance.getRoutes()]);
|
|
307
|
-
|
|
308
|
-
*/
|
|
267
|
+
const moduleInstance = await this.modules.instanceModule(module, path.join(modulesFolder, moduleName), moduleName);
|
|
268
|
+
// Register module in the framework
|
|
269
|
+
this.modules.registerModule(moduleInstance);
|
|
309
270
|
}
|
|
310
271
|
/**
|
|
311
272
|
* Initializes the Discord client using the Discord.js library.
|
|
@@ -428,7 +389,7 @@ export class ZumitoFramework {
|
|
|
428
389
|
}
|
|
429
390
|
async refreshSlashCommands() {
|
|
430
391
|
const rest = new REST({ version: '10' }).setToken(this.settings.discordClientOptions.token);
|
|
431
|
-
const commands = Array.from(this.commands.values())
|
|
392
|
+
const commands = Array.from(this.commands.getAll().values())
|
|
432
393
|
.filter((command) => command.type == CommandType.slash ||
|
|
433
394
|
command.type == CommandType.separated ||
|
|
434
395
|
command.type == CommandType.any)
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { ZumitoFramework } from '../ZumitoFramework.js';
|
|
2
|
-
import { Command } from './Command.js';
|
|
2
|
+
import { Command } from './commands/Command.js';
|
|
3
3
|
import { FrameworkEvent } from './FrameworkEvent.js';
|
|
4
4
|
import { DatabaseModel } from './DatabaseModel.js';
|
|
5
|
+
import { CommandManager } from '../services/CommandManager.js';
|
|
5
6
|
export declare abstract class Module {
|
|
6
7
|
protected path: string;
|
|
7
8
|
protected framework: ZumitoFramework;
|
|
8
|
-
protected commands:
|
|
9
|
+
protected commands: CommandManager;
|
|
9
10
|
protected events: Map<string, FrameworkEvent>;
|
|
10
11
|
protected models: Array<DatabaseModel>;
|
|
12
|
+
protected commandManager: CommandManager;
|
|
11
13
|
constructor(path: any, framework: any);
|
|
12
14
|
initialize(): Promise<void>;
|
|
13
15
|
registerCommands(): Promise<void>;
|
|
14
|
-
onCommandCreated(filePath: string): Promise<void>;
|
|
15
|
-
onCommandChanged(filePath: string): Promise<void>;
|
|
16
|
-
onErrorLoadingCommand(error: Error): void;
|
|
17
16
|
getCommands(): Map<string, Command>;
|
|
18
17
|
registerEvents(): Promise<void>;
|
|
19
18
|
registerEventsFolder(folder: string): Promise<void>;
|
|
@@ -21,8 +20,6 @@ export declare abstract class Module {
|
|
|
21
20
|
parseEventArgs(args: any[]): any;
|
|
22
21
|
getEvents(): Map<string, FrameworkEvent>;
|
|
23
22
|
registerTranslations(subpath?: string): Promise<void>;
|
|
24
|
-
loadTranslationFile(subpath: string, file: string): Promise<any>;
|
|
25
|
-
parseTranslation(path: string, lang: string, json: any): any;
|
|
26
23
|
registerModels(): Promise<void>;
|
|
27
24
|
getModels(): Array<DatabaseModel>;
|
|
28
25
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { ButtonInteraction, CommandInteraction, ModalSubmitInteraction, StringSelectMenuInteraction, } from 'discord.js';
|
|
4
|
+
import { CommandManager } from '../services/CommandManager.js';
|
|
5
|
+
export class Module {
|
|
6
|
+
path;
|
|
7
|
+
framework;
|
|
8
|
+
commands;
|
|
9
|
+
events = new Map();
|
|
10
|
+
models = [];
|
|
11
|
+
commandManager;
|
|
12
|
+
constructor(path, framework) {
|
|
13
|
+
this.path = path;
|
|
14
|
+
this.framework = framework;
|
|
15
|
+
this.commands = new CommandManager(framework);
|
|
16
|
+
}
|
|
17
|
+
async initialize() {
|
|
18
|
+
await this.registerCommands();
|
|
19
|
+
await this.registerEvents();
|
|
20
|
+
await this.registerTranslations();
|
|
21
|
+
await this.registerModels();
|
|
22
|
+
}
|
|
23
|
+
async registerCommands() {
|
|
24
|
+
const commandsFolder = path.join(this.path, 'commands');
|
|
25
|
+
if (fs.existsSync(commandsFolder)) {
|
|
26
|
+
await this.commands.loadCommandsFolder(commandsFolder);
|
|
27
|
+
// register watcher
|
|
28
|
+
if (process.env.DEBUG) {
|
|
29
|
+
/*
|
|
30
|
+
Debug only cause in prod environment commands should't be changed.
|
|
31
|
+
Appart from that, esm module cache invalidation is not working properly
|
|
32
|
+
and can cause memory leaks and crashes.
|
|
33
|
+
*/
|
|
34
|
+
this.commands.watchCommandsFolder(commandsFolder);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
getCommands() {
|
|
39
|
+
return this.commands.getAll();
|
|
40
|
+
}
|
|
41
|
+
async registerEvents() {
|
|
42
|
+
if (!fs.existsSync(path.join(this.path, 'events')))
|
|
43
|
+
return;
|
|
44
|
+
const files = fs.readdirSync(path.join(this.path, 'events'));
|
|
45
|
+
for (const file of files) {
|
|
46
|
+
// if file is folder
|
|
47
|
+
if (fs.lstatSync(path.join(this.path, 'events', file)).isDirectory()) {
|
|
48
|
+
console.log('registering events folder ' + file);
|
|
49
|
+
this.registerEventsFolder(file);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async registerEventsFolder(folder) {
|
|
54
|
+
const folderPath = path.join(this.path, 'events', folder);
|
|
55
|
+
if (!fs.existsSync(folderPath))
|
|
56
|
+
throw new Error(`Folder ${folder} doesn't exist`);
|
|
57
|
+
const files = fs.readdirSync(folderPath);
|
|
58
|
+
for (const file of files) {
|
|
59
|
+
if (file.endsWith('d.ts'))
|
|
60
|
+
continue;
|
|
61
|
+
if (file.endsWith('.js') || file.endsWith('.ts')) {
|
|
62
|
+
let event = await import('file://' + path.join(folderPath, file)).catch((e) => {
|
|
63
|
+
console.error(`[🔄🔴 ] Error loading ${file.slice(0, -3)} event on module ${this.constructor.name}`);
|
|
64
|
+
});
|
|
65
|
+
event = Object.values(event)[0];
|
|
66
|
+
event = new event();
|
|
67
|
+
this.events.set(event.constructor.name.toLowerCase(), event);
|
|
68
|
+
this.registerEvent(event, folder);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
registerEvent(frameworkEvent, emitterName) {
|
|
73
|
+
if (frameworkEvent.disabled)
|
|
74
|
+
return;
|
|
75
|
+
const once = frameworkEvent.once;
|
|
76
|
+
const eventName = frameworkEvent.constructor.name.charAt(0).toLowerCase() +
|
|
77
|
+
frameworkEvent.constructor.name.slice(1);
|
|
78
|
+
this.framework.eventManager.addEventListener(emitterName, eventName, (...args) => {
|
|
79
|
+
const finalArgs = this.parseEventArgs(args);
|
|
80
|
+
frameworkEvent.execute(finalArgs);
|
|
81
|
+
}, { once });
|
|
82
|
+
}
|
|
83
|
+
parseEventArgs(args) {
|
|
84
|
+
const finalArgs = {
|
|
85
|
+
framework: this.framework,
|
|
86
|
+
client: this.framework.client,
|
|
87
|
+
};
|
|
88
|
+
args.forEach((arg) => {
|
|
89
|
+
finalArgs[arg.constructor.name.toLowerCase()] = arg;
|
|
90
|
+
});
|
|
91
|
+
const interaction = args.find((arg) => arg instanceof StringSelectMenuInteraction ||
|
|
92
|
+
arg instanceof CommandInteraction ||
|
|
93
|
+
arg instanceof ButtonInteraction ||
|
|
94
|
+
arg instanceof ModalSubmitInteraction);
|
|
95
|
+
if (interaction) {
|
|
96
|
+
finalArgs['interaction'] = interaction;
|
|
97
|
+
}
|
|
98
|
+
return finalArgs;
|
|
99
|
+
}
|
|
100
|
+
getEvents() {
|
|
101
|
+
return this.events;
|
|
102
|
+
}
|
|
103
|
+
async registerTranslations(subpath = '') {
|
|
104
|
+
if (!fs.existsSync(path.join(this.path, 'translations', subpath)))
|
|
105
|
+
return;
|
|
106
|
+
this.framework.translations.registerTranslationsFromFolder(path.join(this.path, 'translations', subpath), '', process.env.DEBUG ? true : false);
|
|
107
|
+
}
|
|
108
|
+
async registerModels() {
|
|
109
|
+
if (!fs.existsSync(path.join(this.path, 'models')))
|
|
110
|
+
return;
|
|
111
|
+
const files = fs.readdirSync(path.join(this.path, 'models'));
|
|
112
|
+
for (const file of files) {
|
|
113
|
+
if (file.endsWith('d.ts'))
|
|
114
|
+
continue;
|
|
115
|
+
if (file.endsWith('.ts') || file.endsWith('.js')) {
|
|
116
|
+
let model = await import('file://' + `${this.path}/models/${file}`).catch((e) => {
|
|
117
|
+
console.error(`[🔄🔴 ] Error loading ${file.slice(0, -3)} model on module ${this.constructor.name}`);
|
|
118
|
+
console.error(e + '\n' + e.name + '\n' + e.stack);
|
|
119
|
+
});
|
|
120
|
+
model = Object.values(model)[0];
|
|
121
|
+
model = new model();
|
|
122
|
+
this.models.push(model);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
getModels() {
|
|
127
|
+
return this.models;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommandArgDefinition } from './CommandArgDefinition.js';
|
|
2
2
|
import { CommandParameters } from './CommandParameters.js';
|
|
3
|
-
import { SelectMenuParameters } from '
|
|
3
|
+
import { SelectMenuParameters } from '../parameters/SelectMenuParameters.js';
|
|
4
4
|
/**
|
|
5
5
|
* @name Command
|
|
6
6
|
* @description Base class for all commands
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, CommandInteraction, Message } from 'discord.js';
|
|
2
|
-
import { ZumitoFramework } from '
|
|
2
|
+
import { ZumitoFramework } from '../../ZumitoFramework.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class CommandParameters
|
|
5
5
|
* @classdesc Parameters passed to a command execution.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client, SelectMenuInteraction } from 'discord.js';
|
|
2
|
-
import { ZumitoFramework } from '
|
|
2
|
+
import { ZumitoFramework } from '../../ZumitoFramework.js';
|
|
3
3
|
export interface SelectMenuParameters {
|
|
4
4
|
path: string[];
|
|
5
5
|
interaction: SelectMenuInteraction;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { PresenceDataRule, RuledPresenceData, StatusManagerOptions } from './
|
|
2
|
-
import { ApiResponse } from './definitions/ApiResponse.js';
|
|
3
|
-
import { ButtonPressed } from './
|
|
4
|
-
import { ButtonPressedParams } from './
|
|
5
|
-
import { Command } from './
|
|
6
|
-
import { CommandArgDefinition } from './
|
|
7
|
-
import { CommandArguments } from './
|
|
8
|
-
import { CommandChoiceDefinition } from './
|
|
9
|
-
import { CommandParameters } from './
|
|
10
|
-
import { CommandType } from './
|
|
11
|
-
import { DatabaseConfigLoader } from './
|
|
12
|
-
import { DatabaseModel } from './
|
|
13
|
-
import { EmojiFallback } from './
|
|
14
|
-
import { FrameworkEvent } from './
|
|
15
|
-
import { FrameworkSettings } from './
|
|
16
|
-
import { Module } from './
|
|
17
|
-
import { SelectMenuParameters } from './
|
|
18
|
-
import { TextFormatter } from './
|
|
19
|
-
import { Translation } from './
|
|
20
|
-
import { TranslationManager } from './TranslationManager.js';
|
|
1
|
+
import { PresenceDataRule, RuledPresenceData, StatusManagerOptions } from './definitions/StatusManagerOptions.js';
|
|
2
|
+
import { ApiResponse } from './definitions/api/ApiResponse.js';
|
|
3
|
+
import { ButtonPressed } from './definitions/parameters/ButtonPressed.js';
|
|
4
|
+
import { ButtonPressedParams } from './definitions/parameters/ButtonPressedParams.js';
|
|
5
|
+
import { Command } from './definitions/commands/Command.js';
|
|
6
|
+
import { CommandArgDefinition } from './definitions/commands/CommandArgDefinition.js';
|
|
7
|
+
import { CommandArguments } from './definitions/commands/CommandArguments.js';
|
|
8
|
+
import { CommandChoiceDefinition } from './definitions/commands/CommandChoiceDefinition.js';
|
|
9
|
+
import { CommandParameters } from './definitions/commands/CommandParameters.js';
|
|
10
|
+
import { CommandType } from './definitions/commands/CommandType.js';
|
|
11
|
+
import { DatabaseConfigLoader } from './services/DatabaseConfigLoader.js';
|
|
12
|
+
import { DatabaseModel } from './definitions/DatabaseModel.js';
|
|
13
|
+
import { EmojiFallback } from './services/EmojiFallback.js';
|
|
14
|
+
import { FrameworkEvent } from './definitions/FrameworkEvent.js';
|
|
15
|
+
import { FrameworkSettings } from './definitions/FrameworkSettings.js';
|
|
16
|
+
import { Module } from './definitions/Module.js';
|
|
17
|
+
import { SelectMenuParameters } from './definitions/parameters/SelectMenuParameters.js';
|
|
18
|
+
import { TextFormatter } from './services/TextFormatter.js';
|
|
19
|
+
import { Translation } from './definitions/Translation.js';
|
|
20
|
+
import { TranslationManager } from './services/TranslationManager.js';
|
|
21
21
|
import { ZumitoFramework } from './ZumitoFramework.js';
|
|
22
22
|
import * as discord from 'discord.js';
|
|
23
|
-
import { EventParameters } from './
|
|
23
|
+
import { EventParameters } from './definitions/parameters/EventParameters.js';
|
|
24
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
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ApiResponse } from './definitions/ApiResponse.js';
|
|
2
|
-
import { ButtonPressed } from './
|
|
3
|
-
import { Command } from './
|
|
4
|
-
import { CommandArguments } from './
|
|
5
|
-
import { CommandType } from './
|
|
6
|
-
import { DatabaseConfigLoader } from './
|
|
7
|
-
import { DatabaseModel } from './
|
|
8
|
-
import { EmojiFallback } from './
|
|
9
|
-
import { FrameworkEvent } from './
|
|
10
|
-
import { Module } from './
|
|
11
|
-
import { TextFormatter } from './
|
|
12
|
-
import { Translation } from './
|
|
13
|
-
import { TranslationManager } from './TranslationManager.js';
|
|
1
|
+
import { ApiResponse } from './definitions/api/ApiResponse.js';
|
|
2
|
+
import { ButtonPressed } from './definitions/parameters/ButtonPressed.js';
|
|
3
|
+
import { Command } from './definitions/commands/Command.js';
|
|
4
|
+
import { CommandArguments } from './definitions/commands/CommandArguments.js';
|
|
5
|
+
import { CommandType } from './definitions/commands/CommandType.js';
|
|
6
|
+
import { DatabaseConfigLoader } from './services/DatabaseConfigLoader.js';
|
|
7
|
+
import { DatabaseModel } from './definitions/DatabaseModel.js';
|
|
8
|
+
import { EmojiFallback } from './services/EmojiFallback.js';
|
|
9
|
+
import { FrameworkEvent } from './definitions/FrameworkEvent.js';
|
|
10
|
+
import { Module } from './definitions/Module.js';
|
|
11
|
+
import { TextFormatter } from './services/TextFormatter.js';
|
|
12
|
+
import { Translation } from './definitions/Translation.js';
|
|
13
|
+
import { TranslationManager } from './services/TranslationManager.js';
|
|
14
14
|
import { ZumitoFramework } from './ZumitoFramework.js';
|
|
15
15
|
import * as discord from 'discord.js';
|
|
16
16
|
export { ZumitoFramework, Command, Module, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, CommandType, ButtonPressed, TextFormatter, EmojiFallback, DatabaseConfigLoader, DatabaseModel, discord, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command } from '
|
|
2
|
-
import { EventParameters } from '
|
|
3
|
-
import { FrameworkEvent } from '
|
|
1
|
+
import { Command } from '../../../../../definitions/commands/Command.js';
|
|
2
|
+
import { EventParameters } from '../../../../../definitions/parameters/EventParameters.js';
|
|
3
|
+
import { FrameworkEvent } from '../../../../../definitions/FrameworkEvent.js';
|
|
4
4
|
export declare class InteractionCreate extends FrameworkEvent {
|
|
5
5
|
once: boolean;
|
|
6
6
|
execute({ interaction, client, framework, }: EventParameters): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommandType } from '
|
|
2
|
-
import { FrameworkEvent } from '
|
|
1
|
+
import { CommandType } from '../../../../../definitions/commands/CommandType.js';
|
|
2
|
+
import { FrameworkEvent } from '../../../../../definitions/FrameworkEvent.js';
|
|
3
3
|
export class InteractionCreate extends FrameworkEvent {
|
|
4
4
|
once = false;
|
|
5
5
|
async execute({ interaction, client, framework, }) {
|
|
@@ -8,7 +8,7 @@ export class InteractionCreate extends FrameworkEvent {
|
|
|
8
8
|
guildSettings = await framework.getGuildSettings(interaction.guildId);
|
|
9
9
|
}
|
|
10
10
|
if (interaction.isCommand()) {
|
|
11
|
-
if (!framework.commands.has(interaction.commandName))
|
|
11
|
+
if (!framework.commands.getAll().has(interaction.commandName))
|
|
12
12
|
return;
|
|
13
13
|
const commandInstance = framework.commands.get(interaction.commandName);
|
|
14
14
|
const args = new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionRowBuilder, EmbedBuilder } from 'discord.js';
|
|
2
|
-
import { EventParameters } from '
|
|
3
|
-
import { FrameworkEvent } from '
|
|
2
|
+
import { EventParameters } from '../../../../../definitions/parameters/EventParameters.js';
|
|
3
|
+
import { FrameworkEvent } from '../../../../../definitions/FrameworkEvent.js';
|
|
4
4
|
export declare class MessageCreate extends FrameworkEvent {
|
|
5
5
|
once: boolean;
|
|
6
6
|
execute({ message, framework }: EventParameters): Promise<import("discord.js").Message<boolean>>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, ChannelType, EmbedBuilder, PermissionsBitField, } from 'discord.js';
|
|
2
2
|
import ErrorStackParser from 'error-stack-parser';
|
|
3
|
-
import { FrameworkEvent } from '
|
|
4
|
-
import { ZumitoFramework } from '
|
|
3
|
+
import { FrameworkEvent } from '../../../../../definitions/FrameworkEvent.js';
|
|
4
|
+
import { ZumitoFramework } from '../../../../../ZumitoFramework.js';
|
|
5
5
|
import leven from 'leven';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { InteractionIdGenerator } from '
|
|
7
|
+
import { InteractionIdGenerator } from '../../../../../services/InteractionIdGenerator.js';
|
|
8
8
|
export class MessageCreate extends FrameworkEvent {
|
|
9
9
|
once = false;
|
|
10
10
|
async execute({ message, framework }) {
|
|
@@ -14,10 +14,10 @@ export class MessageCreate extends FrameworkEvent {
|
|
|
14
14
|
const command = args.shift().toLowerCase();
|
|
15
15
|
let commandInstance;
|
|
16
16
|
if (message.content.startsWith(prefix)) {
|
|
17
|
-
if (!framework.commands.has(command)) {
|
|
18
|
-
const commandNames = Array.from(framework.commands.keys());
|
|
17
|
+
if (!framework.commands.getAll().has(command)) {
|
|
18
|
+
const commandNames = Array.from(framework.commands.getAll().keys());
|
|
19
19
|
const correctedCommand = this.autocorrect(command, commandNames);
|
|
20
|
-
if (framework.commands.has(correctedCommand)) {
|
|
20
|
+
if (framework.commands.getAll().has(correctedCommand)) {
|
|
21
21
|
commandInstance = framework.commands.get(correctedCommand);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ZumitoFramework } from "../ZumitoFramework";
|
|
2
|
+
import { Command } from "../definitions/commands/Command.js";
|
|
3
|
+
export declare class CommandManager {
|
|
4
|
+
protected commands: Map<string, Command>;
|
|
5
|
+
protected framework: ZumitoFramework;
|
|
6
|
+
constructor(framework: any);
|
|
7
|
+
set(name: string, command: Command): void;
|
|
8
|
+
get(name: string): Command;
|
|
9
|
+
getAll(): Map<string, Command>;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
get size(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Load command from file
|
|
16
|
+
* @async
|
|
17
|
+
* @public
|
|
18
|
+
* @param filePath - Absolute path to command file
|
|
19
|
+
* @returns {Promise<Command>}
|
|
20
|
+
*/
|
|
21
|
+
loadCommandFile(filePath: string): Promise<any>;
|
|
22
|
+
/**
|
|
23
|
+
* Load all command files from a folder
|
|
24
|
+
* @async
|
|
25
|
+
* @public
|
|
26
|
+
* @param folderPath - Absolute path to commands folder
|
|
27
|
+
* @returns {Promise<Map<string, Command>>}
|
|
28
|
+
*/
|
|
29
|
+
loadCommandsFolder(folderPath: string): Promise<Map<string, any>>;
|
|
30
|
+
/**
|
|
31
|
+
* Watch command files on a folder.
|
|
32
|
+
* It loads command when new file is created, update command when file is modified and deletes command when file is deleted.
|
|
33
|
+
* @async
|
|
34
|
+
* @public
|
|
35
|
+
* @param folderPath - Absolute path to commands folder
|
|
36
|
+
* @returns {Promise<Map<string, Command>>}
|
|
37
|
+
*/
|
|
38
|
+
watchCommandsFolder(folderPath: string): void;
|
|
39
|
+
refreshSlashCommands(): Promise<void>;
|
|
40
|
+
}
|