galactic-bot/structure/client/components/commands/information/Help.js
2020-05-22 23:13:47 +03:00

48 lines
1.4 KiB
JavaScript

const { Command } = require('../../../../interfaces/');
class HelpCommand extends Command {
constructor(client) {
super(client, {
name: 'help',
module: 'information'
});
this.client = client;
}
async execute(message, { params }) {
if (!params.length) return message.embed({
description: message.format('C_HELP')
});
const [ key ] = params;
let [ result ] = this.client.resolver.components(key, 'command');
if (!result) [ result ] = this.client.resolver.components(key, 'setting');
if (!result) return message.embed({
description: message.format('C_HELP_404', { component: key })
});
//let index = `${result.type.slice(0, 1).toUpperCase()}_${result.name.toUpperCase()}_HELP`;
return message.embed({
description: message.format('C_HELP_TEMPLATE', {
desc: message.format(result.description),
component: result.name.toUpperCase(),
text: result.examples.map(ex => `\`{prefix}${result.name} ${ex}\``).join('\n')
})//,
// fields: [
// {
// name: '',
// value: message.format(result.examples)
// }
// ]
});
}
}
module.exports = HelpCommand;