2020-04-06 05:54:45 +00:00
exports . conf = {
enabled : true ,
guildOnly : false ,
2020-04-11 09:30:51 +00:00
aliases : [ 'commands' , 'cmds' ] ,
2020-04-06 05:54:45 +00:00
permLevel : 'User' ,
requiredPerms : [ 'EMBED_LINKS' ] ,
cooldown : 2000
}
exports . help = {
name : 'help' ,
2020-04-11 09:30:51 +00:00
category : 'Bot' ,
description : 'Lists all commands Woomy has, what they do, and how to use them.' ,
2020-04-12 09:15:31 +00:00
usage : '`help` - Shows the embed that provides info on how to use woomy. `help all` - Lists all commands.\n`help <command>` - Show detailed information on how to use the specified command.' ,
2020-04-11 09:30:51 +00:00
parameters : '`command` - The name of the command you want more information on.'
2020-04-06 05:54:45 +00:00
}
const Discord = require ( 'discord.js' )
exports . run = ( client , message , args , level , data ) => {
const embed = new Discord . MessageEmbed ( )
embed . setColor ( client . embedColour ( message . guild ) )
2020-04-06 09:36:32 +00:00
2020-04-12 09:15:31 +00:00
const commands = client . commands
const categories = [ ]
commands . forEach ( ( cmd ) => {
if ( ! categories . includes ( cmd . help . category ) ) {
if ( cmd . help . category === 'Developer' && ! client . config . devs . includes ( 'message.author.id' ) ) {
return
}
categories . push ( cmd . help . category )
}
} )
2020-04-11 09:30:51 +00:00
if ( ! args [ 0 ] ) {
let uPrefix = '`' + data . user . prefix + '`'
let gPrefix = '`' + data . guild . prefix + '`'
2020-04-06 09:36:32 +00:00
2020-04-11 09:30:51 +00:00
if ( client . config . defaultPrefix === data . user . prefix ) {
uPrefix = 'None set, use: `~myprefix'
}
2020-04-06 09:36:32 +00:00
2020-04-11 09:30:51 +00:00
if ( client . config . defaultPrefix === data . guild . prefix ) {
gPrefix = 'None set, use: `~prefix`'
}
2020-04-12 09:15:31 +00:00
embed . setTitle ( 'Help & Commands' )
embed . setDescription ( '' )
if ( client . version . news . length > 0 ) {
embed . addField ( '**News**' , client . version . news )
}
embed . addField ( '**Prefixes**' , ` Default Prefix: \` ${ client . config . defaultPrefix } \` \n Server Prefix: ${ gPrefix } \n User Prefix: ${ uPrefix } ` )
embed . addField ( '**Command Syntax**' , 'For arguments in commands:\n» Arguments in `[]` brackets are required.\n» Arguments in `<>` brackets are optional.\n» Arguments prefixed with `-` are flags, and are placed at the start of the command (`avatar -jpg mudkipscience`)' )
embed . addField ( '**Commands**' , ` Use \` ${ message . prefix } help all \` to view all commands, or \` ${ message . prefix } help <command> \` for more information on a specific command. \n \n [Bot Invite](https://discordapp.com/oauth2/authorize?client_id= ${ client . user . id } &permissions=2134240503&scope=bot) | [Discord Server](https://discord.gg/HCF8mdv) | [GitHub](https://github.com/mudkipscience/woomy) | [Vote for me!](https://top.gg/bot/435961704145485835/vote) ` )
2020-04-06 09:36:32 +00:00
2020-04-12 09:15:31 +00:00
return message . channel . send ( embed )
} else if ( args [ 0 ] === 'all' ) {
embed . setTitle ( 'Commands' )
2020-04-06 09:36:32 +00:00
categories . sort ( ) . forEach ( ( cat ) => {
const filtered = commands . filter ( ( cmd ) => cmd . help . category === cat )
2020-04-12 09:15:31 +00:00
embed . addField ( '**' + cat + '**' , filtered . map ( ( cmd ) => '`' + cmd . help . name + '`' ) . join ( ', ' ) )
2020-04-06 09:36:32 +00:00
} )
2020-04-06 16:35:06 +00:00
if ( message . guild && data . guild . customCommands . length > 0 ) {
2020-04-12 09:15:31 +00:00
embed . addField ( '**Custom**' , data . guild . customCommands . map ( ( cmd ) => '`' + cmd . name + '`' ) . join ( ' ' ) )
2020-04-06 09:36:32 +00:00
}
return message . channel . send ( embed )
2020-04-08 14:09:55 +00:00
} else {
2020-04-06 16:35:06 +00:00
const command = args . shift ( ) . toLowerCase ( )
2020-04-12 09:15:31 +00:00
const cmd = commands . get ( command ) || commands . get ( client . aliases . get ( command ) )
2020-04-06 16:35:06 +00:00
if ( ! cmd ) {
return message . channel . send ( 'Command/alias doesn\'t exist' )
}
2020-04-11 09:30:51 +00:00
let aliases = ''
2020-04-08 14:09:55 +00:00
2020-04-06 16:35:06 +00:00
if ( cmd . conf . aliases . length > 0 ) {
2020-04-10 02:57:04 +00:00
aliases = '`' + cmd . conf . aliases . join ( '`, `' ) + '`'
2020-04-06 16:35:06 +00:00
}
2020-04-08 09:30:17 +00:00
embed . setTitle ( cmd . help . category . toLowerCase ( ) + ':' + cmd . help . name )
2020-04-11 09:30:51 +00:00
embed . setDescription ( cmd . help . description )
2020-04-08 14:09:55 +00:00
embed . addField ( '**Usage**' , cmd . help . usage )
2020-04-11 09:30:51 +00:00
if ( cmd . help . parameters . length > 0 ) {
embed . addField ( '**Parameters**' , cmd . help . parameters )
}
2020-04-12 09:15:31 +00:00
if ( aliases ) {
embed . addField ( '**Aliases**' , aliases )
}
2020-04-11 09:30:51 +00:00
embed . addField ( '**Rank required**' , cmd . conf . permLevel , true )
embed . addField ( '**Server only**' , cmd . conf . guildOnly , true )
embed . addField ( '**Cooldown**' , cmd . conf . cooldown / 1000 + ' seconds' , true )
2020-04-06 16:35:06 +00:00
embed . setFooter ( '< > = optional, [ ] = required. Don\'t include the brackets in the command itself!' )
message . channel . send ( embed )
2020-04-06 09:36:32 +00:00
}
2020-04-06 05:54:45 +00:00
}