Basic help command

This commit is contained in:
memetrollsXD 2022-08-01 13:41:37 +02:00
parent 4ef3575a13
commit 438d69c838
No known key found for this signature in database
GPG Key ID: 105C2F3417AC32CD
3 changed files with 23 additions and 2 deletions

View File

@ -1,3 +1,8 @@
{
"close": "exit"
"close": "exit",
"stop": "exit",
"t": "target",
"acc": "account",
"d": "debug",
"?": "help"
}

View File

@ -4,5 +4,5 @@ const c = new Logger("/exit", "blue");
export default async function handle(command: Command) {
c.log("Good riddance!");
process.exit(1);
process.exit(0);
}

16
src/commands/help.ts Normal file
View File

@ -0,0 +1,16 @@
import Logger from "../util/Logger";
import { Command } from "./Interface";
import fs from 'fs';
const c = new Logger("/help", "blue");
export default async function handle(command: Command) {
const cmds = fs.readdirSync(__dirname);
c.log(`${cmds.length} commands available:`)
cmds.forEach(cmd => {
if (cmd.endsWith(".ts")) {
const cmdName = cmd.replace(/.ts/gm, "");
if (cmdName !== "Interface") c.trail(cmdName);
}
})
}