2019-12-05 16:58:46 +00:00
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" ) ;
2020-02-11 01:49:35 +00:00
module . exports = async ( output ) => {
2020-09-01 22:10:19 +00:00
const template = ` # <img src="https://raw.githubusercontent.com/esmBot/esmBot/master/esmbot.png" width="64"> esmBot ${ process . env . NODE _ENV === "development" ? " Dev" : "" } Command List
$ { process . env . NODE _ENV === "development" ? "\n**You are currently using esmBot Dev! Things may change at any time without warning and there will be bugs. Many bugs. If you find one, [report it here](https://github.com/esmBot/esmBot/issues) or in the esmBot Support server.**\n" : "" }
2019-12-20 17:39:30 +00:00
\ ` [] \` means an argument is required, \` {} \` means an argument is optional.
Default prefix is \ ` & \` .
2020-08-13 13:47:41 +00:00
* * Want to help support esmBot ' s development ? Consider donating on Patreon ! * * https : //patreon.com/TheEssem
2020-01-08 01:17:04 +00:00
> Tip : You can get more info about a command by using \ ` help [command] \` .
2019-12-20 17:39:30 +00:00
# # Table of Contents
+ [ * * General * * ] ( # 💻 - general )
+ [ * * Tags * * ] ( # 🏷 ️ - tags )
+ [ * * Fun * * ] ( # 👌 - fun )
+ [ * * Image Editing * * ] ( # 🖼 ️ - image - editing )
+ [ * * Soundboard * * ] ( # 🔊 - soundboard )
2020-07-06 20:19:30 +00:00
+ [ * * Music * * ] ( # 🎤 - music )
2019-12-20 17:39:30 +00:00
` ;
2020-03-10 22:24:57 +00:00
const commands = collections . commands ;
2019-12-05 16:58:46 +00:00
const categories = {
2019-12-20 17:39:30 +00:00
general : [ "## 💻 General" ] ,
tags : [ "## 🏷️ Tags" ] ,
fun : [ "## 👌 Fun" ] ,
2020-01-08 01:17:04 +00:00
images : [ "## 🖼️ Image Editing" , "> These commands support the PNG, JPEG, WEBP, and GIF formats. (GIF support is currently experimental)" ] ,
2020-07-06 20:19:30 +00:00
soundboard : [ "## 🔊 Soundboard" ] ,
music : [ "## 🎤 Music" ]
2019-12-05 16:58:46 +00:00
} ;
2020-03-10 22:24:57 +00:00
for ( const [ command ] of commands ) {
2019-12-05 16:58:46 +00:00
const category = collections . info . get ( command ) . category ;
const description = collections . info . get ( command ) . description ;
const params = collections . info . get ( command ) . params ;
if ( category === 1 ) {
2019-12-20 17:39:30 +00:00
categories . general . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-05 16:58:46 +00:00
} else if ( category === 2 ) {
2019-12-20 17:39:30 +00:00
categories . moderation . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-05 16:58:46 +00:00
} else if ( category === 3 ) {
2020-03-10 22:24:57 +00:00
const subCommands = [ ... Object . keys ( description ) ] ;
2019-12-06 00:15:28 +00:00
for ( const subCommand of subCommands ) {
2019-12-20 17:39:30 +00:00
categories . tags . push ( ` + **tags ${ subCommand !== "default" ? ` ${ subCommand } ` : "" } ** ${ params [ subCommand ] ? ` ${ params [ subCommand ] } ` : "" } - ${ description [ subCommand ] } ` ) ;
2019-12-06 00:15:28 +00:00
}
2019-12-05 16:58:46 +00:00
} else if ( category === 4 ) {
2019-12-20 17:39:30 +00:00
categories . fun . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-05 16:58:46 +00:00
} else if ( category === 5 ) {
2019-12-20 17:39:30 +00:00
categories . images . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-05 16:58:46 +00:00
} else if ( category === 6 ) {
2019-12-20 17:39:30 +00:00
categories . soundboard . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2020-07-06 20:19:30 +00:00
} else if ( category === 7 ) {
categories . music . push ( ` + ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-05 16:58:46 +00:00
}
}
2020-12-18 02:32:19 +00:00
fs . writeFile ( output , ` ${ template } \n ${ categories . general . join ( "\n" ) } \n \n ${ categories . tags . join ( "\n" ) } \n \n ${ categories . fun . join ( "\n" ) } \n \n ${ categories . images . join ( "\n" ) } \n \n ${ categories . soundboard . join ( "\n" ) } \n \n ${ categories . music . join ( "\n" ) } ` , ( ) => {
2019-12-06 00:15:28 +00:00
logger . log ( "The help docs have been generated." ) ;
2019-12-05 16:58:46 +00:00
} ) ;
} ;