Finished channel topic on ticket creation
This commit is contained in:
+29
-22
@@ -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
|
||||
const permissions: discord.OverwriteResolvable[] = [{
|
||||
type:discord.OverwriteType.Role,
|
||||
@@ -109,22 +103,6 @@ export const registerActions = async () => {
|
||||
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
|
||||
const participants: {type:"role"|"user",id:string}[] = []
|
||||
permissions.forEach((permission,index) => {
|
||||
@@ -134,6 +112,35 @@ export const registerActions = async () => {
|
||||
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
|
||||
const ticket = new api.ODTicket(channel.id,option,[
|
||||
new api.ODTicketData("opendiscord:busy",false),
|
||||
|
||||
@@ -143,14 +143,14 @@ export interface ODJsonConfig_DefaultSystemChannelTopic {
|
||||
showOptionDescription:boolean,
|
||||
/**Show the option topic text in the channel topic (configured in the options config). */
|
||||
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). */
|
||||
showClosed:boolean,
|
||||
/**Show the current claim status in the channel topic (auto-updated). */
|
||||
showClaimed:boolean,
|
||||
/**Show the current pin status in the channel topic (auto-updated). */
|
||||
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). */
|
||||
showCreator:boolean,
|
||||
/**Show the first 5 participants of the ticket in the channel topic (auto-updated). */
|
||||
|
||||
@@ -1272,10 +1272,10 @@ async function saveQuickSetupConfig(){
|
||||
showOptionName:true,
|
||||
showOptionDescription:false,
|
||||
showOptionTopic:true,
|
||||
showPriority:false,
|
||||
showClosed:true,
|
||||
showClaimed:false,
|
||||
showPinned:false,
|
||||
showPriority:false,
|
||||
showCreator:false,
|
||||
showParticipants:false
|
||||
},
|
||||
|
||||
@@ -70,10 +70,10 @@ export const migrations = [
|
||||
showOptionName:true,
|
||||
showOptionDescription:false,
|
||||
showOptionTopic:true,
|
||||
showPriority:false,
|
||||
showClosed:true,
|
||||
showClaimed:false,
|
||||
showPinned:false,
|
||||
showPriority:false,
|
||||
showCreator:false,
|
||||
showParticipants:false
|
||||
}
|
||||
|
||||
@@ -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:"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:"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:"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:"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:"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)."})},
|
||||
|
||||
|
||||
@@ -107,10 +107,10 @@ export const defaultGeneralFormatter = new fjs.ObjectFormatter(null,true,[
|
||||
new fjs.PropertyFormatter("showOptionName"),
|
||||
new fjs.PropertyFormatter("showOptionDescription"),
|
||||
new fjs.PropertyFormatter("showOptionTopic"),
|
||||
new fjs.PropertyFormatter("showPriority"),
|
||||
new fjs.PropertyFormatter("showClosed"),
|
||||
new fjs.PropertyFormatter("showClaimed"),
|
||||
new fjs.PropertyFormatter("showPinned"),
|
||||
new fjs.PropertyFormatter("showPriority"),
|
||||
new fjs.PropertyFormatter("showCreator"),
|
||||
new fjs.PropertyFormatter("showParticipants"),
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user