setting priorities straight

This commit is contained in:
Erik 2020-06-20 00:01:58 +03:00
parent 56d1d6b63e
commit a3cbe75fed
2 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,7 @@ class Dispatcher {
const observers = this.client.registry.components
.filter((c) => c.type === 'observer' && !c.disabled)
.sort((a, b) => b.priority - a.priority);
.sort((a, b) => a.priority - b.priority);
for(const observer of observers.values()) {
for(const [hook, func] of observer.hooks) {

View File

@ -366,6 +366,7 @@ class CommandHandler extends Observer {
async handleCommand(message) {
const inhibitor = await this._handleInhibitors(message);
//console.log(inhibitor);
if(inhibitor.error) return this.handleError(message, { type: 'inhibitor', ...inhibitor });
const resolved = await message.resolve();
@ -396,7 +397,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 { error: false };
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[0];
}
@ -553,7 +554,8 @@ class CommandHandler extends Observer {
}
};
return message.respond(await messages[error.type](error), { emoji: 'failure' });
//return this.client.rateLimiter.limitSend(message.channel, await messages[error.type](error));
return message.limitedRespond(await messages[error.type](error), { emoji: 'failure' });
}