Added toggle/options for help page generator

This commit is contained in:
TheEssem 2019-12-05 11:40:09 -06:00
parent b6a2dd275a
commit c357d3bc46
4 changed files with 24 additions and 16 deletions

View file

@ -24,6 +24,9 @@ CSE=
# Put DBL/top.gg token here
DBL=
# Put HTML help page output location here, leave blank to disable
OUTPUT=
# Enable/disable Twitter bot (true/false)
TWITTER=false
# Put Twitter username here

View file

@ -48,46 +48,46 @@ body
h2#table-of-contents Table of Contents
ul
li
a(href='#💻-general')
a(href='#general')
strong General
li
a(href='#🔨-moderation')
a(href='#moderation')
strong Moderation
li
a(href='#🏷️-tags')
a(href='#tags')
strong Tags
li
a(href='#👌-fun')
a(href='#fun')
strong Fun
li
a(href='#🖼️-image-editing')
a(href='#images')
strong Image Editing
li
a(href='#🔊-soundboard')
a(href='#soundboard')
strong Soundboard
h2(id='💻-general') 💻 General
h2(id='general') 💻 General
each command in commands.general
ul
li!= command
h2(id='🔨-moderation') 🔨 Moderation
h2(id='moderation') 🔨 Moderation
each command in commands.moderation
ul
li!= command
h2(id='🏷️-tags') 🏷️ Tags
h2(id='tags') 🏷️ Tags
each command in commands.tags
ul
li!= command
h2(id='👌-fun') 👌 Fun
h2(id='fun') 👌 Fun
each command in commands.fun
ul
li!= command
h2(id='🖼️-image-editing') 🖼️ Image Editing
h2(id='images') 🖼️ Image Editing
blockquote
p These commands support the PNG, JPEG, and WEBP formats.
each command in commands.images
ul
li!= command
h2(id='🔊-soundboard') 🔊 Soundboard
h2(id='soundboard') 🔊 Soundboard
each command in commands.soundboard
ul
li!= command

View file

@ -3,6 +3,7 @@ const database = require("../utils/database.js");
const logger = require("../utils/logger.js");
const messages = require("../messages.json");
const misc = require("../utils/misc.js");
const helpGenerator = process.env.OUTPUT !== "" ? require("../utils/help.js") : null;
const twitter = process.env.TWITTER === "true" ? require("../utils/twitter.js") : null;
// run when ready
@ -42,6 +43,11 @@ module.exports = async () => {
}
}
// generate docs
if (helpGenerator) {
await helpGenerator(process.env.OUTPUT);
}
// set activity (a.k.a. the gamer code)
(async function activityChanger() {
client.editStatus("dnd", { name: `${misc.random(messages)} | @esmBot help` });

View file

@ -2,8 +2,7 @@ const pug = require("pug");
const collections = require("./collections.js");
const fs = require("fs");
module.exports = async () => {
//const compiledFunction = pug.compileFile("./assets/pages/help.pug");
module.exports = async (output) => {
const commands = Array.from(collections.commands.keys());
const categories = {
general: [],
@ -31,7 +30,7 @@ module.exports = async () => {
categories.soundboard.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
}
}
fs.writeFile("../help.html", pug.renderFile("./assets/pages/help.pug", { commands: categories }), () => {
console.log("hi");
fs.writeFile(output, pug.renderFile("./assets/pages/help.pug", { commands: categories }), () => {
console.log("The docs have been generated.");
});
};