summary refs log tree commit diff
path: root/slowcord/bot/src/commands/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'slowcord/bot/src/commands/index.ts')
-rw-r--r--slowcord/bot/src/commands/index.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/slowcord/bot/src/commands/index.ts b/slowcord/bot/src/commands/index.ts
new file mode 100644

index 00000000..ef2d2a22 --- /dev/null +++ b/slowcord/bot/src/commands/index.ts
@@ -0,0 +1,33 @@ +import { Message, GuildMember, Guild, User } from "discord.js"; +import fs from "fs"; + +export type CommandContext = { + user: User, + guild: Guild | null, + member: GuildMember | null, + message: Message, + args: string[], +}; + +export type Command = { + name: string; + exec: (ctx: CommandContext) => any; +}; + +const walk = async (path: string): Promise<Command[]> => { + const files = fs.readdirSync(path); + const out: Command[] = []; + for (var file of files) { + if (file.indexOf("index") !== -1) continue; + + var imported = await import(`${path}/${file}`); + } + + return out; +}; + +export const getCommands = async () => { + const map: { [key: string]: Command; } = {}; + (await walk("./build/commands")).forEach((val) => map[val.name] = val); + return map; +}; \ No newline at end of file