From 4b485adf82bff717e8fa0e38d7582fe3f27bcc50 Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:53:40 +0100 Subject: [PATCH] (v4.1) Additional autoclose/autodelete features --- config/general.json | 1 - src/actions/reopenTicket.ts | 6 ++++++ src/core/api/defaults/config.ts | 2 -- src/core/cli/quickSetup.ts | 1 - src/core/startup/migration.ts | 1 - src/data/framework/checkerLoader.ts | 1 - src/data/framework/codeLoader.ts | 7 +++++-- src/data/framework/configLoader.ts | 1 - 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config/general.json b/config/general.json index 39abe86..221ecda 100644 --- a/config/general.json +++ b/config/general.json @@ -39,7 +39,6 @@ "replyOnTicketCreation":true, "replyOnReactionRole":true, - "showPreAutocloseWarning":false, "askPriorityOnTicketCreation":false, "removeParticipantsOnClose":false, "disableAutocloseAfterReopen":true, diff --git a/src/actions/reopenTicket.ts b/src/actions/reopenTicket.ts index 511eb37..5112f66 100644 --- a/src/actions/reopenTicket.ts +++ b/src/actions/reopenTicket.ts @@ -28,6 +28,12 @@ export const registerActions = async () => { ticket.get("opendiscord:open").value = true ticket.get("opendiscord:busy").value = true + if (generalConfig.data.system.disableAutocloseAfterReopen){ + //disable autoclose after reopen + ticket.get("opendiscord:autoclose-enabled").value = false + ticket.get("opendiscord:autoclose-hours").value = 0 + } + //update stats await opendiscord.stats.get("opendiscord:global").setStat("opendiscord:tickets-reopened",1,"increase") await opendiscord.stats.get("opendiscord:user").setStat("opendiscord:tickets-reopened",user.id,1,"increase") diff --git a/src/core/api/defaults/config.ts b/src/core/api/defaults/config.ts index f828f3e..69a1850 100644 --- a/src/core/api/defaults/config.ts +++ b/src/core/api/defaults/config.ts @@ -235,8 +235,6 @@ export interface ODJsonConfig_DefaultSystem { replyOnTicketCreation:boolean, /**Reply with an ephemeral message when reaction roles are changed. */ replyOnReactionRole:boolean, - /**Show a warning message before the ticket gets autoclosed. This will happen when only 1/4th of the autoclose time remains. */ - showPreAutocloseWarning:boolean, /**Ask for the priority of this ticket on ticket creation. This will happen in a dropdown in the ticket message. */ askPriorityOnTicketCreation:boolean, /**Remove all participants (except admins) from the ticket when it's closed. */ diff --git a/src/core/cli/quickSetup.ts b/src/core/cli/quickSetup.ts index b26cc57..ef1bdf4 100644 --- a/src/core/cli/quickSetup.ts +++ b/src/core/cli/quickSetup.ts @@ -1239,7 +1239,6 @@ async function saveQuickSetupConfig(){ replyOnTicketCreation:false, replyOnReactionRole:true, - showPreAutocloseWarning:false, askPriorityOnTicketCreation:false, removeParticipantsOnClose:quickSetupStorage.removeParticipantsOnClose ?? false, disableAutocloseAfterReopen:true, diff --git a/src/core/startup/migration.ts b/src/core/startup/migration.ts index c7e3085..2bbc38a 100644 --- a/src/core/startup/migration.ts +++ b/src/core/startup/migration.ts @@ -57,7 +57,6 @@ export const migrations = [ generalConfig.data.system.showGlobalAdminsInPanelRoles = false generalConfig.data.system.alwaysShowReason = false generalConfig.data.system.pinEmoji = "📌" - generalConfig.data.system.showPreAutocloseWarning = false generalConfig.data.system.askPriorityOnTicketCreation = false generalConfig.data.system.disableAutocloseAfterReopen = true generalConfig.data.system.autodeleteRequiresClosedTicket = true diff --git a/src/data/framework/checkerLoader.ts b/src/data/framework/checkerLoader.ts index 7ca554b..c34c907 100644 --- a/src/data/framework/checkerLoader.ts +++ b/src/data/framework/checkerLoader.ts @@ -278,7 +278,6 @@ export const defaultGeneralStructure = new api.ODCheckerObjectStructure("opendis {key:"replyOnTicketCreation",checker:new api.ODCheckerBooleanStructure("opendiscord:reply-on-ticket-creation",{cliDisplayName:"Reply On Ticket Creation",cliDisplayDescription:"When enabled, the bot will send an ephemeral reply in the channel of the panel when creating a ticket."})}, {key:"replyOnReactionRole",checker:new api.ODCheckerBooleanStructure("opendiscord:reply-on-reaction-role",{cliDisplayName:"Reply On Reaction Role",cliDisplayDescription:"When enabled, the bot will send an ephemeral reply in the channel of the panel when using a role button."})}, - {key:"showPreAutocloseWarning",checker:new api.ODCheckerBooleanStructure("opendiscord:show-pre-autoclose-warning",{cliDisplayName:"Show Pre-Autoclose Warning",cliDisplayDescription:"Show a warning message before the ticket gets autoclosed. This will happen when only 1/4th of the autoclose time remains."})}, {key:"askPriorityOnTicketCreation",checker:new api.ODCheckerBooleanStructure("opendiscord:ask-priority-creation",{cliDisplayName:"Ask Priority On Ticket Creation",cliDisplayDescription:"Ask for the priority of this ticket on ticket creation. This will happen in a dropdown in the ticket message."})}, {key:"removeParticipantsOnClose",checker:new api.ODCheckerBooleanStructure("opendiscord:remove-participants-on-close",{cliDisplayName:"Remove Participants On Close",cliDisplayDescription:"When enabled, all participants except admins will be removed from the ticket."})}, {key:"disableAutocloseAfterReopen",checker:new api.ODCheckerBooleanStructure("opendiscord:disable-autoclose-reopen",{cliDisplayName:"Disable Autoclose On Reopen",cliDisplayDescription:"Disable autoclose for a ticket when it has been closed and re-opened."})}, diff --git a/src/data/framework/codeLoader.ts b/src/data/framework/codeLoader.ts index da79601..08b4cd0 100644 --- a/src/data/framework/codeLoader.ts +++ b/src/data/framework/codeLoader.ts @@ -446,7 +446,9 @@ const loadAutoCode = () => { if (lastMessage){ //ticket has last message const disableOnClaim = ticket.option.get("opendiscord:autodelete-disable-claim").value && ticket.get("opendiscord:claimed").value - const enabled = (disableOnClaim) ? false : ticket.get("opendiscord:autodelete-enabled").value + const disableWhenNotClosed = generalConfig.data.system.autodeleteRequiresClosedTicket && !ticket.get("opendiscord:closed").value + + const enabled = (disableOnClaim || disableWhenNotClosed) ? false : ticket.get("opendiscord:autodelete-enabled").value const days = ticket.get("opendiscord:autodelete-days").value const time = days*24*60*60*1000 //days in milliseconds @@ -475,7 +477,8 @@ const loadAutoCode = () => { if (!channel) return //ticket has been created by this user const disableOnClaim = ticket.option.get("opendiscord:autodelete-disable-claim").value && ticket.get("opendiscord:claimed").value - const enabled = (disableOnClaim || !ticket.get("opendiscord:autodelete-enabled").value) ? false : ticket.option.get("opendiscord:autodelete-enable-leave") + const disableWhenNotClosed = generalConfig.data.system.autodeleteRequiresClosedTicket && !ticket.get("opendiscord:closed").value + const enabled = (disableOnClaim || disableWhenNotClosed || !ticket.get("opendiscord:autodelete-enabled").value) ? false : ticket.option.get("opendiscord:autodelete-enable-leave") if (enabled){ //autodelete ticket diff --git a/src/data/framework/configLoader.ts b/src/data/framework/configLoader.ts index c39b045..98945d0 100644 --- a/src/data/framework/configLoader.ts +++ b/src/data/framework/configLoader.ts @@ -74,7 +74,6 @@ export const defaultGeneralFormatter = new fjs.ObjectFormatter(null,true,[ new fjs.TextFormatter(""), new fjs.PropertyFormatter("replyOnTicketCreation"), new fjs.PropertyFormatter("replyOnReactionRole"), - new fjs.PropertyFormatter("showPreAutocloseWarning"), new fjs.PropertyFormatter("askPriorityOnTicketCreation"), new fjs.PropertyFormatter("removeParticipantsOnClose"), new fjs.PropertyFormatter("disableAutocloseAfterReopen"),