apps/bot/src/feats/bugs/buttons.ts (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import { option } from "@purrkit/router";
import db, { bugs, eq } from "@stealth-developers/db";
import { errorMessage } from "@/lib";
import { useGetData } from "@/middleware";
import { buildReportModal } from "./shared";
export const editButton = useGetData.button("edit-bug", {
options: {
id: option.integer({ required: true }),
},
run: async (interaction, { id }, { actor }) => {
if (!actor) return errorMessage(interaction, "Failed to retrieve your user data");
const [bug] = await db.select().from(bugs).where(eq(bugs.id, id));
if (!bug) return errorMessage(interaction, "Bug not found.");
if (!actor.moderator && bug.actorId !== actor.id) {
return errorMessage(interaction, "You do not have permission to edit this bug.");
}
const modal = buildReportModal(bug);
console.log(modal.toJSON());
interaction.showModal(modal);
},
});
|