languages/config improvements & bug fixes
This commit is contained in:
@@ -135,9 +135,9 @@ export const loadDatabaseCleanersCode = async () => {
|
||||
//OPTION DATABASE CLEANER
|
||||
openticket.code.add(new api.ODCode("openticket:option-database-cleaner",10,() => {
|
||||
//delete all unused options
|
||||
openticket.options.getAll().forEach((option) => {
|
||||
if (optionDatabase.exists("openticket:used-option",option.id.value) && !openticket.tickets.getAll().some((ticket) => ticket.option.id.value == option.id.value)){
|
||||
optionDatabase.delete("openticket:used-option",option.id.value)
|
||||
openticket.options.forEach((option,id) => {
|
||||
if (optionDatabase.exists("openticket:used-option",id.value) && !openticket.tickets.getAll().some((ticket) => ticket.id.value == id.value)){
|
||||
optionDatabase.delete("openticket:used-option",id.value)
|
||||
}
|
||||
})
|
||||
}))
|
||||
@@ -331,9 +331,9 @@ export const loadDatabaseSaversCode = async () => {
|
||||
}
|
||||
|
||||
//delete all unused options on ticket move
|
||||
openticket.options.getAll().forEach((option) => {
|
||||
if (optionDatabase.exists("openticket:used-option",option.id.value) && !openticket.tickets.getAll().some((ticket) => ticket.option.id.value == option.id.value)){
|
||||
optionDatabase.delete("openticket:used-option",option.id.value)
|
||||
openticket.options.forEach((option,id) => {
|
||||
if (optionDatabase.exists("openticket:used-option",id.value) && !openticket.tickets.getAll().some((ticket) => ticket.id.value == id.value)){
|
||||
optionDatabase.delete("openticket:used-option",id.value)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {openticket, api, utilities} from "../../index"
|
||||
|
||||
export const loadAllCooldowns = async () => {
|
||||
openticket.options.getAll().forEach((option) => {
|
||||
openticket.options.forEach((option) => {
|
||||
if (!(option instanceof api.ODTicketOption)) return
|
||||
loadTicketOptionCooldown(option)
|
||||
})
|
||||
|
||||
@@ -2,8 +2,8 @@ import {openticket, api, utilities} from "../../index"
|
||||
|
||||
export const loadAllFlags = async () => {
|
||||
openticket.flags.add(new api.ODFlag("openticket:no-migration","No Migration","Disable Open Ticket data migration on update!","--no-migration",["-nm"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:dev-config","Developer Config","Use the configs in /devconfig instead of /config!","--dev-config",["-dc"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:dev-database","Developer Database","Use the databases in /devdatabase instead of /database!","--dev-database",["-nd"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:dev-config","Developer Config","Use the configs in /devconfig/ instead of /config/!","--dev-config",["-dc"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:dev-database","Developer Database","Use the databases in /devdatabase/ instead of /database/!","--dev-database",["-nd"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:debug","Debug Mode","Couldn't you find the error? Try to check this out!","--debug",["-d"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:crash","Crash On Error","Crash the bot on an unknown error!","--crash",["-cr"]))
|
||||
openticket.flags.add(new api.ODFlag("openticket:no-transcripts","No HTML Transcripts","Disable uploading HTML transcripts (for debugging)","--no-transcripts",["-nt"]))
|
||||
|
||||
@@ -30,7 +30,7 @@ export const loadAllPermissions = async () => {
|
||||
})
|
||||
|
||||
//TICKET ADMINS
|
||||
openticket.tickets.getAll().forEach(async (ticket) => {
|
||||
openticket.tickets.forEach(async (ticket) => {
|
||||
try {
|
||||
const channel = await openticket.client.fetchGuildTextChannel(mainServer,ticket.id.value)
|
||||
if (!channel) return
|
||||
|
||||
@@ -15,6 +15,42 @@ export const loadAllOptions = async () => {
|
||||
openticket.options.add(loadRoleOption(option))
|
||||
}
|
||||
})
|
||||
|
||||
//update options on config reload
|
||||
optionConfig.onReload(async () => {
|
||||
//clear previous options
|
||||
openticket.options.forEach((data,id) => {openticket.options.remove(id)})
|
||||
|
||||
//add new options
|
||||
optionConfig.data.forEach((option) => {
|
||||
if (option.type == "ticket"){
|
||||
const loadedOption = loadTicketOption(option)
|
||||
openticket.options.add(loadedOption)
|
||||
openticket.options.suffix.add(loadTicketOptionSuffix(loadedOption))
|
||||
}else if (option.type == "website"){
|
||||
openticket.options.add(loadWebsiteOption(option))
|
||||
}else if (option.type == "role"){
|
||||
openticket.options.add(loadRoleOption(option))
|
||||
}
|
||||
})
|
||||
|
||||
//update options in tickets
|
||||
openticket.tickets.forEach((ticket) => {
|
||||
const optionId = ticket.option.id
|
||||
const option = openticket.options.get(optionId)
|
||||
if (option && option instanceof api.ODTicketOption) ticket.option = option
|
||||
else{
|
||||
openticket.log("Unable to move ticket to unexisting option due to config reload!","warning",[
|
||||
{key:"channelid",value:ticket.id.value},
|
||||
{key:"option",value:optionId.value}
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
//update roles on config reload
|
||||
openticket.roles.forEach((data,id) => {openticket.roles.remove(id)})
|
||||
await (await import("./roleLoader.js")).loadAllRoles()
|
||||
})
|
||||
}
|
||||
|
||||
export const loadTicketOption = (option:api.ODJsonConfig_DefaultOptionTicketType): api.ODTicketOption => {
|
||||
|
||||
@@ -8,6 +8,17 @@ export const loadAllPanels = async () => {
|
||||
panelConfig.data.forEach((panel) => {
|
||||
openticket.panels.add(loadPanel(panel))
|
||||
})
|
||||
|
||||
//update panels on config reload
|
||||
panelConfig.onReload(async () => {
|
||||
//clear previous panels
|
||||
openticket.panels.forEach((data,id) => {openticket.panels.remove(id)})
|
||||
|
||||
//add new panels
|
||||
panelConfig.data.forEach((panel) => {
|
||||
openticket.panels.add(loadPanel(panel))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loadPanel = (panel:api.ODJsonConfig_DefaultPanelType) => {
|
||||
|
||||
@@ -11,6 +11,21 @@ export const loadAllQuestions = async () => {
|
||||
openticket.questions.add(loadParagraphQuestion(question))
|
||||
}
|
||||
})
|
||||
|
||||
//update questions on config reload
|
||||
questionConfig.onReload(() => {
|
||||
//clear previous questions
|
||||
openticket.questions.forEach((data,id) => {openticket.questions.remove(id)})
|
||||
|
||||
//add new questions
|
||||
questionConfig.data.forEach((question) => {
|
||||
if (question.type == "short"){
|
||||
openticket.questions.add(loadShortQuestion(question))
|
||||
}else if (question.type == "paragraph"){
|
||||
openticket.questions.add(loadParagraphQuestion(question))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loadShortQuestion = (option:api.ODJsonConfig_DefaultShortQuestionType) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {openticket, api, utilities} from "../../index"
|
||||
|
||||
export const loadAllRoles = async () => {
|
||||
openticket.options.getAll().forEach((opt) => {
|
||||
openticket.options.forEach((opt) => {
|
||||
if (opt instanceof api.ODRoleOption){
|
||||
openticket.roles.add(loadRole(opt))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user