2019-09-13 20:02:41 +00:00
const database = require ( "../utils/database.js" ) ;
2019-12-02 20:47:22 +00:00
const collections = require ( "../utils/collections.js" ) ;
const client = require ( "../utils/client.js" ) ;
const misc = require ( "../utils/misc.js" ) ;
const paginator = require ( "../utils/pagination/pagination.js" ) ;
2020-07-28 14:38:55 +00:00
const tips = [ "You can change the bot's prefix using the prefix command." , "Image commands also work with images previously posted in that channel." , "You can use the tags commands to save things for later use." , "You can visit https://projectlounge.pw/esmBot/help.html for a web version of this command list." , "You can view a command's aliases by putting the command name after the help command (e.g. help image)." , "Parameters wrapped in [] are required, while parameters wrapped in {} are optional." , "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem" ] ;
2019-09-13 20:02:41 +00:00
2019-12-02 20:47:22 +00:00
exports . run = async ( message , args ) => {
2020-09-01 22:10:19 +00:00
const { prefix } = message . channel . guild ? await database . guilds . findOne ( { id : message . channel . guild . id } ) : "N/A" ;
2020-03-10 22:24:57 +00:00
const commands = collections . commands ;
const aliases = collections . aliases ;
if ( args . length !== 0 && ( commands . has ( args [ 0 ] . toLowerCase ( ) ) || aliases . has ( args [ 0 ] . toLowerCase ( ) ) ) ) {
2020-07-29 23:06:34 +00:00
const command = aliases . has ( args [ 0 ] . toLowerCase ( ) ) ? collections . aliases . get ( args [ 0 ] . toLowerCase ( ) ) : args [ 0 ] . toLowerCase ( ) ;
const info = collections . info . get ( command ) ;
const counts = ( await database . global . findOne ( { } ) ) . cmdCounts ;
2019-12-02 20:47:22 +00:00
const embed = {
"embed" : {
"author" : {
2019-12-09 20:52:33 +00:00
"name" : "esmBot Help" ,
2019-12-02 20:47:22 +00:00
"icon_url" : client . user . avatarURL
} ,
2020-09-01 22:10:19 +00:00
"title" : ` ${ prefix } ${ command } ` ,
2020-05-17 23:02:30 +00:00
"url" : "https://projectlounge.pw/esmBot/help.html" ,
2019-12-02 20:47:22 +00:00
"description" : info . description ,
"color" : 16711680 ,
"fields" : [ {
"name" : "Aliases" ,
"value" : info . aliases ? info . aliases . join ( ", " ) : "None"
2020-07-29 23:06:34 +00:00
} , {
"name" : "Times Used" ,
"value" : counts . get ( command ) ,
"inline" : true
2019-12-05 16:58:46 +00:00
} , {
"name" : "Parameters" ,
2020-07-29 23:06:34 +00:00
"value" : info . params ? info . params : "None" ,
"inline" : true
2019-12-02 20:47:22 +00:00
} ]
}
} ;
2020-04-12 19:51:48 +00:00
return embed ;
2019-12-02 20:47:22 +00:00
} else {
const categories = {
general : [ ] ,
moderation : [ ] ,
2019-12-05 16:58:46 +00:00
tags : [ "**Every command in this category is a subcommand of the tag command.**\n" ] ,
2019-12-02 20:47:22 +00:00
fun : [ ] ,
2020-07-06 20:19:30 +00:00
images : [ "**These commands support the PNG, JPEG, WEBP (static), and GIF (animated or static) formats.**\n" ] ,
soundboard : [ ] ,
music : [ ]
2019-12-02 20:47:22 +00:00
} ;
2020-03-10 22:24:57 +00:00
for ( const [ command ] of commands ) {
2019-12-02 20:47:22 +00:00
const category = collections . info . get ( command ) . category ;
const description = collections . info . get ( command ) . description ;
2019-12-05 16:58:46 +00:00
const params = collections . info . get ( command ) . params ;
2019-12-02 20:47:22 +00:00
if ( category === 1 ) {
2019-12-05 16:58:46 +00:00
categories . general . push ( ` ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-02 20:47:22 +00:00
} else if ( category === 2 ) {
2019-12-05 16:58:46 +00:00
categories . moderation . push ( ` ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-02 20:47:22 +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 ) {
categories . tags . push ( ` **tags ${ subCommand !== "default" ? ` ${ subCommand } ` : "" } ** ${ params [ subCommand ] ? ` ${ params [ subCommand ] } ` : "" } - ${ description [ subCommand ] } ` ) ;
}
2019-12-02 20:47:22 +00:00
} else if ( category === 4 ) {
2019-12-05 16:58:46 +00:00
categories . fun . push ( ` ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-02 20:47:22 +00:00
} else if ( category === 5 ) {
2019-12-05 16:58:46 +00:00
categories . images . push ( ` ** ${ command } ** ${ params ? ` ${ params } ` : "" } - ${ description } ` ) ;
2019-12-02 20:47:22 +00:00
} else if ( category === 6 ) {
2019-12-05 16:58:46 +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-02 20:47:22 +00:00
}
}
const pages = [ ] ;
for ( const category of Object . keys ( categories ) ) {
const splitPages = categories [ category ] . map ( ( item , index ) => {
return index % 15 === 0 ? categories [ category ] . slice ( index , index + 15 ) : null ;
} ) . filter ( ( item ) => {
return item ;
} ) ;
2020-03-10 22:24:57 +00:00
for ( const page of splitPages ) {
2019-12-02 20:47:22 +00:00
pages . push ( {
title : category . charAt ( 0 ) . toUpperCase ( ) + category . slice ( 1 ) ,
page : page
} ) ;
2020-03-10 22:24:57 +00:00
}
2019-12-02 20:47:22 +00:00
}
const embeds = [ ] ;
for ( const [ i , value ] of pages . entries ( ) ) {
embeds . push ( {
"embed" : {
"author" : {
2019-12-09 20:52:33 +00:00
"name" : "esmBot Help" ,
2019-12-02 20:47:22 +00:00
"icon_url" : client . user . avatarURL
} ,
"title" : value . title ,
"description" : value . page . join ( "\n" ) ,
"color" : 16711680 ,
"footer" : {
"text" : ` Page ${ i + 1 } of ${ pages . length } `
} ,
"fields" : [ {
"name" : "Prefix" ,
2020-09-01 22:10:19 +00:00
"value" : prefix
2019-12-02 20:47:22 +00:00
} , {
"name" : "Tip" ,
"value" : misc . random ( tips )
} ]
}
} ) ;
}
return paginator ( message , embeds ) ;
}
2019-09-13 20:02:41 +00:00
} ;
2019-12-02 20:47:22 +00:00
2019-12-09 21:33:06 +00:00
exports . aliases = [ "commands" ] ;
2019-12-02 20:47:22 +00:00
exports . category = 1 ;
2019-12-05 16:58:46 +00:00
exports . help = "Gets a list of commands" ;
exports . params = "{command}" ;