mrmBot-Matrix/utils/help.js
Essem 40223ec8b5
Class commands, improved sharding, and many other changes (#88)
* Load commands recursively

* Sort commands

* Missed a couple of spots

* missed even more spots apparently

* Ported commands in "fun" category to new class-based format, added babel eslint plugin

* Ported general commands, removed old/unneeded stuff, replaced moment with day, many more fixes I lost track of

* Missed a spot

* Removed unnecessary abort-controller package, add deprecation warning for mongo database

* Added imagereload, clarified premature end message

* Fixed docker-compose path issue, added total bot uptime to stats, more fixes for various parts

* Converted image commands into classes, fixed reload, ignore another WS event, cleaned up command handler and image runner

* Converted music/soundboard commands to class format

* Cleanup unnecessary logs

* awful tag command class port

* I literally somehow just learned that you can leave out the constructor in classes

* Pass client directly to commands/events, cleaned up command handler

* Migrated bot to eris-sharder, fixed some error handling stuff

* Remove unused modules

* Fixed type returning

* Switched back to Eris stable

* Some fixes and cleanup

* might wanna correct this

* Implement image command ratelimiting

* Added Bot token prefix, added imagestats, added running endpoint to API
2021-04-12 11:16:12 -05:00

69 lines
No EOL
2.8 KiB
JavaScript

const collections = require("./collections.js");
const fs = require("fs");
const categoryTemplate = {
general: [],
tags: ["> **Every command in this category is a subcommand of the tag command.**\n"],
"image-editing": ["> **These commands support the PNG, JPEG, WEBP (static), and GIF (animated or static) formats.**\n"]
};
exports.categories = categoryTemplate;
exports.generateList = async () => {
this.categories = categoryTemplate;
for (const [command] of collections.commands) {
const category = collections.info.get(command).category;
const description = collections.info.get(command).description;
const params = collections.info.get(command).params;
if (category === "tags") {
const subCommands = [...Object.keys(description)];
for (const subCommand of subCommands) {
this.categories.tags.push(`**tags${subCommand !== "default" ? ` ${subCommand}` : ""}**${params[subCommand] ? ` ${params[subCommand]}` : ""} - ${description[subCommand]}`);
}
} else {
if (!this.categories[category]) this.categories[category] = [];
this.categories[category].push(`**${command}**${params ? ` ${params}` : ""} - ${description}`);
}
}
};
exports.createPage = async (output) => {
let template = `# <img src="https://raw.githubusercontent.com/esmBot/esmBot/master/esmbot.png" width="64"> esmBot${process.env.NODE_ENV === "development" ? " Dev" : ""} Command List
This page was last generated on \`${new Date().toString()}\`.
\`[]\` means an argument is required, \`{}\` means an argument is optional.
Default prefix is \`&\`.
**Want to help support esmBot's development? Consider donating on Patreon!** https://patreon.com/TheEssem
> Tip: You can get more info about a command by using \`help [command]\` in the bot itself.
`;
template += "\n## Table of Contents\n";
for (const category of Object.keys(this.categories)) {
const categoryStringArray = category.split("-");
for (const index of categoryStringArray.keys()) {
categoryStringArray[index] = categoryStringArray[index].charAt(0).toUpperCase() + categoryStringArray[index].slice(1);
}
template += `+ [**${categoryStringArray.join(" ")}**](#${category})\n`;
}
// hell
for (const category of Object.keys(this.categories)) {
const categoryStringArray = category.split("-");
for (const index of categoryStringArray.keys()) {
categoryStringArray[index] = categoryStringArray[index].charAt(0).toUpperCase() + categoryStringArray[index].slice(1);
}
template += `\n## ${categoryStringArray.join(" ")}\n`;
for (const command of this.categories[category]) {
if (command.startsWith(">")) {
template += `${command}\n`;
} else {
template += `+ ${command}\n`;
}
}
}
await fs.promises.writeFile(output, template);
};