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

10 lines
390 B
TypeScript
Raw Normal View History

2023-09-18 15:51:19 +00:00
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`);
}