almost done....

This commit is contained in:
Isaac (eartharoid) 2020-08-23 22:01:21 +01:00
parent 6425e3930c
commit 5c65888c95
21 changed files with 261 additions and 128 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
logs/ logs/
node_modules/ node_modules/
user/.env user/dev.env
user/dev.config.js
user/storage.db user/storage.db
user/transcripts/text/*.txt user/transcripts/text/*.txt
user/transcripts/raw/*.log user/transcripts/raw/*.log

View File

@ -7,7 +7,7 @@
*/ */
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config.js'); const config = require('../../user/' + require('../').config);
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
@ -53,7 +53,7 @@ module.exports = {
} }
} }
if(message.author.id !== ticket.get('creator') && !message.member.roles.cache.has(config.staff_role)) if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
return message.channel.send( return message.channel.send(
new MessageEmbed() new MessageEmbed()
.setColor(config.err_colour) .setColor(config.err_colour)
@ -106,7 +106,7 @@ module.exports = {
.setColor(config.colour) .setColor(config.colour)
.setAuthor(member.user.username, member.user.displayAvatarURL()) .setAuthor(member.user.username, member.user.displayAvatarURL())
.setTitle(':white_check_mark: **Member added**') .setTitle(':white_check_mark: **Member added**')
.setDescription(`${member} has been added to <#${ticket.get('channel')}>`) .setDescription(`${member} has been added to <#${ticket.channel}>`)
.setFooter(guild.name, guild.iconURL()) .setFooter(guild.name, guild.iconURL())
); );

View File

@ -9,7 +9,7 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
const fs = require('fs'); const fs = require('fs');
const archive = require('../modules/archive'); const archive = require('../modules/archive');
@ -59,10 +59,10 @@ module.exports = {
notTicket notTicket
.setTitle(':x: **Channel is not a ticket**') .setTitle(':x: **Channel is not a ticket**')
.setDescription(`${channel} is not a ticket channel.`); .setDescription(`${channel} is not a ticket channel.`);
return channel.send(notTicket); return message.channel.send(notTicket);
} }
if (message.author.id !== ticket.get('creator') && !message.member.roles.cache.has(config.staff_role)) if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
return channel.send( return channel.send(
new MessageEmbed() new MessageEmbed()
.setColor(config.err_colour) .setColor(config.err_colour)
@ -78,7 +78,7 @@ module.exports = {
let success; let success;
let pre = fs.existsSync(`user/transcripts/text/${channel.id}.txt`) || let pre = fs.existsSync(`user/transcripts/text/${channel.id}.txt`) ||
fs.existsSync(`user/transcripts/raw/${channel.id}.log`) ? fs.existsSync(`user/transcripts/raw/${channel.id}.log`) ?
`You will be able to view an archived version later with \`${config.prefix}transcript ${ticket.get('id')}\`` : `You will be able to view an archived version later with \`${config.prefix}transcript ${ticket.id}\`` :
''; '';
let confirm = await message.channel.send( let confirm = await message.channel.send(
@ -118,23 +118,8 @@ module.exports = {
.setFooter(guild.name, guild.iconURL()) .setFooter(guild.name, guild.iconURL())
); );
success = true;
ticket.update({
open: false
}, {
where: {
channel: channel.id
}
});
setTimeout(() => {
channel.delete();
if (channel.id !== message.channel.id)
message.delete()
.then(() => confirm.delete());
}, 15000);
if (config.transcripts.text.enabled || config.transcripts.web.enabled) { if (config.transcripts.text.enabled || config.transcripts.web.enabled) {
let u = await client.users.fetch(ticket.get('creator')); let u = await client.users.fetch(ticket.creator);
if (u) { if (u) {
let dm; let dm;
@ -145,51 +130,55 @@ module.exports = {
} }
await dm.send( let res = {};
new MessageEmbed() const embed = new MessageEmbed()
.setColor(config.colour) .setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL()) .setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(`**Ticket ${ticket.id} closed**`) .setTitle(`Ticket ${ticket.id}`)
.setDescription('Your ticket has been closed.') .setFooter(guild.name, guild.iconURL());
.setFooter(guild.name, guild.iconURL())
);
if (config.transcripts.text.enabled && fs.existsSync(`user/transcripts/text/${channel.id}.txt`)) {
try {
await dm.send('A basic text transcript of the ticket channel is attached:', {
files: [
`user/transcripts/text/${channel.id}.txt`
]
});
} catch (e) {
log.warn(`Failed to send text transcript to ${u.tag}`);
}
if (fs.existsSync(`user/transcripts/text/${ticket.get('channel')}.txt`)) {
embed.addField('Text transcript', 'See attachment');
res.files = [
{
attachment: `user/transcripts/text/${ticket.get('channel')}.txt`,
name: `ticket-${ticket.id}-${ticket.get('channel')}.txt`
}
];
} }
if (config.transcripts.web.enabled) { if (fs.existsSync(`user/transcripts/raw/${ticket.get('channel')}.log`))
try { embed.addField('Web archive', `${await archive.export(Ticket, channel)}`);
let url = await archive.export(client, channel);
await dm.send( if (embed.fields.length < 1)
new MessageEmbed() embed.setDescription(`No text transcripts or archive data exists for ticket ${ticket.id}`);
.setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(`**Ticket ${ticket.id} web archive**`)
.setDescription(`You can view an archive of your ticket channel [here](${url})`)
.setFooter(guild.name, guild.iconURL())
);
} catch (e) {
log.warn(`Failed to send archive URL to ${u.tag}`);
log.warn(e);
}
} res.embed = embed;
dm.send(res).then();
} }
} }
log.info(`${message.author.tag} closed a ticket (#ticket-${ticket.get('id')})`); // update database
success = true;
ticket.update({
open: false
}, {
where: {
channel: channel.id
}
});
// delete messages and channel
setTimeout(() => {
channel.delete();
if (channel.id !== message.channel.id)
message.delete()
.then(() => confirm.delete());
}, 5000);
log.info(`${message.author.tag} closed a ticket (#ticket-${ticket.id})`);
if (config.logs.discord.enabled) if (config.logs.discord.enabled)
client.channels.cache.get(config.logs.discord.channel).send( client.channels.cache.get(config.logs.discord.channel).send(
@ -197,7 +186,7 @@ module.exports = {
.setColor(config.colour) .setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL()) .setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle('Ticket closed') .setTitle('Ticket closed')
.addField('Creator', `<@${ticket.get('creator')}>`, true) .addField('Creator', `<@${ticket.creator}>`, true)
.addField('Closed by', message.author, true) .addField('Closed by', message.author, true)
.setFooter(guild.name, guild.iconURL()) .setFooter(guild.name, guild.iconURL())
.setTimestamp() .setTimestamp()

View File

@ -9,7 +9,7 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'help', name: 'help',

View File

@ -10,7 +10,7 @@ const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const fs = require('fs'); const fs = require('fs');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'new', name: 'new',

View File

@ -9,7 +9,7 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'panel', name: 'panel',

View File

@ -7,7 +7,7 @@
*/ */
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config.js'); const config = require('../../user/' + require('../').config);
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
@ -53,7 +53,7 @@ module.exports = {
} }
} }
if(message.author.id !== ticket.get('creator') && !message.member.roles.cache.has(config.staff_role)) if(message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
return message.channel.send( return message.channel.send(
new MessageEmbed() new MessageEmbed()
.setColor(config.err_colour) .setColor(config.err_colour)
@ -106,7 +106,7 @@ module.exports = {
.setColor(config.colour) .setColor(config.colour)
.setAuthor(member.user.username, member.user.displayAvatarURL()) .setAuthor(member.user.username, member.user.displayAvatarURL())
.setTitle(':white_check_mark: **Member removed**') .setTitle(':white_check_mark: **Member removed**')
.setDescription(`${member} has been removed from <#${ticket.get('channel')}>`) .setDescription(`${member} has been removed from <#${ticket.channel}>`)
.setFooter(guild.name, guild.iconURL()) .setFooter(guild.name, guild.iconURL())
); );

View File

@ -9,7 +9,7 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'stats', name: 'stats',

View File

@ -8,7 +8,7 @@
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const fs = require('fs'); const fs = require('fs');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'tickets', name: 'tickets',
@ -93,23 +93,26 @@ module.exports = {
let transcript = ''; let transcript = '';
let c = closedTickets.rows[t].channel; let c = closedTickets.rows[t].channel;
if(fs.existsSync(`user/transcripts/text/${c}.txt`) || fs.existsSync(`user/transcripts/raw/${c}.log`)) if(fs.existsSync(`user/transcripts/text/${c}.txt`) || fs.existsSync(`user/transcripts/raw/${c}.log`))
transcript = `\n> Type \`${config.prefix}transcript ${closedTickets.rows[t].id}\` to download text transcript.`; transcript = `\n> Type \`${config.prefix}transcript ${closedTickets.rows[t].id}\` to view.`;
closed.push(`> #${closedTickets.rows[t].id}: \`${desc}${desc.length > 20 ? '...' : ''}\`${transcript}`); closed.push(`> **#${closedTickets.rows[t].id}**: \`${desc}${desc.length > 20 ? '...' : ''}\`${transcript}`);
} }
let pre = context === 'self' ? 'You have' : user.username + ' has'; let pre = context === 'self' ? 'You have' : user.username + ' has';
embed.addField('Open tickets', openTickets.count === 0 ? `${pre} no open tickets.` : open.join('\n\n'), false); embed.addField('Open tickets', openTickets.count === 0 ? `${pre} no open tickets.` : open.join('\n\n'), false);
embed.addField('Closed tickets', closedTickets.count === 0 ? `${pre} no old tickets` : closed.join('\n\n'), false); embed.addField('Closed tickets', closedTickets.count === 0 ? `${pre} no old tickets` : closed.join('\n\n'), false);
let m = await message.channel.send(embed); message.delete({timeout: 15000});
return setTimeout(async () => {
await message.delete();
await m.delete();
}, 60000);
let channel;
try {
channel = message.author.dmChannel || await message.author.createDM();
message.channel.send('Sent to DM').then(msg => msg.delete({timeout: 15000}));
} catch (e) {
channel = message.channel;
}
let m = await channel.send(embed);
m.delete({timeout: 60000});
}, },
}; };

