Finished channel topic on ticket creation

This commit is contained in:
DJj123dj
2025-10-27 11:41:56 +01:00
parent 2aef855902
commit 30b6ab4df6
7 changed files with 36 additions and 29 deletions
+1 -1
View File
@@ -72,10 +72,10 @@
"showOptionName":true, "showOptionName":true,
"showOptionDescription":false, "showOptionDescription":false,
"showOptionTopic":true, "showOptionTopic":true,
"showPriority":false,
"showClosed":true, "showClosed":true,
"showClaimed":false, "showClaimed":false,
"showPinned":false, "showPinned":false,
"showPriority":false,
"showCreator":false, "showCreator":false,
"showParticipants":false "showParticipants":false
}, },
+29 -22
View File
@@ -58,12 +58,6 @@ export const registerActions = async () => {
} }
} }
//handle channel topic
const channelTopics: string[] = []
if (generalConfig.data.system.channelTopic.showOptionTopic) channelTopics.push(channelTopicText)
if (generalConfig.data.system.channelTopic.showCreator) channelTopics.push(discord.userMention(user.id))
//if (generalConfig.data.system.channelTopic.showClaimed) TODO TODO TODO
//handle permissions //handle permissions
const permissions: discord.OverwriteResolvable[] = [{ const permissions: discord.OverwriteResolvable[] = [{
type:discord.OverwriteType.Role, type:discord.OverwriteType.Role,
@@ -109,22 +103,6 @@ export const registerActions = async () => {
deny:[] deny:[]
}) })
const slowMode = option.get("opendiscord:slowmode-enabled").value ? option.get("opendiscord:slowmode-seconds").value : undefined
//create channel
const channel = await guild.channels.create({
type:discord.ChannelType.GuildText,
name:channelName,
nsfw:false,
topic:(channelTopics.length > 0) ? channelTopics.join(" | ") : undefined,
parent:category,
reason:"Ticket Created By "+user.displayName,
permissionOverwrites:permissions,
rateLimitPerUser:slowMode
})
await opendiscord.events.get("afterTicketChannelCreated").emit([option,channel,user])
//create participants //create participants
const participants: {type:"role"|"user",id:string}[] = [] const participants: {type:"role"|"user",id:string}[] = []
permissions.forEach((permission,index) => { permissions.forEach((permission,index) => {
@@ -134,6 +112,35 @@ export const registerActions = async () => {
participants.push({type,id}) participants.push({type,id})
}) })
//manage slowmode
const slowMode = option.get("opendiscord:slowmode-enabled").value ? option.get("opendiscord:slowmode-seconds").value : undefined
//handle channel topic
const channelTopics: string[] = []
if (generalConfig.data.system.channelTopic.showOptionName) channelTopics.push(option.get("opendiscord:name").value)
if (generalConfig.data.system.channelTopic.showOptionDescription) channelTopics.push(option.get("opendiscord:description").value)
if (generalConfig.data.system.channelTopic.showOptionTopic) channelTopics.push(channelTopicText)
if (generalConfig.data.system.channelTopic.showPriority) channelTopics.push("**Priority:** "+opendiscord.priorities.get("opendiscord:none").renderDisplayName()) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showClosed) channelTopics.push("**Status:** Opened") //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showClaimed) channelTopics.push("**Claimed By:** No-one") //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showPinned) channelTopics.push("**Pinned:** No") //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showCreator) channelTopics.push("**Creator:** "+discord.userMention(user.id)) //TODO TRANSLATION!!!
if (generalConfig.data.system.channelTopic.showParticipants) channelTopics.push("**Participants:** "+participants.map((p) => (p.type == "user") ? discord.userMention(p.id) : discord.roleMention(p.id)).join(", ")) //TODO TRANSLATION!!!
//create channel
const channel = await guild.channels.create({
type:discord.ChannelType.GuildText,
name:channelName,
nsfw:false,
topic:(channelTopics.length > 0) ? channelTopics.join(" • ") : undefined,
parent:category,
reason:"Ticket Created By "+user.displayName,
permissionOverwrites:permissions,
rateLimitPerUser:slowMode
})
await opendiscord.events.get("afterTicketChannelCreated").emit([option,channel,user])
//create ticket //create ticket
const ticket = new api.ODTicket(channel.id,option,[ const ticket = new api.ODTicket(channel.id,option,[
new api.ODTicketData("opendiscord:busy",false), new api.ODTicketData("opendiscord:busy",false),
+2 -2
View File
@@ -143,14 +143,14 @@ export interface ODJsonConfig_DefaultSystemChannelTopic {
showOptionDescription:boolean, showOptionDescription:boolean,
/**Show the option topic text in the channel topic (configured in the options config). */ /**Show the option topic text in the channel topic (configured in the options config). */
showOptionTopic:boolean, showOptionTopic:boolean,
/**Show the current priority in the channel topic (auto-updated). */
showPriority:boolean,
/**Show the current close/reopen status in the channel topic (auto-updated). */ /**Show the current close/reopen status in the channel topic (auto-updated). */
showClosed:boolean, showClosed:boolean,
/**Show the current claim status in the channel topic (auto-updated). */ /**Show the current claim status in the channel topic (auto-updated). */
showClaimed:boolean, showClaimed:boolean,
/**Show the current pin status in the channel topic (auto-updated). */ /**Show the current pin status in the channel topic (auto-updated). */
showPinned:boolean, showPinned:boolean,
/**Show the current priority in the channel topic (auto-updated). */
showPriority:boolean,
/**Show the creator of the ticket in the channel topic (auto-updated on transfer). */ /**Show the creator of the ticket in the channel topic (auto-updated on transfer). */
showCreator:boolean, showCreator:boolean,
/**Show the first 5 participants of the ticket in the channel topic (auto-updated). */ /**Show the first 5 participants of the ticket in the channel topic (auto-updated). */
+1 -1
View File
@@ -1272,10 +1272,10 @@ async function saveQuickSetupConfig(){
showOptionName:true, showOptionName:true,
showOptionDescription:false, showOptionDescription:false,
showOptionTopic:true, showOptionTopic:true,
showPriority:false,
showClosed:true, showClosed:true,
showClaimed:false, showClaimed:false,
showPinned:false, showPinned:false,
showPriority:false,
showCreator:false, showCreator:false,
showParticipants:false showParticipants:false
}, },
+1 -1
View File
@@ -70,10 +70,10 @@ export const migrations = [
showOptionName:true, showOptionName:true,
showOptionDescription:false, showOptionDescription:false,
showOptionTopic:true, showOptionTopic:true,
showPriority:false,
showClosed:true, showClosed:true,
showClaimed:false, showClaimed:false,
showPinned:false, showPinned:false,
showPriority:false,
showCreator:false, showCreator:false,
showParticipants:false showParticipants:false
} }
+1 -1
View File
@@ -311,10 +311,10 @@ export const defaultGeneralStructure = new api.ODCheckerObjectStructure("opendis
{key:"showOptionName",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-name",{cliDisplayName:"Show Option Name",cliDisplayDescription:"Show the option name in the channel topic."})}, {key:"showOptionName",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-name",{cliDisplayName:"Show Option Name",cliDisplayDescription:"Show the option name in the channel topic."})},
{key:"showOptionDescription",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-description",{cliDisplayName:"Show Option Description",cliDisplayDescription:"Show the option description in the channel topic."})}, {key:"showOptionDescription",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-description",{cliDisplayName:"Show Option Description",cliDisplayDescription:"Show the option description in the channel topic."})},
{key:"showOptionTopic",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-topic",{cliDisplayName:"Show Option Topic",cliDisplayDescription:"Show the option topic text in the channel topic (configured in the options.json config)."})}, {key:"showOptionTopic",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-option-topic",{cliDisplayName:"Show Option Topic",cliDisplayDescription:"Show the option topic text in the channel topic (configured in the options.json config)."})},
{key:"showPriority",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-priority",{cliDisplayName:"Show Priority",cliDisplayDescription:"Show the current priority in the channel topic (auto-updated)."})},
{key:"showClosed",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-closed",{cliDisplayName:"Show Closed Status",cliDisplayDescription:"Show the current close/reopen status in the channel topic (auto-updated)."})}, {key:"showClosed",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-closed",{cliDisplayName:"Show Closed Status",cliDisplayDescription:"Show the current close/reopen status in the channel topic (auto-updated)."})},
{key:"showClaimed",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-claimed",{cliDisplayName:"Show Claimed Status",cliDisplayDescription:"Show the current claim status in the channel topic (auto-updated)."})}, {key:"showClaimed",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-claimed",{cliDisplayName:"Show Claimed Status",cliDisplayDescription:"Show the current claim status in the channel topic (auto-updated)."})},
{key:"showPinned",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-pinned",{cliDisplayName:"Show Pinned Status",cliDisplayDescription:"Show the current pin status in the channel topic (auto-updated)."})}, {key:"showPinned",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-pinned",{cliDisplayName:"Show Pinned Status",cliDisplayDescription:"Show the current pin status in the channel topic (auto-updated)."})},
{key:"showPriority",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-priority",{cliDisplayName:"Show Priority",cliDisplayDescription:"Show the current priority in the channel topic (auto-updated)."})},
{key:"showCreator",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-creator",{cliDisplayName:"Show Creator",cliDisplayDescription:"Show the creator of the ticket in the channel topic (auto-updated on transfer)."})}, {key:"showCreator",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-creator",{cliDisplayName:"Show Creator",cliDisplayDescription:"Show the creator of the ticket in the channel topic (auto-updated on transfer)."})},
{key:"showParticipants",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-participants",{cliDisplayName:"Show Participants",cliDisplayDescription:"Show the first 5 participants of the ticket in the channel topic (auto-updated)."})}, {key:"showParticipants",checker:new api.ODCheckerBooleanStructure("opendiscord:topic-show-participants",{cliDisplayName:"Show Participants",cliDisplayDescription:"Show the first 5 participants of the ticket in the channel topic (auto-updated)."})},
+1 -1
View File
@@ -107,10 +107,10 @@ export const defaultGeneralFormatter = new fjs.ObjectFormatter(null,true,[
new fjs.PropertyFormatter("showOptionName"), new fjs.PropertyFormatter("showOptionName"),
new fjs.PropertyFormatter("showOptionDescription"), new fjs.PropertyFormatter("showOptionDescription"),
new fjs.PropertyFormatter("showOptionTopic"), new fjs.PropertyFormatter("showOptionTopic"),
new fjs.PropertyFormatter("showPriority"),
new fjs.PropertyFormatter("showClosed"), new fjs.PropertyFormatter("showClosed"),
new fjs.PropertyFormatter("showClaimed"), new fjs.PropertyFormatter("showClaimed"),
new fjs.PropertyFormatter("showPinned"), new fjs.PropertyFormatter("showPinned"),
new fjs.PropertyFormatter("showPriority"),
new fjs.PropertyFormatter("showCreator"), new fjs.PropertyFormatter("showCreator"),
new fjs.PropertyFormatter("showParticipants"), new fjs.PropertyFormatter("showParticipants"),
]), ]),