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.
@@ -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
  }
@@ -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((modelDefiniton, modelName) => {
137
- console.log('modelDefiniton', modelDefiniton);
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('commands.' + command.name + '.description', 'en'));
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('commands.' + command.name + '.args.' + arg.name + '.description', 'en'));
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
- export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition };
14
+ import { CommandChoiceDefinition } from './types/CommandChoiceDefinition.js';
15
+ export { ZumitoFramework, FrameworkSettings, Command, Module, CommandParameters, CommandArguments, FrameworkEvent, Translation, TranslationManager, ApiResponse, SelectMenuParameters, CommandType, CommandArgDefinition, CommandChoiceDefinition };
@@ -1,5 +1,7 @@
1
+ import { CommandChoiceDefinition } from './CommandChoiceDefinition.js';
1
2
  export interface CommandArgDefinition {
2
3
  name: string;
3
4
  optional: boolean;
4
5
  type: string;
6
+ choices?: CommandChoiceDefinition[] | Function;
5
7
  }
@@ -0,0 +1,4 @@
1
+ export interface CommandChoiceDefinition {
2
+ name: string;
3
+ value: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.1.39",
3
+ "version": "1.1.41",
4
4
  "description": "Discord.js bot framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",