Minor bugfixes & improvements (priority & topic)

This commit is contained in:
DJj123dj
2025-11-02 20:08:57 +01:00
parent 34ed4edede
commit 68a8170570
3 changed files with 19 additions and 10 deletions
+7 -7
View File
@@ -29,7 +29,6 @@ export const registerActions = async () => {
const claimCategory = (rawClaimCategory) ? rawClaimCategory.category : null
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
const channelTopic = ticket.option.get("opendiscord:channel-topic").value
const channelName = channelPrefix+channelSuffix
//handle category
let category: string|null = null
@@ -155,17 +154,18 @@ export const registerActions = async () => {
ticket.get("opendiscord:participants").refreshDatabase()
//rename channel (and give error when crashed)
const pinEmoji = ticket.get("opendiscord:pinned").value ? generalConfig.data.system.pinEmoji : ""
const priorityEmoji = opendiscord.priorities.getFromPriorityLevel(ticket.get("opendiscord:priority").value).channelEmoji ?? ""
const originalName = channel.name
const newName = pinEmoji+priorityEmoji+utilities.trimEmojis(channelPrefix+channelSuffix)
try{
await utilities.timedAwait(channel.setName(channelName),2500,(err) => {
await utilities.timedAwait(channel.setName(newName),2500,(err) => {
opendiscord.log("Failed to rename channel on ticket move","error")
})
}catch(err){
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-move",{guild,channel,user,originalName,newName:channelName})).message)
await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:error-channel-rename").build("ticket-move",{guild,channel,user,originalName,newName:newName})).message)
}
try{
if (channel.type == discord.ChannelType.GuildText) channel.setTopic(channelTopic)
}catch{}
//update ticket message
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
@@ -173,7 +173,7 @@ export const registerActions = async () => {
try{
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
}catch(e){
opendiscord.log("Unable to edit ticket message on ticket renaming!","error",[
opendiscord.log("Unable to edit ticket message on ticket moving!","error",[
{key:"channel",value:"#"+channel.name},
{key:"channelid",value:channel.id,hidden:true},
{key:"messageid",value:ticketMessage.id},
+6 -2
View File
@@ -14,7 +14,7 @@ export const registerActions = async () => {
if (channel.isThread() || !(channel instanceof discord.TextChannel)) throw new api.ODSystemError("Unable to set priority of ticket! Open Ticket doesn't support threads!")
const oldPriority = opendiscord.priorities.getFromPriorityLevel(ticket.get("opendiscord:priority").value)
await opendiscord.events.get("onTicketPriorityChange").emit([ticket,user,channel,oldPriority,newPriority])
await opendiscord.events.get("onTicketPriorityChange").emit([ticket,user,channel,oldPriority,newPriority,reason])
//update ticket
ticket.get("opendiscord:busy").value = true
@@ -37,7 +37,7 @@ export const registerActions = async () => {
//reply with new message
if (params.sendMessage) await channel.send((await opendiscord.builders.messages.getSafe("opendiscord:priority-set").build(source,{guild,channel,user,ticket,priority:newPriority,reason})).message)
ticket.get("opendiscord:busy").value = false
await opendiscord.events.get("afterTicketPriorityChanged").emit([ticket,user,channel,oldPriority,newPriority])
await opendiscord.events.get("afterTicketPriorityChanged").emit([ticket,user,channel,oldPriority,newPriority,reason])
//update channel topic
await opendiscord.actions.get("opendiscord:update-ticket-topic").run("ticket-action",{guild,channel,user,ticket,sendMessage:false,newTopic:null})
@@ -58,4 +58,8 @@ export const registerActions = async () => {
])
})
])
opendiscord.actions.get("opendiscord:update-ticket-priority").workers.backupWorker = new api.ODWorker("opendiscord:cancel-busy",0,(instance,params) => {
//set busy to false in case of crash or cancel
params.ticket.get("opendiscord:busy").value = false
})
}
+6 -1
View File
@@ -24,6 +24,7 @@ export const registerActions = async () => {
const closed = ticket.get("opendiscord:closed").value
const claimedBy = ticket.get("opendiscord:claimed-by").value
const pinned = ticket.get("opendiscord:pinned").value
const creator = ticket.get("opendiscord:opened-by").value ?? opendiscord.client.client.user.id
//handle channel topic
const channelTopics: string[] = []
@@ -34,7 +35,7 @@ export const registerActions = async () => {
if (generalConfig.data.system.channelTopic.showClosed) channelTopics.push("**Status:** "+(closed ? "Closed" : "Opened")) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showClaimed) channelTopics.push("**Claimed By:** "+(claimedBy ? discord.userMention(claimedBy) : "No-one")) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showPinned) channelTopics.push("**Pinned:** "+(pinned ? "Yes" : "No")) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showCreator) channelTopics.push("**Creator:** "+discord.userMention(user.id)) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showCreator) channelTopics.push("**Creator:** "+discord.userMention(creator)) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showParticipants) channelTopics.push("**Participants:** "+ticket.get("opendiscord:participants").value.map((p) => (p.type == "user") ? discord.userMention(p.id) : discord.roleMention(p.id)).join(", ")) //TODO TRANSLATION!!!
//update channel
@@ -61,4 +62,8 @@ export const registerActions = async () => {
])
})
])
opendiscord.actions.get("opendiscord:update-ticket-topic").workers.backupWorker = new api.ODWorker("opendiscord:cancel-busy",0,(instance,params) => {
//set busy to false in case of crash or cancel
params.ticket.get("opendiscord:busy").value = false
})
}