This commit is contained in:
Erik 2022-07-30 17:58:47 +03:00
parent 4c775c7190
commit 746e395382
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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 = /(?:^| )(?<flag>(?:--[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);