diff --git a/README.md b/README.md index ef2dc3b..63965c1 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,11 @@ SUPER= https://www.prisma.io/docs/reference/database-reference/supported-databases -![](https://static.eartharoid.me/k/22/08/02185801.png) - for user/create, slash/force-close and slash/move +![](https://static.eartharoid.me/k/22/08/02185801.png) - for user/create, slash/force-close, slash/claim, slash/release, and slash/move menu question max length cannot be higher than question options +- TODO: topic and question answer values not encrypted? - TODO: post stats - TODO: settings bundle download - TODO: update notifications @@ -29,4 +30,4 @@ creation requires an interaction: - message:create(staff) -> category? -> DM (channel fallback) button -> topic or questions -> create - DM -> guild? -> category? -> topic or questions -> create - panel(interaction) -> topic or questions -> create -- panel(message) -> DM (channel fallback) button -> topic or questions -> create \ No newline at end of file +- ~~panel(message) -> DM (channel fallback) button -> topic or questions -> create~~ \ No newline at end of file diff --git a/db/mysql/schema.prisma b/db/mysql/schema.prisma index f4fc83a..3c07cf7 100644 --- a/db/mysql/schema.prisma +++ b/db/mysql/schema.prisma @@ -20,16 +20,16 @@ model ArchivedChannel { } model ArchivedMessage { - author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) - authorId String @db.VarChar(19) - content String @db.Text - createdAt DateTime @default(now()) - deleted Boolean @default(false) - edited Boolean @default(false) - id String @id @db.VarChar(19) - referencedBy Ticket[] @relation("MessageReferencedByTicket") - ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) - ticketId String @db.VarChar(19) + author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) + authorId String @db.VarChar(19) + content Json + createdAt DateTime @default(now()) + deleted Boolean @default(false) + edited Boolean @default(false) + external Boolean @default(false) + id String @id @db.VarChar(19) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) + ticketId String @db.VarChar(19) @@map("archivedMessages") } @@ -68,30 +68,30 @@ model ArchivedUser { } 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 - enableFeedback Boolean @default(false) - guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) - guildId String @db.VarChar(19) - id Int @id @default(autoincrement()) - image String? - memberLimit Int @default(1) - name String - openingMessage String @db.Text - pingRoles Json @default("[]") - questions Question[] - ratelimit Int? - requiredRoles Json @default("[]") - requireTopic Boolean @default(false) - staffRoles Json - tickets Ticket[] - totalLimit Int @default(50) + channelName String + claiming Boolean @default(false) + createdAt DateTime @default(now()) + cooldown Int? + customTopic String? + description String + discordCategory String @db.VarChar(19) + emoji String + enableFeedback Boolean @default(false) + guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) + guildId String @db.VarChar(19) + id Int @id @default(autoincrement()) + image String? + memberLimit Int @default(1) + name String + openingMessage String @db.Text + pingRoles Json @default("[]") + questions Question[] + ratelimit Int? + requiredRoles Json @default("[]") + requireTopic Boolean @default(false) + staffRoles Json + tickets Ticket[] + totalLimit Int @default(50) @@map("categories") } @@ -210,11 +210,10 @@ model Ticket { messageCount Int? number Int open Boolean @default(true) - openingMessage String @db.VarChar(19) - pinnedMessages Json @default("[]") + openingMessageId String @db.VarChar(19) + pinnedMessageIds Json @default("[]") priority TicketPriority? referencedBy Ticket[] @relation("TicketsReferencedByTicket") - referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull) referencesMessageId String? @db.VarChar(19) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicketId String? @db.VarChar(19) diff --git a/db/postgresql/schema.prisma b/db/postgresql/schema.prisma index d33a429..faf816a 100644 --- a/db/postgresql/schema.prisma +++ b/db/postgresql/schema.prisma @@ -20,16 +20,16 @@ model ArchivedChannel { } model ArchivedMessage { - author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) - authorId String @db.VarChar(19) - content String @db.Text - createdAt DateTime @default(now()) - deleted Boolean @default(false) - edited Boolean @default(false) - id String @id @db.VarChar(19) - referencedBy Ticket[] @relation("MessageReferencedByTicket") - ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) - ticketId String @db.VarChar(19) + author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) + authorId String @db.VarChar(19) + content Json + createdAt DateTime @default(now()) + deleted Boolean @default(false) + edited Boolean @default(false) + external Boolean @default(false) + id String @id @db.VarChar(19) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) + ticketId String @db.VarChar(19) @@map("archivedMessages") } @@ -68,30 +68,30 @@ model ArchivedUser { } 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 - enableFeedback Boolean @default(false) - guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) - guildId String @db.VarChar(19) - id Int @id @default(autoincrement()) - image String? - memberLimit Int @default(1) - name String - openingMessage String @db.Text - pingRoles Json @default("[]") - questions Question[] - ratelimit Int? - requiredRoles Json @default("[]") - requireTopic Boolean @default(false) - staffRoles Json - tickets Ticket[] - totalLimit Int @default(50) + channelName String + claiming Boolean @default(false) + createdAt DateTime @default(now()) + cooldown Int? + customTopic String? + description String + discordCategory String @db.VarChar(19) + emoji String + enableFeedback Boolean @default(false) + guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) + guildId String @db.VarChar(19) + id Int @id @default(autoincrement()) + image String? + memberLimit Int @default(1) + name String + openingMessage String @db.Text + pingRoles Json @default("[]") + questions Question[] + ratelimit Int? + requiredRoles Json @default("[]") + requireTopic Boolean @default(false) + staffRoles Json + tickets Ticket[] + totalLimit Int @default(50) @@map("categories") } @@ -210,11 +210,10 @@ model Ticket { messageCount Int? number Int open Boolean @default(true) - openingMessage String @db.VarChar(19) - pinnedMessages Json @default("[]") + openingMessageId String @db.VarChar(19) + pinnedMessageIds Json @default("[]") priority TicketPriority? referencedBy Ticket[] @relation("TicketsReferencedByTicket") - referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull) referencesMessageId String? @db.VarChar(19) referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicketId String? @db.VarChar(19) diff --git a/db/sqlite/schema.prisma b/db/sqlite/schema.prisma index eb4e180..6213988 100644 --- a/db/sqlite/schema.prisma +++ b/db/sqlite/schema.prisma @@ -20,16 +20,16 @@ model ArchivedChannel { } model ArchivedMessage { - author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) - authorId String - content String - createdAt DateTime @default(now()) - deleted Boolean @default(false) - edited Boolean @default(false) - id String @id - referencedBy Ticket[] @relation("MessageReferencedByTicket") - ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) - ticketId String + author ArchivedUser @relation(fields: [ticketId, authorId], references: [ticketId, userId], onDelete: Cascade) + authorId String + content String + createdAt DateTime @default(now()) + deleted Boolean @default(false) + edited Boolean @default(false) + id String @id + external Boolean @default(false) + ticket Ticket @relation(fields: [ticketId], references: [id], onDelete: Cascade) + ticketId String @@map("archivedMessages") } @@ -68,30 +68,30 @@ model ArchivedUser { } model Category { - channelName String - claiming Boolean @default(false) - createdAt DateTime @default(now()) - cooldown Int? - customTopic String? - description String - discordCategory String - emoji String - enableFeedback Boolean @default(false) - guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) - guildId String - id Int @id @default(autoincrement()) - image String? - memberLimit Int @default(1) - name String - openingMessage String - pingRoles String @default("[]") - questions Question[] - ratelimit Int? - requiredRoles String @default("[]") - requireTopic Boolean @default(false) - staffRoles String - tickets Ticket[] - totalLimit Int @default(50) + channelName String + claiming Boolean @default(false) + createdAt DateTime @default(now()) + cooldown Int? + customTopic String? + description String + discordCategory String + emoji String + enableFeedback Boolean @default(false) + guild Guild @relation(fields: [guildId], references: [id], onDelete: Cascade) + guildId String + id Int @id @default(autoincrement()) + image String? + memberLimit Int @default(1) + name String + openingMessage String + pingRoles String @default("[]") + questions Question[] + ratelimit Int? + requiredRoles String @default("[]") + requireTopic Boolean @default(false) + staffRoles String + tickets Ticket[] + totalLimit Int @default(50) @@map("categories") } @@ -210,11 +210,10 @@ model Ticket { messageCount Int? number Int open Boolean @default(true) - openingMessage String - pinnedMessages String @default("[]") + openingMessageId String + pinnedMessageIds String @default("[]") priority String? referencedBy Ticket[] @relation("TicketsReferencedByTicket") - referencesMessage ArchivedMessage? @relation(name: "MessageReferencedByTicket", fields: [referencesMessageId], references: [id], onDelete: SetNull) referencesMessageId String? referencesTicket Ticket? @relation(name: "TicketsReferencedByTicket", fields: [referencesTicketId], references: [id], onDelete: SetNull) referencesTicketId String? diff --git a/src/lib/middleware/prisma-sqlite.js b/src/lib/middleware/prisma-sqlite.js index 8af1ca1..7606ee4 100644 --- a/src/lib/middleware/prisma-sqlite.js +++ b/src/lib/middleware/prisma-sqlite.js @@ -6,7 +6,7 @@ const jsonFields = [ 'blocklist', 'workingHours', 'options', - 'pinnedMessages', + 'pinnedMessageIds', ]; const traverse = (obj, action) => { diff --git a/src/lib/tickets/manager.js b/src/lib/tickets/manager.js index 7256c80..626eae9 100644 --- a/src/lib/tickets/manager.js +++ b/src/lib/tickets/manager.js @@ -371,7 +371,7 @@ module.exports = class TicketManager { guild: { connect: { id: category.guild.id } }, id: channel.id, number, - openingMessage: sent.id, + openingMessageId: sent.id, topic, }; if (referencesTicket) data.referencesTicket = { connect: { id: referencesTicket } }; diff --git a/src/listeners/client/messageCreate.js b/src/listeners/client/messageCreate.js index f4b7012..7942cfa 100644 --- a/src/listeners/client/messageCreate.js +++ b/src/listeners/client/messageCreate.js @@ -179,7 +179,9 @@ module.exports = class extends Listener { } else { // TODO: archive messages in tickets // TODO: first response + // TODO: lastMessageAt // TODO: auto tag + // TODO: staff status alert, working hours alerts } } };