From cc97a58165bc045248de1deb7b9e8bbf6db8cecc Mon Sep 17 00:00:00 2001 From: Isaac Date: Fri, 22 Jul 2022 00:17:07 +0100 Subject: [PATCH] Select menu question type and finally fix logging diff --- prisma/schema.prisma | 13 +++++++++++-- src/lib/logging.js | 5 +++-- .../guilds/[guild]/categories/[category]/index.js | 4 ++++ src/routes/api/client.js | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 12ffb19..8e2b303 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -70,6 +70,8 @@ model Category { channelName String claiming Boolean @default(false) createdAt DateTime @default(now()) + cooldown Int? + customTopic String? description String discordCategory String @db.VarChar(19) emoji String @@ -142,10 +144,12 @@ model Question { label String @db.VarChar(45) maxLength Int? @default(4000) minLength Int? @default(0) + options Json @default("[]") order Int placeholder String? @db.VarChar(100) required Boolean @default(true) style Int @default(2) + type QuestionType @default(TEXT) value String? @db.Text @@map("questions") @@ -207,7 +211,7 @@ model Ticket { open Boolean @default(true) openingMessage String @db.VarChar(19) pinnedMessages Json @default("[]") - priority Priority? + priority TicketPriority? referencedBy Ticket[] @relation("TicketsReferencedByTicket") referencesMessageId String @db.VarChar(19) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) @@ -232,8 +236,13 @@ model User { @@map("users") } -enum Priority { +enum TicketPriority { LOW MEDIUM HIGH } + +enum QuestionType { + MENU + TEXT +} diff --git a/src/lib/logging.js b/src/lib/logging.js index 2464618..8289cf9 100644 --- a/src/lib/logging.js +++ b/src/lib/logging.js @@ -4,8 +4,9 @@ const { } = require('discord.js'); const { diff: getDiff } = require('object-diffy'); +const uuidRegex = /[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/g; -const exists = thing => (typeof thing === 'string' && thing.length > 0) && (thing !== null && thing !== undefined); +const exists = thing => typeof thing === 'string' ? thing.length > 0 : thing !== null && thing !== undefined; const arrToObj = obj => { for (const key in obj) { @@ -29,7 +30,7 @@ function makeDiff({ const to = exists(diff[key].to) ? `+ ${String(diff[key].to).replace(/\n/g, '\\n')}\n` : ''; fields.push({ inline: true, - name: key, + name: key.replace(uuidRegex, $1 => $1.split('-')[0]), value: `\`\`\`diff\n${cleanCodeBlockContent(from + to)}\n\`\`\``, }); } diff --git a/src/routes/api/admin/guilds/[guild]/categories/[category]/index.js b/src/routes/api/admin/guilds/[guild]/categories/[category]/index.js index d4a09a5..29fe1a7 100644 --- a/src/routes/api/admin/guilds/[guild]/categories/[category]/index.js +++ b/src/routes/api/admin/guilds/[guild]/categories/[category]/index.js @@ -42,10 +42,12 @@ module.exports.get = fastify => ({ label: true, maxLength: true, minLength: true, + options: true, order: true, placeholder: true, required: true, style: true, + type: true, value: true, }, }, @@ -91,10 +93,12 @@ module.exports.patch = fastify => ({ label: true, maxLength: true, minLength: true, + options: true, order: true, placeholder: true, required: true, style: true, + type: true, value: true, }, }, diff --git a/src/routes/api/client.js b/src/routes/api/client.js index 160ef5e..b9821f9 100644 --- a/src/routes/api/client.js +++ b/src/routes/api/client.js @@ -19,6 +19,7 @@ module.exports.get = () => ({ avatar: client.user.avatarURL(), discriminator: client.user.discriminator, id: client.user.id, + portal: process.env.PORTAL || null, stats: { activatedUsers: users.length, archivedMessages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they get deleted