v3.2 push 1 NOT WORKING YET!!!

This commit is contained in:
DJj123dj
2023-01-17 17:34:51 +01:00
parent fc50a8e83f
commit 7ed2d7bcc7
25 changed files with 687 additions and 184 deletions
@@ -0,0 +1,115 @@
const discord = require('discord.js')
const bot = require("../../../index")
const tsconfig = bot.tsconfig
const tsembeds = require("../embeds")
const tsdb = require("../tsdb")
const otversion = require("../../../package.json").version
const version = require("../info.json").version
/**@typedef {{style:{enableCustomBackground:Boolean, backgroundModus:"color"|"image", backgroundData:String, titleColor:String}, bot:{name:String, id:Number, pfp:String}, ticket:{creatorname:String, creatorid:Number, closedtime:Number, openedtime:Number}}} OThtsDataOption */
/**
*
* @param {discord.Guild} guild
* @param {discord.Channel} channel
* @param {discord.User} user
* @param {discord.Message[]} messagesInv
* @param {OThtsDataOption} data
*/
exports.compile = (guild,channel,user,messagesInv,data) => {
const messages = messagesInv.reverse()
const rawfiles = messages.filter((m) => Array.from(m.attachments).length > 0)
var fileAmount = 0
rawfiles.forEach((msg) => {
fileAmount = fileAmount + Array.from(msg.attachments).length
})
const messagesArray = []
messages.forEach((msg) => {
const embedArray = []
const fileArray = []
msg.attachments.forEach((file) => {
fileArray.push({
name:file.name,
type:file.contentType,
size:file.size.toString()+" bytes",
url:file.url
})
})
msg.embeds.forEach((embed) => {
if (embed.description){
var desc = bot.hiddenData.removeHiddenData(embed.description).description
}else{var desc = false}
embedArray.push({
title:embed.title || false,
description:desc,
authorimg:((embed.author && embed.author.iconURL) ? embed.author.iconURL : false),
authortext:(embed.author ? embed.author.name : false),
footerimg:((embed.footer && embed.footer.iconURL) ? embed.footer.iconURL : false),
footertext:(embed.footer ? embed.footer.text : false),
color:embed.hexColor,
image:((embed.image && embed.image.url) ? embed.image.url : false),
thumbnail:((embed.thumbnail && embed.thumbnail.url) ? embed.thumbnail.url : false),
url:(embed.url ? embed.url : false)
})
})
messagesArray.push({
author:{
name:msg.author.tag,
id:Number(msg.author.id),
color:msg.author.hexAccentColor || "#ffffff",
pfp:msg.author.displayAvatarURL()
},
content:msg.content || "",
timestamp:msg.createdTimestamp,
embeds:embedArray,
files:fileArray
})
})
const result = {
version,otversion,
style:{
backgroundData:data.style.backgroundData || "",
backgroundModus:data.style.backgroundModus || "",
enableCustomBackground:data.style.enableCustomBackground || false,
titleColor:data.style.titleColor || "#F8BA00"
},
bot:{
name:data.bot.name || "Open Ticket",
id:Number(data.bot.id) || 0,
pfp:data.bot.pfp || "dj-dj.be/wp-content/uploads/2022/07/profielfoto-blauw-wit.png?size=128"
},
ticket:{
name:channel.name,
id:Number(channel.id),
guildname:guild.name,
guildid:Number(guild.id),
creatorname:data.ticket.creatorname,
creatorid:Number(data.ticket.creatorid),
closedbyname:user.tag,
closedbyid:Number(user.id),
closedtime:data.ticket.closedtime,
openedtime:data.ticket.openedtime,
messages:Array.from(messages).length,
files:fileAmount
},
messages:messagesArray
}
return result
}
@@ -0,0 +1,28 @@
const axios = require("axios").default
const discord = require('discord.js')
const bot = require("../../../index")
const tsconfig = bot.tsconfig
const tsembeds = require("../embeds")
const tsdb = require("../tsdb")
/**@typedef {{status:"success"|"error", id:String, time:Number, estimated:{lastdump: Number, processtime:Number}, transcriptstatus:{value:2, data:{fetchedmsgs:true, uploaded:true, inqueue:true, processed:false, waiting:false, available:false}}}} OTuploadResponse */
/**
* @param {Object} json
* @returns {OTuploadResponse}
*/
exports.upload = async (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) return false
return res.data
}catch{
console.log("failed transcript upload!")
return false
}
}
@@ -0,0 +1,67 @@
{
"version":"1.0.0",
"otversion":"3.2.0",
"style":{
"enableCustomBackground":false,
"backgroundModus":"color OR image",
"backgroundData":"#ffffff OR https://www.example.com/image.png",
"titleColor":"#ffffff"
},
"bot":{
"name":"DJdj Support Bot",
"id":12345678910,
"pfp":"https://www.example.com/image.png"
},
"ticket":{
"name":"support-DJj123dj",
"id":12345678910,
"guildname":"DJdj Development",
"guildid":12345678910,
"creatorname":"DJj123dj#1706",
"creatorid":12345678910,
"closedbyname":"DJj123dj#1706",
"closedbyid":12345678910,
"closedtime":12345678910,
"openedtime":12345678910,
"messages":1,
"files":1
},
"messages":[
{
"author":{
"name":"DJj123dj#1706",
"id":12345678910,
"color":"#ffffff",
"pfp":"https://www.example.com/image.png"
},
"content":"string or FALSE",
"timestamp":12345678910,
"embeds":[
{
"title":"string or FALSE",
"description":"string or FALSE",
"authorimg":"https://www.example.com/image.png or FALSE",
"authortext":"string or FALSE",
"footerimg":"https://www.example.com/image.png or FALSE",
"footertext":"string or FALSE",
"color":"#ffffff",
"image":"https://www.example.com/image.png or FALSE",
"thumbnail":"https://www.example.com/image.png or FALSE",
"url":"https://www.example.com/image.png or FALSE"
}
],
"files":[
{
"name":"image.png",
"type":"PNG",
"size":"1MB",
"url":"https://www.example.com/image.png"
}
]
}
]
}