cleanup
This commit is contained in:
parent
4c775c7190
commit
746e395382
@ -1,7 +1,7 @@
|
|||||||
const { EmbedBuilder, Message, ChannelType, ComponentType, ButtonStyle } = require('discord.js');
|
const { EmbedBuilder, Message, ChannelType, ComponentType, ButtonStyle } = require('discord.js');
|
||||||
const { Util } = require('../../../utilities');
|
const { Util } = require('../../../utilities');
|
||||||
const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers');
|
const { InvokerWrapper, MessageWrapper } = require('../../client/wrappers');
|
||||||
const { Observer, CommandError } = require('../../interfaces/');
|
const { Observer, CommandError, SettingsCommand } = require('../../interfaces/');
|
||||||
// const { inspect } = require('util');
|
// const { inspect } = require('util');
|
||||||
|
|
||||||
const flagReg = /(?:^| )(?<flag>(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu;
|
const flagReg = /(?:^| )(?<flag>(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu;
|
||||||
@ -165,24 +165,25 @@ class CommandHandler extends Observer {
|
|||||||
async _executeCommand(invoker, options) {
|
async _executeCommand(invoker, options) {
|
||||||
|
|
||||||
let response = null;
|
let response = null;
|
||||||
const now = Date.now();
|
|
||||||
if (this.client.developmentMode && !this.client.developers.includes(invoker.user.id)) return invoker.reply({
|
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
|
ephemeral: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
try {
|
try {
|
||||||
let debugstr = invoker.command.name;
|
let debugstr = invoker.command.name;
|
||||||
if (invoker.subcommandGroup) debugstr += ` ${invoker.subcommandGroup.name}`;
|
if (invoker.subcommandGroup) debugstr += ` ${invoker.subcommandGroup.name}`;
|
||||||
if(invoker.subcommand) debugstr += ` ${invoker.subcommand.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'}`);
|
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);
|
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) {
|
} catch (error) {
|
||||||
if (error instanceof CommandError) {
|
if (error instanceof CommandError) {
|
||||||
this._generateError(invoker, { error, type: 'command' });
|
this._generateError(invoker, { error, type: 'command' });
|
||||||
} else {
|
} 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.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' });
|
this._generateError(invoker, { type: 'commandHandler' });
|
||||||
}
|
}
|
||||||
@ -315,6 +316,7 @@ class CommandHandler extends Observer {
|
|||||||
|
|
||||||
// console.log('matched');
|
// console.log('matched');
|
||||||
const _flag = match.groups.flag.replace(/--?/u, '').toLowerCase();
|
const _flag = match.groups.flag.replace(/--?/u, '').toLowerCase();
|
||||||
|
if(_flag === 'help') return { showUsage: true, verbose: true };
|
||||||
let aliased = false;
|
let aliased = false;
|
||||||
const flag = flags.find((f) => {
|
const flag = flags.find((f) => {
|
||||||
aliased = f.valueAsAlias && f.choices.some((c) => c.value === _flag);
|
aliased = f.valueAsAlias && f.choices.some((c) => c.value === _flag);
|
||||||
|
Loading…
Reference in New Issue
Block a user