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
+2
View File
@@ -26,6 +26,7 @@ export const registerActions = async () => {
await opendiscord.stats.get("opendiscord:user").setStat("opendiscord:tickets-claimed",user.id,1,"increase")
//update category
if (params.allowCategoryChange){
const rawClaimCategory = ticket.option.get("opendiscord:channel-categories-claimed").value.find((c) => c.user == user.id)
const claimCategory = (rawClaimCategory) ? rawClaimCategory.category : null
if (claimCategory){
@@ -42,6 +43,7 @@ export const registerActions = async () => {
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
}
//update ticket message
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
+2
View File
@@ -28,6 +28,7 @@ export const registerActions = async () => {
await opendiscord.stats.get("opendiscord:user").setStat("opendiscord:tickets-closed",user.id,1,"increase")
//update category
if (params.allowCategoryChange){
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
if (closeCategory !== ""){
try {
@@ -43,6 +44,7 @@ export const registerActions = async () => {
opendiscord.debugfile.writeErrorMessage(new api.ODError(e,"uncaughtException"))
}
}
}
//update permissions (non-staff => readonly)
const permissions: discord.OverwriteResolvable[] = [{
+2
View File
@@ -28,6 +28,7 @@ export const registerActions = async () => {
await opendiscord.stats.get("opendiscord:user").setStat("opendiscord:tickets-reopened",user.id,1,"increase")
//update category
if (params.allowCategoryChange){
const channelCategory = ticket.option.get("opendiscord:channel-category").value
const channelBackupCategory = ticket.option.get("opendiscord:channel-category-backup").value
if (channelCategory !== ""){
@@ -76,6 +77,7 @@ export const registerActions = async () => {
ticket.get("opendiscord:category-mode").value = null
ticket.get("opendiscord:category").value = null
}
}
//update permissions
const permissions: discord.OverwriteResolvable[] = [{
+2
View File
@@ -22,6 +22,7 @@ export const registerActions = async () => {
ticket.get("opendiscord:busy").value = true
//update category
if (params.allowCategoryChange){
const channelCategory = ticket.option.get("opendiscord:channel-category").value
const channelBackupCategory = ticket.option.get("opendiscord:channel-category-backup").value
if (channelCategory !== ""){
@@ -71,6 +72,7 @@ export const registerActions = async () => {
ticket.get("opendiscord:category-mode").value = null
ticket.get("opendiscord:category").value = null
}
}
//update ticket message
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
+4 -4
View File
@@ -36,7 +36,7 @@ export interface ODActionManagerIds_Default {
},
"opendiscord:close-ticket":{
source:"slash"|"text"|"ticket-message"|"reopen-message"|"autoclose"|"other",
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean},
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean,allowCategoryChange?:boolean},
result:{},
workers:"opendiscord:close-ticket"|"opendiscord:discord-logs"|"opendiscord:logs"
},
@@ -48,19 +48,19 @@ export interface ODActionManagerIds_Default {
},
"opendiscord:reopen-ticket":{
source:"slash"|"text"|"ticket-message"|"close-message"|"autoclose-message"|"other",
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean},
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean,allowCategoryChange?:boolean},
result:{},
workers:"opendiscord:reopen-ticket"|"opendiscord:discord-logs"|"opendiscord:logs"
},
"opendiscord:claim-ticket":{
source:"slash"|"text"|"ticket-message"|"unclaim-message"|"other",
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean},
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean,allowCategoryChange?:boolean},
result:{},
workers:"opendiscord:claim-ticket"|"opendiscord:discord-logs"|"opendiscord:logs"
},
"opendiscord:unclaim-ticket":{
source:"slash"|"text"|"ticket-message"|"claim-message"|"other",
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean},
params:{guild:discord.Guild,channel:discord.GuildTextBasedChannel,user:discord.User,ticket:ODTicket,reason:string|null,sendMessage:boolean,allowCategoryChange?:boolean},
result:{},
workers:"opendiscord:unclaim-ticket"|"opendiscord:discord-logs"|"opendiscord:logs"
},