diff options
Diffstat (limited to 'src/commands/dev/reload.ts')
-rw-r--r-- | src/commands/dev/reload.ts | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/commands/dev/reload.ts b/src/commands/dev/reload.ts index 64e5745..36c6fd7 100644 --- a/src/commands/dev/reload.ts +++ b/src/commands/dev/reload.ts @@ -2,6 +2,8 @@ import { BushCommand } from '../../lib/extensions/BushCommand'; import { stripIndent } from 'common-tags'; import { Message } from 'discord.js'; import { CommandInteraction } from 'discord.js'; +import { SlashCommandOption } from '../../lib/extensions/Util'; +import { ApplicationCommandOptionType } from 'discord-api-types'; export default class ReloadCommand extends BushCommand { constructor() { @@ -13,19 +15,36 @@ export default class ReloadCommand extends BushCommand { usage: 'reload', examples: ['reload'] }, + args: [ + { + id: 'fast', + match: 'flag', + flag: '--fast' + } + ], ownerOnly: true, - typing: true + typing: true, + slashCommandOptions: [ + { + type: ApplicationCommandOptionType.BOOLEAN, + name: 'fast', + description: 'Wheather to use esbuild for fast compiling or not', + required: false + } + ] }); } - private async getResponse(): Promise<string> { + private async getResponse(fast: boolean): Promise<string> { try { - await this.client.util.shell('yarn rimraf dist/'); - await this.client.util.shell('yarn tsc'); + const s = new Date(); + await this.client.util.shell(`yarn build-${fast ? 'esbuild' : 'tsc'}`); this.client.commandHandler.reloadAll(); this.client.listenerHandler.reloadAll(); this.client.inhibitorHandler.reloadAll(); - return '🔁 Successfully reloaded!'; + return `🔁 Successfully reloaded! (${ + new Date().getTime() - s.getTime() + }ms)`; } catch (e) { return stripIndent` An error occured while reloading: @@ -34,11 +53,17 @@ export default class ReloadCommand extends BushCommand { } } - public async exec(message: Message): Promise<void> { - await message.util.send(await this.getResponse()); + public async exec( + message: Message, + { fast }: { fast: boolean } + ): Promise<void> { + await message.util.send(await this.getResponse(fast)); } - public async execSlash(message: CommandInteraction): Promise<void> { - await message.reply(await this.getResponse()); + public async execSlash( + message: CommandInteraction, + { fast }: { fast: SlashCommandOption<boolean> } + ): Promise<void> { + await message.reply(await this.getResponse(fast?.value)); } } |