2019-12-05 16:58:46 +00:00
|
|
|
const pug = require("pug");
|
|
|
|
const collections = require("./collections.js");
|
2019-12-06 00:15:28 +00:00
|
|
|
const logger = require("./logger.js");
|
2019-12-05 16:58:46 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
|
2019-12-05 17:40:09 +00:00
|
|
|
module.exports = async (output) => {
|
2019-12-05 16:58:46 +00:00
|
|
|
const commands = Array.from(collections.commands.keys());
|
|
|
|
const categories = {
|
|
|
|
general: [],
|
|
|
|
moderation: [],
|
|
|
|
tags: [],
|
|
|
|
fun: [],
|
|
|
|
images: [],
|
|
|
|
soundboard: []
|
|
|
|
};
|
|
|
|
for (const command of commands) {
|
|
|
|
const category = collections.info.get(command).category;
|
|
|
|
const description = collections.info.get(command).description;
|
|
|
|
const params = collections.info.get(command).params;
|
|
|
|
if (category === 1) {
|
|
|
|
categories.general.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
|
|
|
} else if (category === 2) {
|
|
|
|
categories.moderation.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
|
|
|
} else if (category === 3) {
|
2019-12-06 00:15:28 +00:00
|
|
|
const subCommands = Array.from(Object.keys(description));
|
|
|
|
for (const subCommand of subCommands) {
|
|
|
|
categories.tags.push(`<strong>tags${subCommand !== "default" ? ` ${subCommand}` : ""}</strong>${params[subCommand] ? ` ${params[subCommand]}` : ""} - ${description[subCommand]}`);
|
|
|
|
}
|
2019-12-05 16:58:46 +00:00
|
|
|
} else if (category === 4) {
|
|
|
|
categories.fun.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
|
|
|
} else if (category === 5) {
|
|
|
|
categories.images.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
|
|
|
} else if (category === 6) {
|
|
|
|
categories.soundboard.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
|
|
|
}
|
|
|
|
}
|
2019-12-16 21:32:47 +00:00
|
|
|
fs.writeFile(output, pug.renderFile("./assets/pages/help.pug", { commands: categories, dev: process.env.NODE_ENV === "development" ? true : false }), () => {
|
2019-12-06 00:15:28 +00:00
|
|
|
logger.log("The help docs have been generated.");
|
2019-12-05 16:58:46 +00:00
|
|
|
});
|
|
|
|
};
|