diff --git a/packages/kol.js/src/Client.ts b/packages/kol.js/src/Client.ts index cfee2a2..453515d 100644 --- a/packages/kol.js/src/Client.ts +++ b/packages/kol.js/src/Client.ts @@ -270,7 +270,7 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter TypedEmitter${ids.length} message${ids.length === 1 ? "" : "s"} deleted.`, + ); } async checkKmails() { diff --git a/packages/oaf/src/greenbox.ts b/packages/oaf/src/greenbox.ts index 033b5c8..f3a983d 100644 --- a/packages/oaf/src/greenbox.ts +++ b/packages/oaf/src/greenbox.ts @@ -7,6 +7,15 @@ import { kolClient } from "./clients/kol.js"; export async function handleGreenboxKmail(message: KoLMessage) { if (message.type !== "kmail") return; + const deleted = await kolClient.deleteKmails([message.id]); + + if (!deleted) { + await discordClient.alert( + `Could not delete greenbox message ahead of action ${message.msg}`, + ); + return; + } + // Remove spaces - KoL adds weird spaces to long messages. const text = message.msg.replace(/ /g, "").slice(9); @@ -18,8 +27,6 @@ export async function handleGreenboxKmail(message: KoLMessage) { await update(message.who.id, message.who.name, text); break; } - - await kolClient.deleteKmails([message.id]); } async function update(