@@ -41,6 +41,7 @@ export async function ticketHelper(
4141 messageEvent ?: Message ,
4242) {
4343 try {
44+ let message : Message
4445 let guild : Guild ;
4546 let user : GuildMember
4647 if ( ticketType == "event" ) {
@@ -52,6 +53,9 @@ export async function ticketHelper(
5253 flags : MessageFlags . Ephemeral
5354 } )
5455
56+ if ( interaction instanceof ModalSubmitInteraction || interaction instanceof ButtonInteraction || interaction instanceof StringSelectMenuInteraction ) {
57+ message = interaction . message
58+ }
5559 guild = interaction . guild ;
5660 user = interaction . member as GuildMember ;
5761 }
@@ -523,6 +527,13 @@ export async function ticketHelper(
523527 }
524528 } )
525529
530+ // Refresh the Message to reuse the options - is need because discord not do it... (AHAAHAH)
531+ if ( message ) {
532+ await message . edit ( {
533+ content : message . content
534+ } )
535+ }
536+
526537 if ( ticketType == "event" ) {
527538 ( messageEvent . channel as TextChannel ) . send ( {
528539 allowedMentions : {
@@ -586,6 +597,17 @@ export async function handleCloseAction(client: ExtendedClient, guild: Guild, ch
586597 return await ticketErrorMessage ( "No Data!" , interaction , client )
587598 }
588599
600+ await database . tickets . update ( {
601+ where : {
602+ TicketId : ticketId
603+ } ,
604+ data : {
605+ IsClosed : true ,
606+ IsAutoDone : isAuto ?? false ,
607+ ClosedAt : new Date
608+ }
609+ } )
610+
589611 // Default Ticket Close Actions
590612 const owner = await guild . members . fetch ( data . TicketOwnerId )
591613
@@ -938,7 +960,7 @@ export async function handleCloseAction(client: ExtendedClient, guild: Guild, ch
938960 }
939961 }
940962 if ( ! actions . includes ( "not_thread_close" ) ) {
941- await ( channel as ThreadChannel ) . setInvitable ( true , "Moderator Action from Ticket with Id " + ticketId )
963+ await ( channel as ThreadChannel ) . setArchived ( true , "Moderator Action from Ticket with Id " + ticketId )
942964 }
943965 if ( data . TranscriptChannelId ) {
944966 actionCounter += 1
@@ -955,7 +977,7 @@ export async function handleCloseAction(client: ExtendedClient, guild: Guild, ch
955977 client ,
956978 guild ,
957979 channel ,
958- owner ?? null ,
980+ null ,
959981 interaction ?? null
960982 )
961983
@@ -977,18 +999,6 @@ export async function handleCloseAction(client: ExtendedClient, guild: Guild, ch
977999 if ( data . ChannelType == ChannelType . PrivateThread ) return
9781000 await ( channel as TextChannel ) . setParent ( data . OldTicketCategoryId )
9791001 }
980-
981- await database . tickets . update ( {
982- where : {
983- TicketId : ticketId
984- } ,
985- data : {
986- IsClosed : true ,
987- IsAutoDone : isAuto ?? false ,
988- ClosedAt : new Date
989- }
990- } )
991-
9921002 if ( ! actions . includes ( "no_close_message" ) ) {
9931003 actionCounter += 1
9941004 await channel . send ( {
@@ -1025,6 +1035,9 @@ export async function ticketArchiveAction(channel: TextChannel | PrivateThreadCh
10251035 const uuid = ticketId
10261036
10271037 const data = await database . tickets . findFirst ( {
1038+ include : {
1039+ TicketSetup : true
1040+ } ,
10281041 where : {
10291042 TicketId : uuid
10301043 }
@@ -1087,7 +1100,9 @@ export async function ticketArchiveAction(channel: TextChannel | PrivateThreadCh
10871100
10881101 if ( data . ChannelType == ChannelType . PrivateThread ) {
10891102
1090- await ( channel as PrivateThreadChannel ) . setArchived ( true , "Moderator Action from Ticket with Id " + uuid )
1103+ if ( ! data . TicketSetup . AutoCloseAction . includes ( "not_thread_close" ) ) {
1104+ await ( channel as ThreadChannel ) . setArchived ( true , "Moderator Action from Ticket with Id " + ticketId )
1105+ }
10911106
10921107 } else if ( data . ChannelType == ChannelType . GuildCategory ) {
10931108
0 commit comments