1 files changed, 13 insertions, 9 deletions
diff --git a/slowcord/bot/src/commands/index.ts b/slowcord/bot/src/commands/index.ts
index ef2d2a22..d3b39e0f 100644
--- a/slowcord/bot/src/commands/index.ts
+++ b/slowcord/bot/src/commands/index.ts
@@ -14,20 +14,24 @@ export type Command = {
exec: (ctx: CommandContext) => any;
};
-const walk = async (path: string): Promise<Command[]> => {
+const walk = async (path: string) => {
const files = fs.readdirSync(path);
- const out: Command[] = [];
+ const out = [];
for (var file of files) {
- if (file.indexOf("index") !== -1) continue;
-
- var imported = await import(`${path}/${file}`);
+ if (fs.statSync(`${path}/${file}`).isDirectory()) continue;
+ if (file.indexOf("index") !== -1)
+ continue;
+ if (file.indexOf(".js") !== file.length - 3) continue;
+ var imported = (await import(`./${file}`)).default;
+ out.push(imported);
}
-
return out;
};
export const getCommands = async () => {
- const map: { [key: string]: Command; } = {};
- (await walk("./build/commands")).forEach((val) => map[val.name] = val);
+ const map: { [key: string]: Command } = {};
+ for (var cmd of await walk("./build/commands")) {
+ map[cmd.name] = cmd;
+ }
return map;
-};
\ No newline at end of file
+};
|