@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.
- package/index.ts +14 -12
- 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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
236
|
-
|
|
238
|
+
const absolutePath = path.resolve(file.parentPath, file.name);
|
|
239
|
+
const relativePath = path.join(directory, path.relative(path.resolve(directory), absolutePath));
|
|
237
240
|
|
|
238
|
-
|
|
241
|
+
const { default: item } = await import(absolutePath);
|
|
239
242
|
|
|
240
|
-
|
|
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) =>
|
|
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",
|
|
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);
|