1- const { RichEmbed } = require ( "discord.js" )
1+ const { RichEmbed } = require ( "discord.js" ) ;
22const { prefix } = require ( "../../botconfig.json" ) ;
3- const { cyan } = require ( "../../colours.json" ) ;
3+ const { readdirSync } = require ( "fs" )
4+ const { stripIndents } = require ( "common-tags" )
5+ const { cyan } = require ( "../../colours.json" )
46
57module . exports = {
68 config : {
79 name : "help" ,
810 aliases : [ "h" , "halp" , "commands" ] ,
9- usage : "!usage " ,
11+ usage : "(command) " ,
1012 category : "miscellaneous" ,
11- description : "" ,
13+ description : "Displays all commands that the bot has. " ,
1214 accessableby : "Members"
1315 } ,
1416 run : async ( bot , message , args ) => {
15- let arr = [ ] ;
16- let types = [ "Moderation" , "Miscellaneous" ] ;
17- let embed = new RichEmbed ( )
17+ const embed = new RichEmbed ( )
18+ . setColor ( cyan )
19+ . setAuthor ( `${ message . guild . me . displayName } Help` , message . guild . iconURL )
20+ . setThumbnail ( bot . user . displayAvatarURL )
1821
19- if ( ! args [ 0 ] ) {
20- for ( let i = 0 ; i < types . length ; i ++ ) {
21- arr . push ( bot . commands . filter ( c => c . config . category == types [ i ] . toLowerCase ( ) ) . map ( c => `\`${ c . config . name } \`` ) . join ( " " ) ) ;
22- try {
23- embed . addField ( types [ i ] , arr [ i ] ) ;
24- } catch ( e ) {
25- embed . addBlankField ( ) ;
26- }
27- }
22+ if ( ! args [ 0 ] ) {
23+ const categories = readdirSync ( "./commands/" )
24+
25+ embed . setDescription ( `These are the avaliable commands for ${ message . guild . me . displayName } \nThe bot prefix is: **${ prefix } **` )
26+ embed . setFooter ( `© ${ message . guild . me . displayName } | Total Commands: ${ bot . commands . size } ` , bot . user . displayAvatarURL ) ;
27+
28+ categories . forEach ( category => {
29+ const dir = bot . commands . filter ( c => c . config . category === category )
30+ const capitalise = category . slice ( 0 , 1 ) . toUpperCase ( ) + category . slice ( 1 )
31+ try {
32+ embed . addField ( `❯ ${ capitalise } [${ dir . size } ]:` , dir . map ( c => `\`${ c . config . name } \`` ) . join ( " " ) )
33+ } catch ( e ) {
34+ console . log ( e )
35+ }
36+ } )
37+
38+ return message . channel . send ( embed )
39+ } else {
40+ let command = bot . commands . get ( bot . aliases . get ( args [ 0 ] . toLowerCase ( ) ) || args [ 0 ] . toLowerCase ( ) )
41+ if ( ! command ) return message . channel . send ( embed . setTitle ( "Invalid Command." ) . setDescription ( `Do \`${ prefix } help\` for the list of the commands.` ) )
42+ command = command . config
43+
44+ embed . setDescription ( stripIndents `The bot's prefix is: \`${ prefix } \`\n
45+ **Command:** ${ command . name . slice ( 0 , 1 ) . toUpperCase ( ) + command . name . slice ( 1 ) }
46+ **Description:** ${ command . description || "No Description provided." }
47+ **Usage:** ${ command . usage ? `\`${ prefix } ${ command . name } ${ command . usage } \`` : "No Usage" }
48+ **Accessible by:** ${ command . accessableby || "Members" }
49+ **Aliases:** ${ command . aliases ? command . aliases . join ( ", " ) : "None." } ` )
2850
29- embed . setColor ( cyan )
30- . setAuthor ( `${ message . guild . me . displayName } Help` , message . guild . iconURL )
31- . setThumbnail ( bot . user . displayAvatarURL )
32- . setTimestamp ( )
33- . setDescription ( `These are the avaliable commands for the TestBOT!\nThe bot prefix is: **${ prefix } **` )
34- . setFooter ( "Test Bot 2k19" , bot . user . displayAvatarURL )
35- message . channel . send ( embed )
36- } else {
37- let command = bot . commands . get ( args [ 0 ] . toLowerCase ( ) ) ? bot . commands . get ( args [ 0 ] . toLowerCase ( ) ) . config : bot . commands . get ( bot . aliases . get ( args [ 0 ] . toLowerCase ( ) ) ) . config ;
38-
39- embed . setColor ( cyan )
40- . setAuthor ( `${ message . guild . me . displayName } Help` , message . guild . iconURL )
41- . setThumbnail ( bot . user . displayAvatarURL )
42- . setDescription ( `The bot prefix is: ${ prefix } \n\n**Command:** ${ command . name } \n**Description:** ${ command . description || "No Description" } \n**Usage:** ${ command . usage || "No Usage" } \n**Accessable by:** ${ command . accessableby || "Members" } \n**Aliases:** ${ command . aliases ? command . aliases . join ( ", " ) : "None" } ` )
43- message . channel . send ( embed ) ;
51+ return message . channel . send ( embed )
4452 }
4553 }
46- }
54+ }
0 commit comments