moved error event emitting to fire earlier...

before sending a system message
This commit is contained in:
mmacierzanka committed 2021-09-17 18:31:43 +02:00
1 parent 706e426916
commit ef092c92d7
1 file changed
+2 -2
+2 -2
View File
@@ -164,6 +164,7 @@ export class Bot extends EventEmitter {
}
} catch (e) {
if (e instanceof PermissionsError) {
this.emit("ERROR", e);
await this.messages.system.send(
"PERMISSION",
{
@@ -172,12 +173,12 @@ export class Bot extends EventEmitter {
},
m
);
this.emit("ERROR", e);
} else if (e instanceof OperationSuccess) {
await this.messages.system.send("SUCCESS", undefined, m);
} else if (e instanceof CommandNotFound) {
await this.messages.system.send("NOT_FOUND", { phrase: e.query, user: m.member || undefined }, m);
} else {
this.emit("ERROR", e);
await this.messages.system.send(
"ERROR",
{
@@ -187,7 +188,6 @@ export class Bot extends EventEmitter {
},
m
);
this.emit("ERROR", e);
}
return;
}