woomy/commands/help.js

88 lines
3.1 KiB
JavaScript
Raw Normal View History

exports.conf = {
enabled: true,
guildOnly: false,
2020-04-11 09:30:51 +00:00
aliases: ['commands', 'cmds'],
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.',
usage: '`help` - Lists all commands.\n`help <command>` - Show detailed information on how to use the specified command.',
parameters: '`command` - The name of the command you want more information on.'
}
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-11 09:30:51 +00:00
if (!args[0]) {
const categories = []
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`'
}
embed.setTitle('Woomy Help')
embed.setDescription(`**Prefixes**\n» Default: \`${client.config.defaultPrefix}\`\n» Server: ${gPrefix}\n» Personal: ${uPrefix}\n\n» [Join my discord server](https://discord.gg/HCF8mdv) if you need help!\n» Use \`help <command>\` to recieve more information about a command!`)
2020-04-06 09:36:32 +00:00
const commands = client.commands
commands.forEach((cmd) => {
if (!categories.includes(cmd.help.category)) {
2020-04-08 14:09:55 +00:00
if (cmd.help.category === 'Developer' && !client.config.devs.includes('message.author.id')) {
return
}
2020-04-06 09:36:32 +00:00
categories.push(cmd.help.category)
}
})
categories.sort().forEach((cat) => {
const filtered = commands.filter((cmd) => cmd.help.category === cat)
2020-04-11 09:30:51 +00:00
embed.addField('**' + cat + '**', filtered.map((cmd) => '`' + cmd.help.name + '`').join(', '), true)
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-11 09:30:51 +00:00
embed.addField('**Custom**', data.guild.customCommands.map((cmd) => '`' + cmd.name + '`').join(' '), true)
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()
const cmd = client.commands.get(command) || client.commands.get(client.aliases.get(command))
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-10 02:57:04 +00:00
if (aliases) {
embed.addField('**Aliases**', aliases)
}
2020-04-11 09:30:51 +00:00
if (cmd.help.parameters.length > 0) {
embed.addField('**Parameters**', cmd.help.parameters)
}
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
}
}