move filter up

This commit is contained in:
Ryan Cao 2022-06-10 19:37:45 +08:00
parent aca38d2924
commit fc5f7fdc82
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F

View file

@ -11,8 +11,6 @@ import { commands } from './commands';
import { filterMessage } from './filters';
import { parseLog } from './logs';
import { green, bold, blue, underline, yellow } from 'kleur/colors';
import {
parse as discordParse,
type SuccessfulParsedMessage,
@ -21,7 +19,9 @@ import {
import { readFile } from 'fs/promises';
import { join } from 'path';
import { green, bold, blue, underline, yellow } from 'kleur/colors';
import 'dotenv/config';
export interface Command {
name: string;
aliases?: string[];
@ -93,6 +93,11 @@ client.once('ready', async () => {
return;
}
const messageIsOK = await filterMessage(e);
if (!messageIsOK) {
return;
}
const commanded = await parseMsg(e);
if (commanded) return;
@ -101,11 +106,6 @@ client.once('ready', async () => {
e.reply({ embeds: [log] });
return;
}
const filtered = await filterMessage(e);
if (!filtered) {
return;
}
});
});
@ -138,6 +138,7 @@ async function parseMsg(e: Message) {
}
return false;
}
try {
await cmd.exec(e, parsed);
} catch (err: unknown) {