reworked fetching procedure

This commit is contained in:
mmacierzanka committed 2021-08-02 21:12:16 +02:00
1 parent 8ff79484c5
commit 8bd3dbd8d2
3 files changed
+27 -47

No files matched your search

+4 -4
View File
@@ -112,9 +112,8 @@ export class Bot extends EventEmitter {
this.emit("READY");
});
this.client.on("message", async (m) => {
const cmdMsg: CommandMessageStructure | null =
this.commands.fetch(m);
if (cmdMsg?.command) {
const cmdMsg = this.commands.fetch(m);
if (cmdMsg) {
this.emit("COMMAND", m, cmdMsg);
try {
await cmdMsg.command.start(m, cmdMsg.arguments);
@@ -143,7 +142,8 @@ export class Bot extends EventEmitter {
this.emit("ERROR", e);
return;
}
} else if (cmdMsg) {
} else if (m.content.startsWith(this.commands.prefix)) {
this.emit("MESSAGE", m);
this.messages.system.send(
"NOT_FOUND",
{ phrase: m.content, user: m.member || undefined },