Files
Papo/src/services/taskService.ts
Pepe44DEV 2ff54970e2
All checks were successful
Deploy Discord Bot / deploy (push) Successful in -1m11s
SonarQube / sonar (push) Successful in -3s
add setup wizard, lockdown, team tasks, embed builder; fix admin dashboard
Four new independent features: /setup (guided onboarding wizard for
module/channel/automod-strength config), /lockdown (raid protection with
per-channel permission snapshot/restore and join-kick), /task (staff task
tracker with status buttons + dashboard view), /embed create (modal-driven
embed builder with optional link button). Also fixes the Admin dashboard,
which always showed "-" because loadAdminData() double-wrapped the overview
response and discarded activity data, plus mismatched field names against
adminService's actual shape (guildCount/activeGuilds24/uptimeMs).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-03 01:02:39 +02:00

39 lines
1.0 KiB
TypeScript

import { prisma } from '../database';
export type TaskStatus = 'open' | 'in_progress' | 'done';
export class TaskService {
public async createTask(data: {
guildId: string;
title: string;
description?: string;
assigneeId?: string;
createdBy: string;
createdByTag: string;
}) {
return prisma.staffTask.create({ data });
}
public async listTasks(guildId: string, status?: string) {
return prisma.staffTask.findMany({
where: { guildId, ...(status ? { status } : {}) },
orderBy: { createdAt: 'desc' }
});
}
public async getTask(id: string) {
return prisma.staffTask.findUnique({ where: { id } });
}
public async updateStatus(id: string, status: TaskStatus) {
return prisma.staffTask.update({ where: { id }, data: { status } });
}
public async deleteTask(guildId: string, id: string) {
const task = await prisma.staffTask.findFirst({ where: { id, guildId } });
if (!task) return false;
await prisma.staffTask.delete({ where: { id } });
return true;
}
}