Add DELETE guild settings route

For completely resetting a guild
This commit is contained in:
Isaac 2022-05-07 21:28:33 +01:00
parent 41ccd778c6
commit 145514a86b
2 changed files with 16 additions and 3 deletions

View File

@ -74,7 +74,7 @@ model Category {
discordCategory String @db.VarChar(19)
emoji String
enableFeedback Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id])
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19)
id Int @id @default(autoincrement())
image String?
@ -161,7 +161,7 @@ model QuestionAnswer {
model Tag {
content String
createdAt DateTime @default(now())
guild Guild @relation(fields: [guildId], references: [id])
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19)
id Int @id @default(autoincrement())
name String
@ -191,7 +191,7 @@ model Ticket {
feedbackId Int?
firstResponseAt DateTime?
deleted Boolean @default(false)
guild Guild @relation(fields: [guildId], references: [id])
guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade)
guildId String @db.VarChar(19)
id String @id @db.VarChar(19)
lastMessageAt DateTime?

View File

@ -1,3 +1,16 @@
module.exports.delete = fastify => ({
handler: async (req, res) => {
/** @type {import('../../../../../client')} */
const client = res.context.config.client;
await client.prisma.guild.delete({ where: { id: req.params.guild } });
const settings = await client.prisma.guild.create({ data: { id: req.params.guild } });
res.send(settings);
},
onRequest: [fastify.authenticate, fastify.isAdmin],
});
module.exports.get = fastify => ({
handler: async (req, res) => {
/** @type {import('../../../../../client')} */