2021-05-07 23:57:48 +00:00
import Command from '../../handler/structures/Command' ;
import { Context } from '../../utils/types' ;
import lingua from '../../utils/lingua' ;
import { Folders , Commands } from "../../utils/command.amount" ;
import { MessageEmbed } from 'discord.js' ;
export = class Help extends Command {
constructor ( ) {
super ( {
name : "help" ,
aliases : [ '?' , 'h' ] ,
description : "Get help with the Bot" ,
cooldown : 1 ,
} )
}
// ? [ 'developer', 'general', 'images', 'misc', 'roleplay' ]
async command ( ctx : Context ) {
let embed = new MessageEmbed ( ) . setColor ( ctx . config . variables . color ) . setFooter ( ` ${ ctx . config . variables . name } ` , ctx . config . variables . avatar )
if ( ctx . args . length === 0 ) {
await ( await Folders ( ) ) . forEach ( async folder = > {
if ( ! ctx . isDeveloper && folder === 'developer' ) return
// @ts-ignore
2021-07-02 12:18:36 +00:00
return embed . addField ( ` ${ lingua [ ctx . settings . locale ] . CATEGORIES [ folder . toUpperCase ( ) ] . name || folder } [ \` ${ [ . . . ( await Commands ( folder , ctx . client ) ) ] . length } \` ] ` , ` \` ${ ctx . config . variables . prefix [ 0 ] } help ${ folder } \` ` , true )
2021-05-07 23:57:48 +00:00
} )
2021-05-10 15:22:52 +00:00
embed . setTitle ( ` ${ ctx . config . variables . name } Help ` )
2021-05-07 23:57:48 +00:00
return ctx . channel . send ( embed )
}
let arg = ctx . args [ 0 ]
if ( await ( await Folders ( ) ) . includes ( arg ) ) {
2021-05-10 15:22:52 +00:00
if ( arg === 'developer' ) return
2021-05-07 23:57:48 +00:00
let commands = await ( await Commands ( arg , ctx . client ) ) . map ( command = > ` \` ${ command . name } \` - ${ command . description } ` )
embed . addField ( "Commands" , commands . join ( "\n" ) )
// @ts-ignore
embed . setTitle ( ` ${ lingua [ ctx . settings . locale ] . CATEGORIES [ arg . toUpperCase ( ) ] . name || arg } ` )
2021-05-10 15:22:52 +00:00
// @ts-ignore
embed . setDescription ( ` ${ lingua [ ctx . settings . locale ] . CATEGORIES [ arg . toUpperCase ( ) ] . desc || "" } \ n \ nTotal Commands: ** ${ commands . length } ** ` )
2021-05-07 23:57:48 +00:00
return ctx . channel . send ( embed )
}
2021-05-10 15:22:52 +00:00
// @ts-ignore
let command = ctx . client . commands . find ( ( c ) = > c . name . toLowerCase ( ) == arg || ( c . aliases && c . aliases . includes ( arg ) ) )
// let aliases = ctx.client.commands.filter()
if ( command ) {
embed . setTitle ( "Command Help" )
if ( command . aliases ? . length !== 0 ) embed . addField ( "Aliases" , ` ⇒ \` ${ command . aliases ? . join ( "`\n⇒`" ) } \` ` , true )
// @ts-ignore
embed . setDescription ( ` **Cooldown:** ${ command . cooldown } s \ n**Module:** ${ lingua [ ctx . settings . locale ] . CATEGORIES [ command . module . toUpperCase ( ) ] . name || command . module } \ n**NSFW:** ${ command . nsfw } ` )
embed . addField ( "Usage" , ` \` thal ${ command . name } \` ${ command . usage } ` , true )
ctx . channel . send ( embed )
}
2021-05-07 23:57:48 +00:00
}
}