summary refs log tree commit diff
path: root/slowcord/bot/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'slowcord/bot/src/commands')
-rw-r--r--slowcord/bot/src/commands/index.ts33
-rw-r--r--slowcord/bot/src/commands/instance.ts8
2 files changed, 41 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 diff --git a/slowcord/bot/src/commands/instance.ts b/slowcord/bot/src/commands/instance.ts new file mode 100644
index 00000000..7fcfaef4 --- /dev/null +++ b/slowcord/bot/src/commands/instance.ts
@@ -0,0 +1,8 @@ +import { Command } from "./index.js"; + +export default { + name: "instance", + exec: ({ message }) => { + message.reply("Test"); + } +} as Command; \ No newline at end of file