mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 09:23:07 +02:00
archives
This commit is contained in:
parent
59ffa7056d
commit
097602b993
@ -149,7 +149,11 @@ module.exports = {
|
||||
}];
|
||||
}
|
||||
|
||||
if (fs.existsSync(`user/transcripts/raw/${ticket.get('channel')}.log`))
|
||||
if (
|
||||
fs.existsSync(`user/transcripts/raw/${ticket.get('channel')}.log`)
|
||||
&&
|
||||
fs.existsSync(`user/transcripts/raw/entities/${ticket.get('channel')}.json`)
|
||||
)
|
||||
embed.addField('Web archive', `${await archive.export(Ticket, channel)}`);
|
||||
|
||||
|
||||
|
@ -128,12 +128,6 @@ module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
|
||||
else
|
||||
data.messages[index] = message;
|
||||
}, () => {
|
||||
fs.writeFileSync('user/data.json', JSON.stringify(data)); // FOR TESTING
|
||||
|
||||
/**
|
||||
* @todo post(data).then()
|
||||
* @todo if 200 OK delete raw .json and .log
|
||||
*/
|
||||
let endpoint = config.transcripts.web.server;
|
||||
if (endpoint[endpoint.length - 1] === '/')
|
||||
endpoint = endpoint.slice(0, -1);
|
||||
@ -144,13 +138,18 @@ module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(json => {
|
||||
if (json.status !== 200) {
|
||||
log.warn(json);
|
||||
return resolve(new Error(`${json.status} (${json.message})`));
|
||||
.then(res => {
|
||||
if (res.status !== 200) {
|
||||
log.warn(res);
|
||||
return resolve(new Error(`${res.status} (${res.message})`));
|
||||
}
|
||||
|
||||
log.success(`Uploaded ticket #${ticket.id} archive to server`);
|
||||
resolve(json.url);
|
||||
|
||||
fs.unlinkSync(raw);
|
||||
fs.unlinkSync(json);
|
||||
|
||||
resolve(res.url);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
{"entities":{"users":{"475371285531066368":{"avatar":"https://cdn.discordapp.com/avatars/475371285531066368/962b420d036d3f310e4a920f8517d01c.webp","username":"Roadside Assistance","discriminator":"2057","displayName":"Roadside Assistance","color":39321,"badge":"bot"},"319467558166069248":{"avatar":"https://cdn.discordapp.com/avatars/319467558166069248/c0a069ef452737cc75609430a5b6f14f.webp","username":"Eartharoid","discriminator":"2006","displayName":"Eartharoid","color":15277667,"badge":null}},"channels":{},"roles":{}},"ticket":{"id":55,"name":"ticket-55","creator":"319467558166069248","channel":"747831136801259652","topic":"<@319467558166069248> | No topic given"},"messages":[{"id":"747831139024240691","author":"475371285531066368","content":"@here,\n<@319467558166069248> has created a new ticket","time":1598367237574,"embeds":[],"attachments":[]},{"id":"747831144455602268","author":"475371285531066368","content":"","time":1598367238869,"embeds":[],"attachments":[{"attachment":"https://cdn.discordapp.com/attachments/747831136801259652/747831143986102342/how-can-we-help.gif","name":"how-can-we-help.gif","id":"747831143986102342","size":1721116,"url":"https://cdn.discordapp.com/attachments/747831136801259652/747831143986102342/how-can-we-help.gif","proxyURL":"https://media.discordapp.net/attachments/747831136801259652/747831143986102342/how-can-we-help.gif","height":278,"width":498}]},{"id":"747831145437200475","author":"475371285531066368","content":"","time":1598367239103,"embeds":[{"type":"rich","description":"Hello there, <@319467558166069248>!\n\t\tA member of staff will assist you shortly.\n\t\tIn the mean time, please describe your issue in as much detail as possible! :)","timestamp":null,"color":39321,"fields":[{"value":"`No topic given`","name":"Topic","inline":false}],"thumbnail":null,"image":null,"author":{"name":"Eartharoid","icon_url":"https://cdn.discordapp.com/avatars/319467558166069248/c0a069ef452737cc75609430a5b6f14f.webp"},"footer":{"text":"Planet Earth","icon_url":"https://cdn.discordapp.com/icons/451745464480432129/ec04e2401da3b6a1c0b75dfed2beaf15.webp"}}],"attachments":[]},{"id":"747831155121979552","author":"319467558166069248","content":"fjndsg","time":1598367241412,"embeds":[],"attachments":[]},{"id":"747831156703101131","author":"319467558166069248","content":"dsg","time":1598367241789,"embeds":[],"attachments":[]},{"id":"747831158913630238","author":"319467558166069248","content":"dfg","time":1598367242316,"embeds":[],"attachments":[]},{"id":"747831160993742928","author":"319467558166069248","content":"fdg","time":1598367242812,"embeds":[],"attachments":[]},{"id":"747831162193313913","author":"319467558166069248","content":"dfgasdfdsgdfgdf","time":1598367243098,"embeds":[],"attachments":[],"edited":true},{"id":"747831163803926580","author":"319467558166069248","content":"fdg","time":1598367243482,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831165091840054","author":"319467558166069248","content":"fdg","time":1598367243789,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831166677155852","author":"319467558166069248","content":"fdg","time":1598367244167,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831168682164365","author":"319467558166069248","content":"dfg","time":1598367244645,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831178194714734","author":"319467558166069248","content":"fdg","time":1598367246913,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831180325421107","author":"319467558166069248","content":"fdg","time":1598367247421,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831209265987744","author":"319467558166069248","content":"sdg","time":1598367254321,"embeds":[],"attachments":[],"edited":false,"deleted":true},{"id":"747831222423519342","author":"319467558166069248","content":"degfdsg","time":1598367257458,"embeds":[],"attachments":[]},{"id":"747831228748529774","author":"319467558166069248","content":"-close","time":1598367258966,"embeds":[],"attachments":[]},{"id":"747831229558161488","author":"475371285531066368","content":"","time":1598367259159,"embeds":[{"title":":grey_question: Are you sure?","type":"rich","description":"You will be able to view an archived version later with `-transcript 55`\n**React with :white_check_mark: to confirm.**","timestamp":null,"color":39321,"fields":[],"thumbnail":null,"image":null,"author":{"name":"Eartharoid","icon_url":"https://cdn.discordapp.com/avatars/319467558166069248/c0a069ef452737cc75609430a5b6f14f.webp"},"footer":{"text":"Planet Earth | Expires in 15 seconds","icon_url":"https://cdn.discordapp.com/icons/451745464480432129/ec04e2401da3b6a1c0b75dfed2beaf15.webp"}}],"attachments":[]}]}
|
Loading…
Reference in New Issue
Block a user