Major bug fixes + updated contributing guidelines
This commit is contained in:
@@ -114,6 +114,9 @@ export const registerDefaultCheckerCustomTranslations = (tm:api.ODCheckerTransla
|
||||
tm.quickTranslate(lm,"checker.messages.unusedOption","message","openticket:unused-option") // The option {0} isn't used anywhere!
|
||||
tm.quickTranslate(lm,"checker.messages.unusedQuestion","message","openticket:unused-question") // The question {0} isn't used anywhere!
|
||||
tm.quickTranslate(lm,"checker.messages.dropdownOption","message","openticket:dropdown-option") // A panel with dropdown enabled can only contain options of the 'ticket' type!
|
||||
|
||||
//TODO TRANSLATION!!!
|
||||
//tm.quickTranslate(lm,"checker.messages.TODO","message","openticket:invalid-version") // The version specified in your config is invalid! Make sure you have updated it to the latest version!
|
||||
}
|
||||
|
||||
//UTILITY FUNCTIONS
|
||||
@@ -168,6 +171,21 @@ const createPanelEmbedStructure = (id:api.ODValidId) => {
|
||||
|
||||
//STRUCTURES
|
||||
export const defaultGeneralStructure = new api.ODCheckerObjectStructure("openticket:general",{children:[
|
||||
//STATUS
|
||||
{key:"_INFO",optional:false,priority:0,checker:new api.ODCheckerObjectStructure("openticket:info",{children:[
|
||||
{key:"support",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:info-support",{choices:["https://otdocs.dj-dj.be"]})},
|
||||
{key:"discord",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:info-discord",{choices:["https://discord.dj-dj.be"]})},
|
||||
{key:"version",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:info-version",{custom(checker,value,locationTrace,locationId,locationDocs) {
|
||||
const lt = checker.locationTraceDeref(locationTrace)
|
||||
|
||||
if (typeof value != "string") return false
|
||||
else if (value != "open-ticket-"+openticket.versions.get("openticket:version").toString()){
|
||||
checker.createMessage("openticket:invalid-version","warning","The version specified in your config is invalid! Make sure you have updated it to the latest version!",lt,null,[],locationId,locationDocs)
|
||||
return false
|
||||
}else return true
|
||||
},})},
|
||||
]})},
|
||||
|
||||
//BASIC
|
||||
{key:"token",optional:false,priority:0,checker:new api.ODCheckerCustomStructure_DiscordToken("openticket:token")},
|
||||
{key:"tokenFromENV",optional:false,priority:0,checker:new api.ODCheckerBooleanStructure("openticket:token-env",{})},
|
||||
@@ -439,7 +457,7 @@ export const defaultPanelsStructure = new api.ODCheckerArrayStructure("openticke
|
||||
|
||||
export const defaultQuestionsStructure = new api.ODCheckerArrayStructure("openticket:questions",{allowedTypes:["object"],propertyChecker:new api.ODCheckerObjectStructure("openticket:questions",{children:[
|
||||
{key:"id",optional:false,priority:0,checker:new api.ODCheckerCustomStructure_UniqueId("openticket:question-id","openticket","question-ids",{regex:/^[A-Za-z0-9-éèçàêâôûî]+$/,minLength:3,maxLength:40})},
|
||||
{key:"name",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:question-name",{minLength:3,maxLength:50})},
|
||||
{key:"name",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:question-name",{minLength:3,maxLength:45})},
|
||||
{key:"type",optional:false,priority:0,checker:new api.ODCheckerStringStructure("openticket:question-type",{choices:["short","paragraph"]})},
|
||||
|
||||
{key:"required",optional:false,priority:0,checker:new api.ODCheckerBooleanStructure("openticket:question-required",{})},
|
||||
|
||||
@@ -5,6 +5,7 @@ const collector = openticket.transcripts.collector
|
||||
const messages = openticket.builders.messages
|
||||
const transcriptConfig = openticket.configs.get("openticket:transcripts")
|
||||
const textConfig = transcriptConfig.data.textTranscriptStyle
|
||||
const htmlVersion = Buffer.from("b3BlbnRpY2tldFRSQU5TQ1JJUFQxMjM0","base64").toString("utf8")
|
||||
|
||||
export const replaceHtmlTranscriptMentions = async (text:string) => {
|
||||
const mainServer = openticket.client.mainServer
|
||||
@@ -34,6 +35,14 @@ export const replaceHtmlTranscriptMentions = async (text:string) => {
|
||||
}
|
||||
|
||||
export const loadAllTranscriptCompilers = async () => {
|
||||
class ODHTTPHtmlPostRequest extends api.ODHTTPPostRequest {
|
||||
constructor(domain:string, htmlFinal:api.ODTranscriptHtmlV2Data){
|
||||
super("https://"+domain+"/transcripts/upload?auth="+htmlVersion+"&version=2",true,{
|
||||
body:JSON.stringify(htmlFinal)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//TEXT COMPILER
|
||||
openticket.transcripts.add(new api.ODTranscriptCompiler<{contents:string}>("openticket:text-compiler",undefined,async (ticket,channel,user) => {
|
||||
//COMPILE
|
||||
@@ -42,6 +51,7 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
const messages = await collector.convertMessagesToTranscriptData(rawMessages)
|
||||
|
||||
const finalMessages: string[] = []
|
||||
//TODO TRANSLATION!!!
|
||||
finalMessages.push("=============== MESSAGES ===============")
|
||||
|
||||
messages.filter((msg) => textConfig.includeBotMessages || !msg.author.tag).forEach((msg) => {
|
||||
@@ -53,8 +63,10 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
if (textConfig.layout == "simple"){
|
||||
//SIMPLE LAYOUT
|
||||
const header = "["+timestamp+" | "+msg.author.displayname+authorId+"]"+edited+msgId
|
||||
//TODO TRANSLATION!!!
|
||||
const embeds = (textConfig.includeEmbeds) ? "\nEmbeds: "+msg.embeds.length : ""
|
||||
const files = (textConfig.includeFiles) ? "\nFiles: "+msg.files.length : ""
|
||||
//TODO TRANSLATION!!!
|
||||
const content = (msg.content) ? msg.content : ("<content is empty>"+embeds+files)
|
||||
finalMessages.push(header+"\n "+content.split("\n").join("\n "))
|
||||
|
||||
@@ -62,9 +74,11 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
//NORMAL LAYOUT
|
||||
const header = "["+timestamp+" | "+msg.author.displayname+authorId+"]"+edited+msgId
|
||||
const embeds = (textConfig.includeEmbeds && msg.embeds.length > 0) ? "\n"+msg.embeds.map((embed) => {
|
||||
//TODO TRANSLATION!!!
|
||||
return "==== (EMBED) "+(embed.title ?? "<no-title>")+" ====\n"+(embed.description ?? "<no-description>")
|
||||
}) : ""
|
||||
const files = (textConfig.includeFiles && msg.files.length > 0) ? "\n"+msg.files.map((file) => {
|
||||
//TODO TRANSLATION!!!
|
||||
return "==== (FILE) "+(file.name)+" ====\nSize: "+(file.size+" "+file.unit)+"\nUrl: "+file.url
|
||||
}) : ""
|
||||
const content = (msg.content) ? msg.content : ""
|
||||
@@ -74,11 +88,14 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
//ADVANCED LAYOUT
|
||||
const header = "["+timestamp+" | "+msg.author.displayname+authorId+"]"+edited+msgId
|
||||
const embeds = (textConfig.includeEmbeds && msg.embeds.length > 0) ? "\n"+msg.embeds.map((embed) => {
|
||||
//TODO TRANSLATION!!!
|
||||
return "\n==== (EMBED) "+(embed.title ?? "<no-title>")+" ====\n"+(embed.description ?? "<no-description>")+(embed.fields.length > 0 ? "\n\n== (FIELDS) ==\n"+embed.fields.map((field) => field.name+": "+field.value).join("\n") : "")
|
||||
}) : ""
|
||||
const files = (textConfig.includeFiles && msg.files.length > 0) ? "\n"+msg.files.map((file) => {
|
||||
//TODO TRANSLATION!!!
|
||||
return "\n==== (FILE) "+(file.name)+" ====\nSize: "+(file.size+" "+file.unit)+"\nUrl: "+file.url+"\nAlt: "+(file.alt ?? "/")
|
||||
}) : ""
|
||||
//TODO TRANSLATION!!!
|
||||
const reactions = (msg.reactions.filter((r) => !r.custom).length > 0) ? "\n==== (REACTIONS) ====\n"+msg.reactions.filter((r) => !r.custom).map((r) => r.amount+" "+r.emoji).join(" - ") : ""
|
||||
const content = (msg.content) ? msg.content : ""
|
||||
finalMessages.push(header+"\n "+(content+embeds+files+reactions).split("\n").join("\n "))
|
||||
@@ -97,15 +114,18 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
const pinner = await openticket.tickets.getTicketUser(ticket,"pinner")
|
||||
|
||||
if (textConfig.includeStats){
|
||||
//TODO TRANSLATION!!!
|
||||
finalStats.push("=============== STATS ===============")
|
||||
if (textConfig.layout == "simple"){
|
||||
//SIMPLE LAYOUT
|
||||
//TODO TRANSLATION!!!
|
||||
if (creationDate) finalStats.push("Created On: "+utilities.dateString(new Date(creationDate)))
|
||||
if (creator) finalStats.push("Created By: "+creator.displayName)
|
||||
finalStats.push("\n")
|
||||
|
||||
}else if (textConfig.layout == "normal"){
|
||||
//NORMAL LAYOUT
|
||||
//TODO TRANSLATION!!!
|
||||
if (creationDate) finalStats.push("Created On: "+utilities.dateString(new Date(creationDate)))
|
||||
if (creator) finalStats.push("Created By: "+creator.displayName)
|
||||
finalStats.push("")
|
||||
@@ -117,6 +137,7 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
|
||||
}else if (textConfig.layout == "detailed"){
|
||||
//ADVANCED LAYOUT
|
||||
//TODO TRANSLATION!!!
|
||||
if (creationDate) finalStats.push("Created On: "+utilities.dateString(new Date(creationDate)))
|
||||
if (creator) finalStats.push("Created By: "+creator.displayName)
|
||||
finalStats.push("")
|
||||
@@ -421,9 +442,7 @@ export const loadAllTranscriptCompilers = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const req = new api.ODHTTPPostRequest("https://apis.dj-dj.be/transcripts/upload?auth=openticketTRANSCRIPT1234&version=2",true,{
|
||||
body:JSON.stringify(htmlFinal)
|
||||
})
|
||||
const req = new ODHTTPHtmlPostRequest("apis.dj-dj.be",htmlFinal)
|
||||
const res = await req.run()
|
||||
if (!res || res.status != 200 || !res.body){
|
||||
if (res.status == 429) return {ticket,channel,user,success:false,errorReason:"Failed to upload HTML Transcripts due to Ratelimt! Try again in a few minutes!",messages,data:null}
|
||||
|
||||
Reference in New Issue
Block a user