API: allowCategoryChange param in related actions

Added the 'allowCategoryChange' parameter in related ticket actions (claim, unclaim, close, reopen) to disable the changing of the category. This can be used by plugins not wanting the category of the channel to change.
This commit is contained in:
DJj123dj
2025-03-27 16:30:37 +01:00
parent f316ae83e7
commit fd3bc0e7b9
5 changed files with 126 additions and 118 deletions
+15 -13
View File
@@ -28,19 +28,21 @@ export const registerActions = async () => {
await opendiscord.stats.get("opendiscord:user").setStat("opendiscord:tickets-closed",user.id,1,"increase")
//update category
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
if (closeCategory !== ""){
try {
channel.setParent(closeCategory,{lockPermissions:false})
ticket.get("opendiscord:category-mode").value = "closed"
ticket.get("opendiscord:category").value = closeCategory
}catch(e){
opendiscord.log("Unable to move ticket to 'closed category'!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"categoryid",value:closeCategory}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
if (params.allowCategoryChange){
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
if (closeCategory !== ""){
try {
channel.setParent(closeCategory,{lockPermissions:false})
ticket.get("opendiscord:category-mode").value = "closed"
ticket.get("opendiscord:category").value = closeCategory
}catch(e){
opendiscord.log("Unable to move ticket to 'closed category'!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"categoryid",value:closeCategory}
])
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
}