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