From 87e77ae8cc69d0d7f1e3d6f614b03c9297e85ab3 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 19 Jun 2021 23:07:24 -0400 Subject: feat(*): Made everything work better --- src/commands/info/help.ts | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/commands') diff --git a/src/commands/info/help.ts b/src/commands/info/help.ts index e7998a4..9caae24 100644 --- a/src/commands/info/help.ts +++ b/src/commands/info/help.ts @@ -1,8 +1,7 @@ -import { stripIndent } from 'common-tags'; -import { Message, MessageEmbed } from 'discord.js'; -import { SlashCommandOption } from '../../lib/extensions/BushClientUtil'; +import { MessageEmbed } from 'discord.js'; import { BushCommand } from '../../lib/extensions/BushCommand'; import { BushInteractionMessage } from '../../lib/extensions/BushInteractionMessage'; +import { BushMessage } from '../../lib/extensions/BushMessage'; export default class HelpCommand extends BushCommand { constructor() { @@ -33,18 +32,13 @@ export default class HelpCommand extends BushCommand { }); } - private generateEmbed(command?: BushCommand): MessageEmbed { - const prefix = this.handler.prefix; + private generateEmbed(command?: BushCommand, message?: BushInteractionMessage | BushMessage): MessageEmbed { + const prefix = this.client.config.dev ? 'dev ' : message.util.parsed.prefix; if (!command) { const embed = new MessageEmbed() - .addField( - 'Commands', - stripIndent`A list of available commands. - For additional info on a command, type \`${prefix}help \` - ` - ) - .setFooter(`For more information about a command use "${this.client.config.prefix}help "`) - .setTimestamp(); + .setFooter(`For more information about a command use '${prefix}help '`) + .setTimestamp() + .setColor(this.client.util.colors.default); for (const category of this.handler.categories.values()) { embed.addField( `${category.id.replace(/(\b\w)/gi, (lc): string => lc.toUpperCase())}`, @@ -71,15 +65,13 @@ export default class HelpCommand extends BushCommand { } } - public async exec(message: Message, { command }: { command: BushCommand }): Promise { - await message.util.send({ embeds: [this.generateEmbed(command)] }); - } - - public async execSlash(message: BushInteractionMessage, { command }: { command: SlashCommandOption }): Promise { - if (command) { - await message.interaction.reply({ embeds: [this.generateEmbed(this.handler.findCommand(command.value) as BushCommand)] }); - } else { - await message.interaction.reply({ embeds: [this.generateEmbed()] }); - } + public async exec( + message: BushMessage | BushInteractionMessage, + { command }: { command: BushCommand | string } + ): Promise { + const parsedCommand = message.util.isSlash + ? (this.handler.findCommand(command as string) as BushCommand) + : (command as BushCommand); + await message.util.send({ embeds: [this.generateEmbed(parsedCommand, message)] }); } } -- cgit