mrmBot-Matrix/commands/general/help.js

43 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-03-15 15:03:09 +00:00
// import { Constants } from "oceanic.js";
// import database from "../../utils/database.js";
import * as collections from "../../utils/collections.js";
import { htmlescape } from "../../utils/misc.js";
2023-03-15 15:03:09 +00:00
// import paginator from "../../utils/pagination/pagination.js";
import * as help from "../../utils/help.js";
2023-03-15 15:03:59 +00:00
import Command from "../../classes/command.js";
2023-03-15 15:03:09 +00:00
// const tips = ["You can change the bot's prefix using the prefix command.", "Image commands also work with images previously posted in that channel.", "You can use the tags commands to save things for later use.", "You can visit https://esmbot.net/help.html for a web version of this command list.", "You can view a command's aliases by putting the command name after the help command (e.g. help image).", "Parameters wrapped in [] are required, while parameters wrapped in {} are optional.", "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem"];
2023-03-15 14:09:09 +00:00
class HelpCommand extends Command {
async run() {
let html;
if (this.args.length !== 0) {
if (collections.commands.has(this.args[0].toLowerCase())) {
const command = collections.aliases.get(this.args[0].toLowerCase()) ?? this.args[0].toLowerCase();
const info = collections.info.get(command);
// TODO: room-specific prefix
const prefix = htmlescape(process.env.PREFIX);
html = `<h3><ins>mrmBot Help</ins></h3><h6><code>${prefix}${command}</code></h6>${info.description}`
return { html: html }
}
if (help.categories[this.args[0].toLowerCase()]) {
}
}
html = `<h2>mrmBot Help</h2><table><tr><th>Command</th><th>Description</th></tr>`
for (const [command] of collections.commands) {
const description = collections.info.get(command).description;
html = html + `<tr><td>${command}</td><td>${description}</td></tr>`
}
html = html + "</table>"
return { html: html }
// return { html: "<h1>There are no mrmBot Docs Yet</h1>In the meantime, please refer to https://esmbot.net/help.html" };
2023-03-15 14:09:09 +00:00
}
2023-03-15 15:03:09 +00:00
2023-03-15 14:09:09 +00:00
static description = "Gets a list of commands";
static aliases = ["commands"];
static arguments = ["{command}"];
static slashAllowed = false;
}
export default HelpCommand;