2020-05-01 16:12:54 +02:00
|
|
|
const { Command } = require('../../../../interfaces/');
|
|
|
|
|
|
|
|
class HelpCommand extends Command {
|
|
|
|
|
|
|
|
constructor(client) {
|
|
|
|
|
|
|
|
super(client, {
|
|
|
|
name: 'help',
|
2020-05-07 01:26:16 +02:00
|
|
|
module: 'information'
|
2020-05-01 16:12:54 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.client = client;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
async execute(message, { params }) {
|
|
|
|
|
2020-05-21 12:47:58 +02:00
|
|
|
if (!params.length) return message.embed({
|
|
|
|
description: message.format('C_HELP')
|
|
|
|
});
|
2020-05-07 01:26:16 +02:00
|
|
|
|
2020-05-05 15:33:14 +02:00
|
|
|
const [ key ] = params;
|
|
|
|
let [ result ] = this.client.resolver.components(key, 'command');
|
|
|
|
if (!result) [ result ] = this.client.resolver.components(key, 'setting');
|
2020-07-26 22:10:46 +02:00
|
|
|
if (!result) result = this.client.resolver.componentsByTag(key, 'any', false);
|
2020-05-21 12:47:58 +02:00
|
|
|
if (!result) return message.embed({
|
|
|
|
description: message.format('C_HELP_404', { component: key })
|
|
|
|
});
|
2020-05-01 16:12:54 +02:00
|
|
|
|
2020-07-26 22:10:46 +02:00
|
|
|
if (result instanceof Array) {
|
2020-08-04 11:35:58 +02:00
|
|
|
|
|
|
|
const commands = result.filter((c) => c.type === 'command');
|
|
|
|
const settings = result.filter((c) => c.type === 'setting');
|
|
|
|
|
|
|
|
const embed = {
|
|
|
|
description: message.format('C_HELP_TAGS', { keyword: key }),
|
|
|
|
fields: [
|
|
|
|
{
|
|
|
|
name: 'Commands',
|
|
|
|
value: commands.length ? commands.map((c) => c.name).join('\n') : 'N/A',
|
|
|
|
inline: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Settings',
|
|
|
|
value: settings.length ? settings.map((s) => s.display).join('\n') : 'N/A',
|
|
|
|
inline: true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
return message.embed(embed);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return message.embed(result.usageEmbed(message, true));
|
2020-07-26 22:10:46 +02:00
|
|
|
|
|
|
|
// //let index = `${result.type.slice(0, 1).toUpperCase()}_${result.name.toUpperCase()}_HELP`;
|
|
|
|
// const em = {
|
|
|
|
// description: message.format('C_HELP_TEMPLATE', {
|
|
|
|
// desc: message.format(result.description),
|
|
|
|
// component: result.name.toUpperCase(),
|
|
|
|
// text: result.examples.map((ex) => `\`{prefix}${result.type === 'command' ? result.name.toLowerCase() : `settings ${result.name.toLowerCase()}`} ${ex}\``).join('\n')
|
|
|
|
// })
|
|
|
|
// };
|
|
|
|
// if (result.aliases.length) em.fields = [
|
|
|
|
// {
|
|
|
|
// name: 'Aliases',
|
|
|
|
// value: result.aliases.map((al) => al.toLowerCase()).join(', ')
|
|
|
|
// }
|
|
|
|
// ];
|
|
|
|
|
|
|
|
// return message.embed(em);
|
2020-05-01 16:12:54 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HelpCommand;
|