zumito-framework 1.1.39 → 1.1.41
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/TranslationManager.d.ts +2 -0
- package/dist/TranslationManager.js +6 -0
- package/dist/ZumitoFramework.js +16 -5
- package/dist/index.d.ts +2 -1
- package/dist/types/CommandArgDefinition.d.ts +2 -0
- package/dist/types/CommandChoiceDefinition.d.ts +4 -0
- package/dist/types/CommandChoiceDefinition.js +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { Translation } from "./types/Translation.js";
|
|
|
2
2
|
export declare class TranslationManager {
|
|
3
3
|
private translations;
|
|
4
4
|
private defaultLanguage;
|
|
5
|
+
private languages;
|
|
5
6
|
constructor();
|
|
6
7
|
get(key: string, language?: string, params?: any): string;
|
|
7
8
|
set(key: string, language: string, text: string): void;
|
|
@@ -10,4 +11,5 @@ export declare class TranslationManager {
|
|
|
10
11
|
setAll(translations: Map<string, Translation>): void;
|
|
11
12
|
getDefaultLanguage(): string;
|
|
12
13
|
setDefaultLanguage(language: string): void;
|
|
14
|
+
getLanguages(): string[];
|
|
13
15
|
}
|
|
@@ -2,6 +2,7 @@ import { Translation } from "./types/Translation.js";
|
|
|
2
2
|
export class TranslationManager {
|
|
3
3
|
translations = new Map();
|
|
4
4
|
defaultLanguage = 'en';
|
|
5
|
+
languages = [];
|
|
5
6
|
constructor() { }
|
|
6
7
|
get(key, language, params) {
|
|
7
8
|
if (this.translations.has(key)) {
|
|
@@ -16,6 +17,8 @@ export class TranslationManager {
|
|
|
16
17
|
this.translations.set(key, new Translation());
|
|
17
18
|
}
|
|
18
19
|
this.translations.get(key).set(language, text);
|
|
20
|
+
if (!this.languages.includes(language))
|
|
21
|
+
this.languages.push(language);
|
|
19
22
|
}
|
|
20
23
|
has(key) {
|
|
21
24
|
return this.translations.has(key);
|
|
@@ -32,4 +35,7 @@ export class TranslationManager {
|
|
|
32
35
|
setDefaultLanguage(language) {
|
|
33
36
|
this.defaultLanguage = language;
|
|
34
37
|
}
|
|
38
|
+
getLanguages() {
|
|
39
|
+
return this.languages;
|
|
40
|
+
}
|
|
35
41
|
}
|
package/dist/ZumitoFramework.js
CHANGED
|
@@ -133,9 +133,8 @@ export class ZumitoFramework {
|
|
|
133
133
|
for (let file of files) {
|
|
134
134
|
await this.registerModule(modulesFolder, file);
|
|
135
135
|
}
|
|
136
|
-
this.models.forEach((
|
|
137
|
-
|
|
138
|
-
const schema = new mongoose.Schema(modelDefiniton);
|
|
136
|
+
this.models.forEach((modelDefinition, modelName) => {
|
|
137
|
+
const schema = new mongoose.Schema(modelDefinition);
|
|
139
138
|
this.models.set(modelName, mongoose.model(modelName, schema));
|
|
140
139
|
});
|
|
141
140
|
}
|
|
@@ -246,7 +245,7 @@ export class ZumitoFramework {
|
|
|
246
245
|
.map((command) => {
|
|
247
246
|
let slashCommand = new SlashCommandBuilder()
|
|
248
247
|
.setName(command.name)
|
|
249
|
-
.setDescription(this.translations.get('
|
|
248
|
+
.setDescription(this.translations.get('command.' + command.name + '.description', 'en'));
|
|
250
249
|
if (command.args) {
|
|
251
250
|
command.args.forEach((arg) => {
|
|
252
251
|
let method;
|
|
@@ -269,8 +268,20 @@ export class ZumitoFramework {
|
|
|
269
268
|
}
|
|
270
269
|
slashCommand[method]((option) => {
|
|
271
270
|
option.setName(arg.name);
|
|
272
|
-
option.setDescription(this.translations.get('
|
|
271
|
+
option.setDescription(this.translations.get('command.' + command.name + '.args.' + arg.name + '.description', 'en'));
|
|
273
272
|
option.setRequired(!arg.optional);
|
|
273
|
+
if (arg.choices) {
|
|
274
|
+
// if arg.choices is function, call it
|
|
275
|
+
if (typeof arg.choices == 'function') {
|
|
276
|
+
arg.choices = arg.choices();
|
|
277
|
+
}
|
|
278
|
+
arg.choices.forEach((choice) => {
|
|
279
|
+
option.addChoices({
|
|
280
|
+
name: choice.name,
|
|
281
|
+
value: choice.value
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
}
|
|
274
285
|
return option;
|
|
275
286
|
});
|
|
276
287
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ import { ApiResponse } from './definitions/ApiResponse.js';
|
|
|
11
11
|
import { SelectMenuParameters } from './types/SelectMenuParameters.js';
|
|
12
12
|
import { CommandType } from './types/CommandType.js';
|
|
13
13
|
import { CommandArgDefinition } from './types/CommandArgDefinition.js';
|
|
14
|
-
|
|
14
|
+
import { CommandChoiceDefinition } from './types/CommandChoiceDefinition.js';
|
|
15
|
+
export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition, CommandChoiceDefinition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|