embeds for specific commands

This commit is contained in:
rhearmas 2019-12-23 22:13:14 -05:00
parent 1913704e90
commit d8de3f5c54

View file

@ -1,43 +1,61 @@
exports.run = (client, message, args, level) => { const { RichEmbed } = require('discord.js');
message.delete();
if (!args[0]) {
const myCommands = message.guild ? client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level) : client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true);
const commandNames = myCommands.keyArray();
const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
let currentCategory = ""; exports.run = (client, message, args, level) => {
let output = `= Command List =\n\n[Use ${message.settings.prefix}help <commandname> for details]\n`; message.delete();
const sorted = myCommands.array().sort((p, c) => p.help.category > c.help.category ? 1 : p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1 ); if (!args[0]) {
sorted.forEach( c => { const myCommands = message.guild ? client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level) : client.commands.filter(cmd => client.levelCache[cmd.conf.permLevel] <= level && cmd.conf.guildOnly !== true);
const cat = c.help.category.toProperCase();
if (currentCategory !== cat) { const commandNames = myCommands.keyArray();
output += `\u200b\n== ${cat} ==\n`; const longest = commandNames.reduce((long, str) => Math.max(long, str.length), 0);
currentCategory = cat;
} let currentCategory = "";
output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: ${c.help.description}\n`; let output = `= Command List =\n\n[Use ${message.settings.prefix}help <commandname> for details]\n`;
}); const sorted = myCommands.array().sort((p, c) => p.help.category > c.help.category ? 1 : p.help.name > c.help.name && p.help.category === c.help.category ? 1 : -1 );
message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }}); sorted.forEach( c => {
} else { const cat = c.help.category.toProperCase();
let command = args[0]; if (currentCategory !== cat) {
if (client.commands.has(command)) { output += `\u200b\n== ${cat} ==\n`;
command = client.commands.get(command); currentCategory = cat;
if (level < client.levelCache[command.conf.permLevel]) return; }
message.channel.send(`= ${command.help.name} = \n${command.help.description}\nusage:: ${command.help.usage}\n${command.conf.aliases.join(", ") !== "" ? `aliases:: ${command.conf.aliases.join(", ")}` : "aliases:: none"}`, {code:"asciidoc"}); output += `${message.settings.prefix}${c.help.name}${" ".repeat(longest - c.help.name.length)} :: ${c.help.description}\n`;
} });
} message.channel.send(output, {code: "asciidoc", split: { char: "\u200b" }});
} else {
let command = args[0];
if (client.commands.has(command)) {
command = client.commands.get(command);
if (level < client.levelCache[command.conf.permLevel]) return;
message.channel.send({embed: client.embed(`Command information: "${command.help.name}"`, command.help.description, [
{
name: 'Category',
value: command.help.category !== "" ? command.help.category : "none",
inline: true
},
{
name: 'Usage',
value: command.help.usage,
inline: true
},
{
name: 'Aliases',
value: command.conf.aliases.join(", ") !== "" ? command.conf.aliases.join(", ") : "none",
inline: true
}
])});
}
}
}; };
exports.conf = { exports.conf = {
enabled: true, enabled: true,
guildOnly: false, guildOnly: false,
aliases: ["h", "halp"], aliases: ["h", "halp"],
permLevel: "User" permLevel: "User"
}; };
exports.help = { exports.help = {
name: "help", name: "help",
category: "Information", category: "Information",
description: "Displays all the available commands for your permission level.", description: "Displays all the available commands for your permission level.",
usage: "help [command]" usage: "help [command]"
}; };