@hyperneutrino/djs-lite 1.7.2 → 1.7.4

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.
Files changed (2) hide show
  1. package/index.ts +14 -12
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -46,6 +46,10 @@ type WrapperConfig<R extends Record<string, Handleable>> = {
46
46
  [K in keyof R]?: Wrapper<Handler<R[K]>>;
47
47
  };
48
48
 
49
+ function serialize(object: unknown) {
50
+ return JSON.stringify(object, (_, v) => (typeof v === "bigint" ? v.toString() : v));
51
+ }
52
+
49
53
  /**
50
54
  * This is the type of `config.wrappers` in {@link loadCommands}. This type is exported so that you can expose the wrappers upstream if you are making a library
51
55
  * surrounding this library.
@@ -227,19 +231,17 @@ async function importAll(
227
231
  ) {
228
232
  const files = await fs.readdir(path.resolve(directory), { recursive, withFileTypes: true });
229
233
 
230
- await Promise.all(
231
- files.map(async (file) => {
232
- if (file.isDirectory()) return;
233
- if (file.name.startsWith(".")) return;
234
+ for (const file of files) {
235
+ if (file.isDirectory()) continue;
236
+ if (file.name.startsWith(".")) continue;
234
237
 
235
- const absolutePath = path.resolve(file.parentPath, file.name);
236
- const relativePath = path.join(directory, path.relative(path.resolve(directory), absolutePath));
238
+ const absolutePath = path.resolve(file.parentPath, file.name);
239
+ const relativePath = path.join(directory, path.relative(path.resolve(directory), absolutePath));
237
240
 
238
- const { default: item } = await import(absolutePath);
241
+ const { default: item } = await import(absolutePath);
239
242
 
240
- await consumer({ file, relativePath, absolutePath, item });
241
- }),
242
- );
243
+ await consumer({ file, relativePath, absolutePath, item });
244
+ }
243
245
  }
244
246
 
245
247
  async function loadSubcommands(directory: string) {
@@ -367,12 +369,12 @@ export async function loadCommands(client: Client<true>, directory: string, conf
367
369
  const commandDataHasBeenUpdated = await fs
368
370
  .readFile(".cache/command-data.json")
369
371
  .then((buffer) => buffer.toString("utf-8"))
370
- .then((string) => JSON.stringify(commandData) !== string)
372
+ .then((string) => serialize(commandData) !== string)
371
373
  .catch(() => true);
372
374
 
373
375
  if (commandDataHasBeenUpdated) {
374
376
  await fs.mkdir(".cache", { recursive: true }).catch(() => null);
375
- await fs.writeFile(".cache/command-data.json", JSON.stringify(commandData)).catch(() => null);
377
+ await fs.writeFile(".cache/command-data.json", serialize(commandData)).catch(() => null);
376
378
 
377
379
  if (config?.guildId) {
378
380
  const testGuild = client.guilds.resolve(config.guildId);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hyperneutrino/djs-lite",
3
3
  "private": false,
4
- "version": "1.7.2",
4
+ "version": "1.7.4",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
7
  "devDependencies": {