From 746e395382fc7e44757b2f83730ae466ccab96c1 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 30 Jul 2022 17:58:47 +0300 Subject: [PATCH] cleanup --- src/structure/components/observers/CommandHandler.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/structure/components/observers/CommandHandler.js b/src/structure/components/observers/CommandHandler.js index c29f3c1..46634bc 100644 --- a/src/structure/components/observers/CommandHandler.js +++ b/src/structure/components/observers/CommandHandler.js @@ -1,7 +1,7 @@ const { EmbedBuilder, Message, ChannelType, ComponentType, ButtonStyle } = require('discord.js'); const { Util } = require('../../../utilities'); const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers'); -const { Observer, CommandError } = require('../../interfaces/'); +const { Observer, CommandError, SettingsCommand } = require('../../interfaces/'); // const { inspect } = require('util'); const flagReg = /(?:^| )(?(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu; @@ -165,24 +165,25 @@ class CommandHandler extends Observer { async _executeCommand(invoker, options) { let response = null; - const now = Date.now(); if (this.client.developmentMode && !this.client.developers.includes(invoker.user.id)) return invoker.reply({ - content: 'Bot is in development mode currently and is online for stability testing.\nIt\'ll be ready for public use soon!', + content: 'The bot is temporarily unavailable.', ephemeral: true }); + const now = Date.now(); try { let debugstr = invoker.command.name; if (invoker.subcommandGroup) debugstr += ` ${invoker.subcommandGroup.name}`; if(invoker.subcommand) debugstr += ` ${invoker.subcommand.name}`; this.logger.info(`[${invoker.type.toUpperCase()}] ${invoker.user.tag} (${invoker.user.id}) is executing ${debugstr} in ${invoker.guild?.name || 'dms'}`); response = await invoker.command.execute(invoker, options); - invoker.command.success(now); + // Settings have a lot of prompts that will skew the resultts + if(!(invoker.command instanceof SettingsCommand)) invoker.command.success(now); } catch (error) { if (error instanceof CommandError) { this._generateError(invoker, { error, type: 'command' }); } else { - invoker.command.error(now); + if (!(invoker.command instanceof SettingsCommand)) invoker.command.error(now); this.logger.error(`Command ${invoker.command.name} errored:\nOptions:\n${Object.keys(options).map((key) => `[${key}: ${options[key]._rawValue}]`).join('\n')}\n${error.stack || error}`); this._generateError(invoker, { type: 'commandHandler' }); } @@ -315,6 +316,7 @@ class CommandHandler extends Observer { // console.log('matched'); const _flag = match.groups.flag.replace(/--?/u, '').toLowerCase(); + if(_flag === 'help') return { showUsage: true, verbose: true }; let aliased = false; const flag = flags.find((f) => { aliased = f.valueAsAlias && f.choices.some((c) => c.value === _flag);