v3.2 last push
This commit is contained in:
@@ -21,6 +21,7 @@ const version = require("../info.json").version
|
||||
*/
|
||||
exports.compile = (guild,channel,user,messagesInv,data) => {
|
||||
const messages = messagesInv.reverse()
|
||||
var invisibleMessages = 0
|
||||
|
||||
const rawfiles = messages.filter((m) => Array.from(m.attachments).length > 0)
|
||||
var fileAmount = 0
|
||||
@@ -30,8 +31,6 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
|
||||
|
||||
const messagesArray = []
|
||||
messages.forEach((msg) => {
|
||||
|
||||
console.log("'"+msg.content+"'",msg.embeds.length,msg.attachments.toJSON().length)
|
||||
if (msg.content || msg.embeds.length > 0 || msg.attachments.toJSON().length > 0){
|
||||
|
||||
const embedArray = []
|
||||
@@ -78,7 +77,7 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
|
||||
embeds:embedArray,
|
||||
files:fileArray
|
||||
})
|
||||
}
|
||||
}else {invisibleMessages++}
|
||||
})
|
||||
|
||||
const result = {
|
||||
@@ -109,7 +108,7 @@ exports.compile = (guild,channel,user,messagesInv,data) => {
|
||||
closedtime:data.ticket.closedtime,
|
||||
openedtime:data.ticket.openedtime,
|
||||
|
||||
messages:Array.from(messages).length,
|
||||
messages:Array.from(messages).length-invisibleMessages,
|
||||
files:fileAmount
|
||||
},
|
||||
messages:messagesArray
|
||||
|
||||
@@ -10,19 +10,20 @@ const tsdb = require("../tsdb")
|
||||
|
||||
/**
|
||||
* @param {Object} json
|
||||
* @returns {OTuploadResponse}
|
||||
* @returns {Promise<OTuploadResponse|false>}
|
||||
*/
|
||||
exports.upload = async (json) => {
|
||||
return new Promise(async (resolve,reject) => {
|
||||
const data = encodeURIComponent(JSON.stringify(json))
|
||||
|
||||
const data = encodeURIComponent(JSON.stringify(json))
|
||||
try {
|
||||
const res = await axios.get("https://api.transcripts.dj-dj.be/upload?auth=openticketTRANSCRIPT1234&version=1.0.0&data="+data)
|
||||
if (res.status != 200) resolve(false)
|
||||
|
||||
try {
|
||||
const res = await axios.get("https://api.transcripts.dj-dj.be/upload?auth=openticketTRANSCRIPT1234&version=1.0.0&data="+data)
|
||||
if (res.status != 200) return false
|
||||
|
||||
return res.data
|
||||
}catch{
|
||||
console.log("failed transcript upload!")
|
||||
return false
|
||||
}
|
||||
resolve(res.data)
|
||||
}catch{
|
||||
console.log("failed transcript upload!")
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -57,15 +57,18 @@ exports.tsready = (name,id,url,user) => {
|
||||
* @param {String} name
|
||||
* @param {String} id
|
||||
* @param {discord.User} user
|
||||
* @param {undefined|String} err
|
||||
*/
|
||||
exports.tserror = (name,id,user) => {
|
||||
exports.tserror = (name,id,user,err) => {
|
||||
const embed = new discord.EmbedBuilder()
|
||||
.setTitle("❌ Transcript")
|
||||
.setColor(discord.Colors.Red)
|
||||
.setAuthor({name:user.tag,iconURL:user.displayAvatarURL()})
|
||||
.setFooter({text:name})
|
||||
|
||||
.setDescription("Something went wrong while creating the HTML transcript.\n\n[possible reasons](https://docs.openticket.dj-dj.be/the-system/transcripts/transcript-errors)")
|
||||
const errDesc = (typeof err == "string") ? "\n"+err : ""
|
||||
|
||||
embed.setDescription("Something went wrong while creating the HTML transcript.\n\n[possible reasons](https://docs.openticket.dj-dj.be/the-system/transcripts/transcript-errors)"+errDesc)
|
||||
|
||||
return embed
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = async (messages,guild,channel,user,reason) => {
|
||||
})
|
||||
|
||||
if (!await checkAvailability()){
|
||||
const attachment = await require("./oldTranscript").createTranscript(messages,ch)
|
||||
const attachment = await require("./oldTranscript").createTranscript(messages,channel)
|
||||
const errembed = tsembeds.tserror(chName,chId,user)
|
||||
|
||||
if (tsconfig.sendTranscripts.enableChannel){
|
||||
@@ -85,6 +85,7 @@ module.exports = async (messages,guild,channel,user,reason) => {
|
||||
|
||||
const TSdata = await require("./communication/index").upload(JSONDATA)
|
||||
if (!TSdata) return false
|
||||
|
||||
if (TSdata.status == "success"){
|
||||
const url = "https://transcripts.dj-dj.be/t/"+TSdata.time+"_"+TSdata.id+".html"
|
||||
|
||||
@@ -121,6 +122,17 @@ module.exports = async (messages,guild,channel,user,reason) => {
|
||||
}catch{}
|
||||
}
|
||||
},duration)
|
||||
}else{
|
||||
const attachment = await require("./oldTranscript").createTranscript(messages,channel)
|
||||
const errembed = tsembeds.tserror(chName,chId,user,"`error type: transcript API error`")
|
||||
|
||||
if (tsconfig.sendTranscripts.enableChannel){
|
||||
/**@type {discord.TextChannel|undefined} */
|
||||
const tc = guild.channels.cache.find((c) => c.id == tsconfig.sendTranscripts.channel)
|
||||
|
||||
if (!tc) return
|
||||
tc.send({embeds:[errembed],files:[attachment]})
|
||||
}
|
||||
}
|
||||
}
|
||||
asyncmanager(msglist)
|
||||
|
||||
Reference in New Issue
Block a user