diff --git a/.env.example b/.env.example index 312a5ac..13e7218 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/assets/pages/help.pug b/assets/pages/help.pug index fb86cd0..d3f137a 100644 --- a/assets/pages/help.pug +++ b/assets/pages/help.pug @@ -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 \ No newline at end of file diff --git a/events/ready.js b/events/ready.js index a070cfa..5ee6a41 100644 --- a/events/ready.js +++ b/events/ready.js @@ -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` }); diff --git a/utils/help.js b/utils/help.js index b50070f..48157e9 100644 --- a/utils/help.js +++ b/utils/help.js @@ -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(`${command}${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."); }); }; \ No newline at end of file