Minor bugfixes & improvements (priority & topic)
This commit is contained in:
@@ -29,7 +29,6 @@ export const registerActions = async () => {
|
|||||||
const claimCategory = (rawClaimCategory) ? rawClaimCategory.category : null
|
const claimCategory = (rawClaimCategory) ? rawClaimCategory.category : null
|
||||||
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
|
const closeCategory = ticket.option.get("opendiscord:channel-category-closed").value
|
||||||
const channelTopic = ticket.option.get("opendiscord:channel-topic").value
|
const channelTopic = ticket.option.get("opendiscord:channel-topic").value
|
||||||
const channelName = channelPrefix+channelSuffix
|
|
||||||
|
|
||||||
//handle category
|
//handle category
|
||||||
let category: string|null = null
|
let category: string|null = null
|
||||||
@@ -155,17 +154,18 @@ export const registerActions = async () => {
|
|||||||
ticket.get("opendiscord:participants").refreshDatabase()
|
ticket.get("opendiscord:participants").refreshDatabase()
|
||||||
|
|
||||||
//rename channel (and give error when crashed)
|
//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 originalName = channel.name
|
||||||
|
const newName = pinEmoji+priorityEmoji+utilities.trimEmojis(channelPrefix+channelSuffix)
|
||||||
try{
|
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")
|
opendiscord.log("Failed to rename channel on ticket move","error")
|
||||||
})
|
})
|
||||||
}catch(err){
|
}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
|
//update ticket message
|
||||||
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
|
const ticketMessage = await opendiscord.tickets.getTicketMessage(ticket)
|
||||||
@@ -173,7 +173,7 @@ export const registerActions = async () => {
|
|||||||
try{
|
try{
|
||||||
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
|
ticketMessage.edit((await opendiscord.builders.messages.getSafe("opendiscord:ticket-message").build("other",{guild,channel,user,ticket})).message)
|
||||||
}catch(e){
|
}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:"channel",value:"#"+channel.name},
|
||||||
{key:"channelid",value:channel.id,hidden:true},
|
{key:"channelid",value:channel.id,hidden:true},
|
||||||
{key:"messageid",value:ticketMessage.id},
|
{key:"messageid",value:ticketMessage.id},
|
||||||
|
|||||||
@@ -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!")
|
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)
|
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
|
//update ticket
|
||||||
ticket.get("opendiscord:busy").value = true
|
ticket.get("opendiscord:busy").value = true
|
||||||
@@ -37,7 +37,7 @@ export const registerActions = async () => {
|
|||||||
//reply with new message
|
//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)
|
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
|
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
|
//update channel topic
|
||||||
await opendiscord.actions.get("opendiscord:update-ticket-topic").run("ticket-action",{guild,channel,user,ticket,sendMessage:false,newTopic:null})
|
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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ export const registerActions = async () => {
|
|||||||
const closed = ticket.get("opendiscord:closed").value
|
const closed = ticket.get("opendiscord:closed").value
|
||||||
const claimedBy = ticket.get("opendiscord:claimed-by").value
|
const claimedBy = ticket.get("opendiscord:claimed-by").value
|
||||||
const pinned = ticket.get("opendiscord:pinned").value
|
const pinned = ticket.get("opendiscord:pinned").value
|
||||||
|
const creator = ticket.get("opendiscord:opened-by").value ?? opendiscord.client.client.user.id
|
||||||
|
|
||||||
//handle channel topic
|
//handle channel topic
|
||||||
const channelTopics: string[] = []
|
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.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.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.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!!!
|
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
|
//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
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user