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