From 68f2fef16ef97e44088029dbaa03d41af4815572 Mon Sep 17 00:00:00 2001 From: Navy Date: Tue, 15 Jun 2021 20:15:55 +0300 Subject: [PATCH] should not respond in ignored channel even for inhibitor errors --- structure/client/Resolver.js | 9 +++++++++ .../client/components/observers/CommandHandler.js | 13 +++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/structure/client/Resolver.js b/structure/client/Resolver.js index a3a8b76..d98cf2a 100644 --- a/structure/client/Resolver.js +++ b/structure/client/Resolver.js @@ -712,6 +712,15 @@ class Resolver { } + /** + * Resolves input into an emoji, either a custom or a unicode emoji. Returned object will have a type property indicating whether it's custom or unicode. + * + * @param {Array} [resolveables=[]] + * @param {boolean} strict + * @param {Guild} guild + * @return {Object} + * @memberof Resolver + */ async resolveEmojis(resolveables = [], strict, guild) { if (typeof resolveables === 'string') resolveables = [resolveables]; diff --git a/structure/client/components/observers/CommandHandler.js b/structure/client/components/observers/CommandHandler.js index 7edbdaa..915c0a5 100644 --- a/structure/client/components/observers/CommandHandler.js +++ b/structure/client/components/observers/CommandHandler.js @@ -389,15 +389,16 @@ class CommandHandler extends Observer { const silent = inhibitors.filter((i) => i.inhibitor.silent); const nonsilent = inhibitors.filter((i) => !i.inhibitor.silent); - if(nonsilent.length === 0 && silent.length > 0) return undefined; - if(nonsilent.length > 0) return this.handleError(message, { type: 'inhibitor', ...nonsilent[0] }); + if (silent.length && silent.some((result) => result.inhibitor.id === 'channelIgnore')) return; + if (nonsilent.length === 0 && silent.length > 0) return undefined; + if (nonsilent.length > 0) return this.handleError(message, { type: 'inhibitor', ...nonsilent[0] }); const resolved = await message.resolve(); - if(resolved.error) { + if (resolved.error) { this.client.logger.error(`Command Error | ${message.command.resolveable} | Message ID: ${message.id}\n${resolved.message.stack || resolved.message}`); - if(resolved.message.code === 50013) { + if (resolved.message.code === 50013) { const missing = message.channel.permissionsFor(message.guild.me).missing(['EMBED_LINKS']); - if(missing.length > 0) { + if (missing.length > 0) { return message.respond(message.format('COMMANDHANDLER_COMMAND_MISSINGPERMISSIONS'), { emoji: 'failure' }); @@ -428,7 +429,7 @@ class CommandHandler extends Observer { const reasons = (await Promise.all(promises)).filter((p) => p.error); // Filters out inhibitors with only errors. if(reasons.length === 0) return []; - reasons.sort((a, b) => b.inhibitor.priority - a.inhibitor.priority); // Sorts inhibitor errors by most important. + reasons.sort((a, b) => a.inhibitor.priority - b.inhibitor.priority); // Sorts inhibitor errors by most important. return reasons; }