View File

@ -6,10 +6,8 @@
* *
*/ */
const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'topic', name: 'topic',
@ -17,8 +15,59 @@ module.exports = {
usage: '<topic>', usage: '<topic>',
aliases: ['edit'], aliases: ['edit'],
example: 'topic need help error', example: 'topic need help error',
args: false, args: true,
async execute(client, message, args, Ticket) { async execute(client, message, args, Ticket) {
const guild = client.guilds.cache.get(config.guild);
let ticket = await Ticket.findOne({
where: {
channel: message.channel.id
}
});
if (!ticket)
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(':x: **This isn\'t a ticket channel**')
.setDescription('Use this command in the ticket channel you want to close, or mention the channel.')
.addField('Usage', `\`${config.prefix}${this.name} ${this.usage}\`\n`)
.addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`)
.setFooter(guild.name, guild.iconURL())
);
let topic = args.join(' ');
if (topic.length > 256)
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(':x: **Description too long**')
.setDescription('Please limit your ticket topic to less than 256 characters. A short sentence will do.')
.setFooter(guild.name, guild.iconURL())
);
message.channel.setTopic(`<@${ticket.creator}> | ` + topic);
Ticket.update({
topic: topic
}, {
where: {
channel: message.channel.id
}
});
message.channel.send(
new MessageEmbed()
.setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(':white_check_mark: **Ticket updated**')
.setDescription('The topic has been changed.')
.setFooter(client.user.username, client.user.avatarURL())
);
} }
}; };

View File

@ -6,10 +6,11 @@
* *
*/ */
const ChildLogger = require('leekslazylogger').ChildLogger; const fs = require('fs');
const log = new ChildLogger(); const {
const { MessageEmbed } = require('discord.js'); MessageEmbed
const config = require('../../user/config'); } = require('discord.js');
const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
name: 'transcript', name: 'transcript',
@ -17,11 +18,77 @@ module.exports = {
usage: '<ticket-id>', usage: '<ticket-id>',
aliases: ['archive', 'download'], aliases: ['archive', 'download'],
example: 'transcript 57', example: 'transcript 57',
args: false, args: true,
async execute(client, message, args, Ticket) { async execute(client, message, args, Ticket) {
/**
* @TODO TRY TO SEND ATTACHMENT TO DM const guild = client.guilds.cache.get(config.guild);
* @TODO ONLY ALLOW CREATOR AND STAFF TO RUN CMD const id = args[0];
*/
let ticket = await Ticket.findOne({
where: {
id: id,
open: false
}
});
if (!ticket)
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(':x: **Unknown ticket**')
.setDescription('Couldn\'t find a closed ticket with that ID')
.setFooter(guild.name, guild.iconURL())
);
if (message.author.id !== ticket.creator && !message.member.roles.cache.has(config.staff_role))
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(':x: **No permission**')
.setDescription(`You don't have permission to view ticket ${id} as it does not belong to you and you are not staff.`)
.setFooter(guild.name, guild.iconURL())
);
let res = {};
const embed = new MessageEmbed()
.setColor(config.colour)
.setAuthor(message.author.username, message.author.displayAvatarURL())
.setTitle(`Ticket ${id}`)
.setFooter(guild.name + ' | This message will be deleted in 15 seconds', guild.iconURL());
if (fs.existsSync(`user/transcripts/text/${ticket.channel}.txt`)) {
embed.addField('Text transcript', 'See attachment');
res.files = [
{
attachment: `user/transcripts/text/${ticket.channel}.txt`,
name: `ticket-${id}-${ticket.channel}.txt`
}
];
}
const BASE_URL = config.transcripts.web.server;
if (fs.existsSync(`user/transcripts/raw/${ticket.channel}.log`))
embed.addField('Web archive', `${BASE_URL}/${ticket.creator}/${ticket.channel}`);
if (embed.fields.length < 1)
embed.setDescription(`No text transcripts or archive data exists for ticket ${id}`);
res.embed = embed;
let channel;
try {
channel = message.author.dmChannel || await message.author.createDM();
} catch (e) {
channel = message.channel;
}
channel.send(res).then(m => {
if (channel.id === message.channel.id)
m.delete({timeout: 15000});
});
message.delete({timeout: 1500});
} }
}; };

