forked from pinks/eris
1
0
Fork 0
nyx/bot/cancelCommand.ts

10 lines
390 B
TypeScript

import { jobStore } from "../db/jobStore.ts";
import { Context } from "./mod.ts";
export async function cancelCommand(ctx: Context) {
const jobs = await jobStore.getBy("status.type", { value: "waiting" });
const userJobs = jobs.filter((j) => j.value.from.id === ctx.from?.id);
for (const job of userJobs) await job.delete();
await ctx.reply(`Cancelled ${userJobs.length} jobs`);
}