File tree Expand file tree Collapse file tree 10 files changed +16
-2
lines changed
migrations/20230309144248_4_0_0
migrations/20230309132703_4_0_0
migrations/20230309142817_4_0_0
routes/api/admin/guilds/[guild]/categories Expand file tree Collapse file tree 10 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ CREATE TABLE `archivedUsers` (
5353
5454-- CreateTable
5555CREATE TABLE `categories ` (
56+ ` blockedRoles` JSON NOT NULL ,
5657 ` channelName` VARCHAR (191 ) NOT NULL ,
5758 ` claiming` BOOLEAN NOT NULL DEFAULT false,
5859 ` createdAt` DATETIME(3 ) NOT NULL DEFAULT CURRENT_TIMESTAMP (3 ),
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ model ArchivedMessage {
3737
3838model ArchivedRole {
3939 archivedUsers ArchivedUser []
40- colour String @default (" 5865F2 " ) @db.Char (6 ) // 7289DA
40+ colour String @default (" 5865F2 " ) @db.Char (6 ) // 7289DA
4141 createdAt DateTime @default (now () )
4242 name String
4343 roleId String @db.VarChar (19 )
@@ -69,6 +69,7 @@ model ArchivedUser {
6969}
7070
7171model Category {
72+ blockedRoles Json @default (" []" )
7273 channelName String
7374 claiming Boolean @default (false )
7475 createdAt DateTime @default (now () )
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ CREATE TABLE "archivedUsers" (
5656
5757-- CreateTable
5858CREATE TABLE "categories " (
59+ " blockedRoles" JSONB NOT NULL DEFAULT ' []' ,
5960 " channelName" TEXT NOT NULL ,
6061 " claiming" BOOLEAN NOT NULL DEFAULT false,
6162 " createdAt" TIMESTAMP (3 ) NOT NULL DEFAULT CURRENT_TIMESTAMP ,
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ model ArchivedMessage {
3636
3737model ArchivedRole {
3838 archivedUsers ArchivedUser []
39- colour String @default (" 5865F2 " ) @db.Char (6 ) // 7289DA
39+ colour String @default (" 5865F2 " ) @db.Char (6 ) // 7289DA
4040 createdAt DateTime @default (now () )
4141 name String
4242 roleId String @db.VarChar (19 )
@@ -68,6 +68,7 @@ model ArchivedUser {
6868}
6969
7070model Category {
71+ blockedRoles Json @default (" []" )
7172 channelName String
7273 claiming Boolean @default (false )
7374 createdAt DateTime @default (now () )
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ CREATE TABLE "archivedUsers" (
5454
5555-- CreateTable
5656CREATE TABLE "categories " (
57+ " blockedRoles" TEXT NOT NULL DEFAULT ' []' ,
5758 " channelName" TEXT NOT NULL ,
5859 " claiming" BOOLEAN NOT NULL DEFAULT false,
5960 " createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ,
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ model ArchivedUser {
6868}
6969
7070model Category {
71+ blockedRoles String @default (" []" )
7172 channelName String
7273 claiming Boolean @default (false )
7374 createdAt DateTime @default (now () )
Original file line number Diff line number Diff line change 11const jsonFields = [
22 'pingRoles' ,
33 'requiredRoles' ,
4+ 'blockedRoles' ,
45 'staffRoles' ,
56 'autoTag' ,
67 'blocklist' ,
Original file line number Diff line number Diff line change @@ -227,6 +227,11 @@ module.exports = class TicketManager {
227227 if ( blocked ) return await sendError ( 'blocked' ) ;
228228 }
229229
230+ if ( category . blockedRoles . length !== 0 ) {
231+ const blocked = category . blockedRoles . some ( r => member . roles . cache . has ( r ) ) ;
232+ if ( blocked ) return await sendError ( 'blocked' ) ;
233+ }
234+
230235 if ( category . requiredRoles . length !== 0 ) {
231236 const missing = category . requiredRoles . some ( r => ! member . roles . cache . has ( r ) ) ;
232237 if ( missing ) return await sendError ( 'missing_roles' ) ;
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ module.exports.patch = fastify => ({
7676 const data = req . body ;
7777
7878 const select = {
79+ blockedRoles : true ,
7980 channelName : true ,
8081 claiming : true ,
8182 // createdAt: true,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module.exports.get = fastify => ({
2020 select : {
2121 categories : {
2222 select : {
23+ blockedRoles : true ,
2324 createdAt : true ,
2425 description : true ,
2526 discordCategory : true ,
You can’t perform that action at this time.
0 commit comments