zumito-framework 1.1.80 → 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.
@@ -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';
@@ -21,9 +21,6 @@ export declare abstract class Module {
21
21
  parseEventArgs(args: any[]): any;
22
22
  getEvents(): Map<string, FrameworkEvent>;
23
23
  registerTranslations(subpath?: string): Promise<void>;
24
- onTranslationCreated(filePath: string): Promise<void>;
25
- onTranslationChanged(filePath: string): Promise<void>;
26
- onErrorLoadingTranslation(error: Error): void;
27
24
  loadTranslationFile(subpath: string, file: string): Promise<any>;
28
25
  parseTranslation(path: string, lang: string, json: any): any;
29
26
  registerModels(): Promise<void>;
@@ -37,7 +37,7 @@ export class Module {
37
37
  // register watcher
38
38
  if (process.env.DEBUG) {
39
39
  /*
40
- Debug only cause in prod environment commands should't be changed in runtime.
40
+ Debug only cause in prod environment commands should't be changed.
41
41
  Appart from that, esm module cache invalidation is not working properly
42
42
  and can cause memory leaks and crashes.
43
43
  */
@@ -164,59 +164,11 @@ export class Module {
164
164
  await this.registerTranslations(path.join(subpath, file));
165
165
  }
166
166
  }
167
- // register watcher
168
- if (process.env.DEBUG) {
169
- /*
170
- Debug only cause in prod environment translations should't be changed on runtime.
171
- Appart from that, esm module cache invalidation is not working properly
172
- and can cause memory leaks and crashes.
173
- */
174
- chokidar
175
- .watch(path.resolve(path.join(this.path, 'translations')), {
176
- ignored: /^\./,
177
- persistent: true,
178
- ignoreInitial: true,
179
- })
180
- .on('add', this.onTranslationCreated.bind(this))
181
- .on('change', this.onTranslationChanged.bind(this))
182
- //.on('unlink', function(path) {console.log('File', path, 'has been removed');})
183
- .on('error', this.onErrorLoadingTranslation.bind(this));
184
- }
185
- }
186
- async onTranslationCreated(filePath) {
187
- if (filePath.endsWith('.json')) {
188
- const subpath = path.dirname(filePath).replace(this.path + '/translations', '');
189
- const fileName = path.basename(filePath);
190
- const json = await this.loadTranslationFile(subpath, fileName);
191
- const lang = fileName.slice(0, -5);
192
- const baseKey = subpath
193
- ? subpath.substring(1).replaceAll('/', '.').replaceAll('\\', '.') + '.'
194
- : '';
195
- this.parseTranslation(baseKey, lang, json);
196
- console.debug('[🆕🟢 ] translations file ' + chalk.blue(filePath.replace(/^.*[\\\/]/, '').split('.').slice(0, -1).join('.')) + ' loaded');
197
- }
198
- }
199
- async onTranslationChanged(filePath) {
200
- if (filePath.endsWith('.json')) {
201
- const subpath = path.dirname(filePath).replace(this.path + '/translations', '');
202
- const fileName = path.basename(filePath);
203
- const json = await this.loadTranslationFile(subpath, fileName);
204
- const lang = fileName.slice(0, -5);
205
- const baseKey = subpath
206
- ? subpath.substring(1).replaceAll('/', '.').replaceAll('\\', '.') + '.'
207
- : '';
208
- this.parseTranslation(baseKey, lang, json);
209
- console.debug('[🆕🟢 ] translations file ' + chalk.blue(filePath.replace(/^.*[\\\/]/, '').split('.').slice(0, -1).join('.')) + ' reloaded');
210
- }
211
- }
212
- onErrorLoadingTranslation(error) {
213
- console.error('[🔄🔴 ] Error reloading translation file');
214
- console.log(boxen(error + '\n' + error.stack, { padding: 1 }));
215
167
  }
216
168
  async loadTranslationFile(subpath, file) {
217
169
  if (subpath)
218
170
  subpath = subpath + '/';
219
- const json = await import('file://' + `${this.path}/translations/${subpath}${file}?update=${Date.now().toString()}`, {
171
+ const json = await import('file://' + `${this.path}/translations/${subpath}${file}`, {
220
172
  assert: {
221
173
  type: 'json',
222
174
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zumito-framework",
3
- "version": "1.1.80",
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.9.0",
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.23.14",
50
- "typescript": "^4.8.3"
49
+ "typedoc": "^0.25.4",
50
+ "typescript": "^5.3.3"
51
51
  },
52
52
  "type": "module",
53
53
  "exports": {