View File

@ -9,7 +9,7 @@
const { Collection, MessageEmbed } = require('discord.js'); const { Collection, MessageEmbed } = require('discord.js');
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
const archive = require('../modules/archive'); const archive = require('../modules/archive');
module.exports = { module.exports = {
@ -32,7 +32,7 @@ Type \`${config.prefix}new\` on the server to create a new ticket.`);
let ticket = await Ticket.findOne({ where: { channel: message.channel.id } }); let ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
if(ticket) if(ticket)
archive.add(client, message); // add message to archive archive.add(message); // add message to archive
if (message.author.bot || message.author.id === client.user.id) return; // goodbye bots if (message.author.bot || message.author.id === client.user.id) return; // goodbye bots

View File

@ -6,12 +6,10 @@
* *
*/ */
const Discord = require('discord.js');
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
const fs = require('fs'); const fs = require('fs');
const dtf = require('@eartharoid/dtf');
module.exports = { module.exports = {
event: 'messageDelete', event: 'messageDelete',
@ -23,7 +21,8 @@ module.exports = {
try { try {
await message.fetch(); await message.fetch();
} catch (err) { } catch (err) {
log.error(err); log.warn('Failed to fetch deleted messaged');
log.error(err.message);
return; return;
} }

View File

@ -9,7 +9,7 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const { MessageEmbed } = require('discord.js'); const { MessageEmbed } = require('discord.js');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
const fs = require('fs'); const fs = require('fs');
module.exports = { module.exports = {
@ -104,7 +104,7 @@ module.exports = {
topic: topic topic: topic
}); });
let name = 'ticket-' + ticket.get('id'); let name = 'ticket-' + ticket.id;
channel.guild.channels.create(name, { channel.guild.channels.create(name, {
type: 'text', type: 'text',

View File

@ -9,7 +9,7 @@
const Discord = require('discord.js'); const Discord = require('discord.js');
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
const fs = require('fs'); const fs = require('fs');
const dtf = require('@eartharoid/dtf'); const dtf = require('@eartharoid/dtf');

View File

@ -8,11 +8,11 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports = { module.exports = {
event: 'ready', event: 'ready',
execute(client, [e], {Ticket, Setting}) { execute(client) {
log.success(`Authenticated as ${client.user.tag}`); log.success(`Authenticated as ${client.user.tag}`);

View File

@ -5,11 +5,17 @@
* @license GNU-GPLv3 * @license GNU-GPLv3
* *
*/ */
require('dotenv').config({path: 'user/.env'});
const Discord = require('discord.js');
const fs = require('fs'); const fs = require('fs');
const leeks = require('leeks.js'); const path = require('path');
let dev = fs.existsSync('user/dev.env') && fs.existsSync('user/dev.config.js');
require('dotenv').config({path: path.join('user/', dev ? 'dev.env' : '.env')});
module.exports.config = dev ? 'dev.config.js' : 'config.js';
const config = require(path.join('../user/', module.exports.config));
const Discord = require('discord.js');
const client = new Discord.Client({ const client = new Discord.Client({
autoReconnect: true, autoReconnect: true,
partials: ['MESSAGE', 'CHANNEL', 'REACTION'], partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
@ -18,9 +24,10 @@ client.events = new Discord.Collection();
client.commands = new Discord.Collection(); client.commands = new Discord.Collection();
client.cooldowns = new Discord.Collection(); client.cooldowns = new Discord.Collection();
const utils = require('./modules/utils'); const utils = require('./modules/utils');
const leeks = require('leeks.js');
require('./modules/banner')(leeks); // big coloured text thing require('./modules/banner')(leeks); // big coloured text thing
const config = require('../user/config');
const Logger = require('leekslazylogger'); const Logger = require('leekslazylogger');
const log = new Logger({ const log = new Logger({
name: config.name, name: config.name,
@ -28,6 +35,7 @@ const log = new Logger({
maxAge: config.logs.files.keep_for, maxAge: config.logs.files.keep_for,
debug: config.debug debug: config.debug
}); });
log.multi(log); // required to allow other files to access the logger log.multi(log); // required to allow other files to access the logger
require('./modules/updater')(); // check for updates require('./modules/updater')(); // check for updates

View File

@ -11,9 +11,9 @@ const log = new ChildLogger();
const lineReader = require('line-reader'); const lineReader = require('line-reader');
const fs = require('fs'); const fs = require('fs');
const dtf = require('@eartharoid/dtf'); const dtf = require('@eartharoid/dtf');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
module.exports.add = (client, message) => { module.exports.add = (message) => {
if(message.type !== 'DEFAULT') return; if(message.type !== 'DEFAULT') return;
@ -92,7 +92,13 @@ module.exports.add = (client, message) => {
} }
}; };
module.exports.export = (client, channel) => new Promise((resolve, reject) => { module.exports.export = (Ticket, channel) => new Promise((resolve, reject) => {
let ticket = (async () => await Ticket.findOne({
where: {
channel: channel.id
}
}))();
let raw = `user/transcripts/raw/${channel.id}.log`, let raw = `user/transcripts/raw/${channel.id}.log`,
json = `user/transcripts/raw/entities/${channel.id}.json`; json = `user/transcripts/raw/entities/${channel.id}.json`;
@ -102,6 +108,14 @@ module.exports.export = (client, channel) => new Promise((resolve, reject) => {
let data = JSON.parse(fs.readFileSync(json)); let data = JSON.parse(fs.readFileSync(json));
data.ticket = {
id: ticket.id,
name: channel.name,
creator: ticket.creator,
channel: channel.id,
topic: channel.topic
};
data.messages = []; data.messages = [];
lineReader.eachLine(raw, line => { lineReader.eachLine(raw, line => {
@ -115,8 +129,12 @@ module.exports.export = (client, channel) => new Promise((resolve, reject) => {
data.messages[index] = message; data.messages[index] = message;
}, () => { }, () => {
// fs.writeFileSync('user/data.json', JSON.stringify(data)); // FOR TESTING // fs.writeFileSync('user/data.json', JSON.stringify(data)); // FOR TESTING
// post(data).then()
// delete raw .json and .log /**
* @todo post(data).then()
* @todo if 200 OK delete raw .json and .log
*/
resolve(config.transcripts.web.server); // json.url resolve(config.transcripts.web.server); // json.url
}); });
}); });

View File

@ -8,9 +8,8 @@
const ChildLogger = require('leekslazylogger').ChildLogger; const ChildLogger = require('leekslazylogger').ChildLogger;
const log = new ChildLogger(); const log = new ChildLogger();
const leeks = require('leeks.js');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const config = require('../../user/config'); const config = require('../../user/' + require('../').config);
let {version} = require('../../package.json'); let {version} = require('../../package.json');
version = 'v' + version; version = 'v' + version;
const boxen = require('boxen'); const boxen = require('boxen');

View File

@ -29,24 +29,24 @@
module.exports = { module.exports = {
prefix: '-', prefix: '-',
name: 'DiscordTickets', name: 'DiscordTickets',
activities: ['-new', 'with tickets', 'for new tickets'], /** @INFO " | {PRE}help" */ activities: ['-new', 'with tickets', 'for new tickets'],
activity_types: ['PLAYING', 'PLAYING', 'WATCHING'], /** @INFO paired */ activity_types: ['PLAYING', 'PLAYING', 'WATCHING'],
colour: '#009999', colour: '#009999',
err_colour: '#E74C3C', err_colour: '#E74C3C',
cooldown: 3, cooldown: 3,
guild: '451745464480432129', // ID of your guild guild: '', // ID of your guild
staff_role: '451745586564169728', // ID of your Support Team role staff_role: '', // ID of your Support Team role
tickets: { tickets: {
category: '620272351988285480', // ID of your tickets category category: '', // ID of your tickets category
send_img: true, send_img: true,
ping: 'here', /** @INFO here, everyone, staff, false */ ping: 'here',
text: `Hello there, {{ tag }}! text: `Hello there, {{ tag }}!
A member of staff will assist you shortly. A member of staff will assist you shortly.
In the mean time, please describe your issue in as much detail as possible! :)`, // {{ name }} and {{ tag }} In the mean time, please describe your issue in as much detail as possible! :)`,
pin: false, pin: false,
max: 3 /** @INFO OPEN */ max: 3
}, },
transcripts: { transcripts: {
@ -55,8 +55,8 @@ module.exports = {
keep_for: 90, keep_for: 90,
}, },
web: { web: {
enabled: true, enabled: false,
server: 'https://tickets.example.com', // WITHOUT! trailing / server: 'https://tickets.example.com',
} }
}, },
@ -76,11 +76,11 @@ module.exports = {
keep_for: 7 keep_for: 7
}, },
discord: { discord: {
enabled: true, enabled: false,
channel: '573957980152791080' // ID of your log channel channel: '' // ID of your log channel
} }
}, },
debug: false, debug: false,
updater: false /** @INFO ENABLE BY DEFAULT */ updater: true
}; };