This commit is contained in:
David Ralph
2020-10-03 15:08:10 +01:00
parent 5ef7dc3fc4
commit b0ad6b7c88
32 changed files with 194 additions and 176 deletions

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const { MessageEmbed } = require('discord.js');
@@ -34,17 +34,15 @@ module.exports = {
let channel = message.mentions.channels.first();
if(!channel) {
if (!channel) {
channel = message.channel;
ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
if(!ticket)
if(!ticket)
return message.channel.send(notTicket);
} else {
ticket = await Ticket.findOne({ where: { channel: channel.id } });
if(!ticket) {
if (!ticket) {
notTicket
.setTitle(':x: **Channel is not a ticket**')
.setDescription(`${channel} is not a ticket channel.`);
@@ -63,12 +61,10 @@ module.exports = {
.addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`)
.setFooter(guild.name, guild.iconURL())
);
let member = guild.member(message.mentions.users.first() || guild.members.cache.get(args[0]));
if(!member)
if (!member)
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
@@ -88,7 +84,7 @@ module.exports = {
READ_MESSAGE_HISTORY: true
});
if(channel.id !== message.channel.id)
if (channel.id !== message.channel.id)
channel.send(
new MessageEmbed()
.setColor(config.colour)
@@ -99,7 +95,6 @@ module.exports = {
);
message.channel.send(
new MessageEmbed()
.setColor(config.colour)
@@ -108,7 +103,7 @@ module.exports = {
.setDescription(`${member} has been added to <#${ticket.channel}>`)
.setFooter(guild.name, guild.iconURL())
);
log.info(`${message.author.tag} added a user to a ticket (#${message.channel.id})`);
} catch (error) {
log.error(error);

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const ChildLogger = require('leekslazylogger').ChildLogger;
@@ -153,10 +153,9 @@ module.exports = {
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));
if (embed.fields.length < 1)
embed.setDescription(`No text transcripts or archive data exists for ticket ${ticket.id}`);

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const ChildLogger = require('leekslazylogger').ChildLogger;
@@ -124,13 +124,13 @@ module.exports = {
raw = `user/transcripts/raw/${ticket.get('channel')}.log`,
json = `user/transcripts/raw/entities/${ticket.get('channel')}.json`;
if (fs.existsSync(txt))
if (fs.existsSync(txt))
fs.unlinkSync(txt);
if (fs.existsSync(raw))
if (fs.existsSync(raw))
fs.unlinkSync(raw);
if (fs.existsSync(json))
if (fs.existsSync(json))
fs.unlinkSync(json);
// update database

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const ChildLogger = require('leekslazylogger').ChildLogger;
@@ -20,7 +20,7 @@ module.exports = {
execute(client, message, args, {config}) {
const guild = client.guilds.cache.get(config.guild);
const commands = Array.from(client.commands.values());
if (!args.length) {
@@ -29,7 +29,7 @@ module.exports = {
for (let command of commands) {
if (command.hide)
continue;
if (command.permission && !message.member.hasPermission(command.permission))
if (command.permission && !message.member.hasPermission(command.permission))
continue;
let desc = command.description;
@@ -38,7 +38,7 @@ module.exports = {
desc = desc.substring(0, 50) + '...';
cmds.push(`**${config.prefix}${command.name}** **·** ${desc}`);
}
message.channel.send(
new MessageEmbed()
.setTitle('Commands')
@@ -58,13 +58,13 @@ module.exports = {
const name = args[0].toLowerCase();
const command = client.commands.get(name) || client.commands.find(c => c.aliases && c.aliases.includes(name));
if (!command)
if (!command)
return message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
.setDescription(`:x: **Invalid command name** (\`${config.prefix}help\`)`)
);
const cmd = new MessageEmbed()
.setColor(config.colour)
@@ -88,7 +88,7 @@ module.exports = {
} else {
cmd.addField('Required Permission', `\`${command.permission || 'none'}\``, true);
}
message.channel.send(cmd);
}

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const ChildLogger = require('leekslazylogger').ChildLogger;
@@ -19,9 +19,9 @@ module.exports = {
example: 'new my server won\'t start',
args: false,
async execute(client, message, args, {config, Ticket}) {
const guild = client.guilds.cache.get(config.guild);
const supportRole = guild.roles.cache.get(config.staff_role);
if (!supportRole)
return message.channel.send(
@@ -47,8 +47,8 @@ module.exports = {
let desc = tickets.rows[t].topic.substring(0, 30);
ticketList
.push(`<#${tickets.rows[t].channel}>: \`${desc}${desc.length > 30 ? '...' : ''}\``);
}
}
let m = await message.channel.send(
new MessageEmbed()
.setColor(config.err_colour)
@@ -63,7 +63,7 @@ module.exports = {
await m.delete();
}, 15000);
}
let topic = args.join(' ');
if (topic.length > 256)
@@ -100,7 +100,7 @@ module.exports = {
{
id: client.user,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY']
},
},
{
id: message.member,
allow: ['VIEW_CHANNEL', 'SEND_MESSAGES', 'ATTACH_FILES', 'READ_MESSAGE_HISTORY']
@@ -134,7 +134,7 @@ module.exports = {
await message.delete();
await m.delete();
}, 15000);
// require('../modules/archive').create(client, c); // create files
let ping;

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const ChildLogger = require('leekslazylogger').ChildLogger;
@@ -26,13 +26,13 @@ module.exports = {
let chanID = await Setting.findOne({ where: { key: 'panel_chan_id' } });
let panel;
if(!chanID)
if (!chanID)
chanID = await Setting.create({
key: 'panel_chan_id',
value: message.channel.id,
});
if(!msgID) {
if (!msgID) {
msgID = await Setting.create({
key: 'panel_msg_id',
value: '',
@@ -45,7 +45,7 @@ module.exports = {
} catch (e) {
log.warn('Couldn\'t delete old panel');
}
}
message.delete();

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const { MessageEmbed } = require('discord.js');
@@ -34,15 +34,15 @@ module.exports = {
let channel = message.mentions.channels.first();
if(!channel) {
if (!channel) {
channel = message.channel;
ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
if(!ticket)
if (!ticket)
return message.channel.send(notTicket);
} else {
ticket = await Ticket.findOne({ where: { channel: channel.id } });
if(!ticket) {
notTicket
@@ -52,7 +52,7 @@ module.exports = {
}
}
if(message.author.id !== ticket.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(
new MessageEmbed()
.setColor(config.err_colour)
@@ -63,11 +63,11 @@ module.exports = {
.addField('Help', `Type \`${config.prefix}help ${this.name}\` for more information`)
.setFooter(guild.name, guild.iconURL())
);
let member = guild.member(message.mentions.users.first() || guild.members.cache.get(args[0]));
if(!member || member.id === message.author.id || member.id === guild.me.id)
return message.channel.send(
new MessageEmbed()
@@ -99,7 +99,7 @@ module.exports = {
);
message.channel.send(
new MessageEmbed()
.setColor(config.colour)
@@ -108,7 +108,7 @@ module.exports = {
.setDescription(`${member} has been removed from <#${ticket.channel}>`)
.setFooter(guild.name, guild.iconURL())
);
log.info(`${message.author.tag} removed a user from a ticket (#${message.channel.id})`);
} catch (error) {
log.error(error);

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const { MessageEmbed } = require('discord.js');

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const { MessageEmbed } = require('discord.js');
@@ -19,7 +19,7 @@ module.exports = {
async execute(client, message, args, {config, Ticket}) {
const guild = client.guilds.cache.get(config.guild);
const supportRole = guild.roles.cache.get(config.staff_role);
if (!supportRole)
return message.channel.send(
@@ -32,7 +32,7 @@ module.exports = {
let context = 'self';
let user = message.mentions.users.first() || guild.members.cache.get(args[0]);
if(user) {
if(!message.member.roles.cache.has(config.staff_role))
return message.channel.send(
@@ -76,17 +76,15 @@ module.exports = {
if(config.transcripts.web.enabled)
embed.setDescription(`You can access all of your ticket archives on the [web portal](${config.transcripts.web.server}/${user.id}).`);
let open = [],
closed = [];
for (let t in openTickets.rows) {
let desc = openTickets.rows[t].topic.substring(0, 30);
open.push(`> <#${openTickets.rows[t].channel}>: \`${desc}${desc.length > 20 ? '...' : ''}\``);
}
for (let t in closedTickets.rows) {
let desc = closedTickets.rows[t].topic.substring(0, 30);
let transcript = '';
@@ -95,12 +93,12 @@ module.exports = {
transcript = `\n> Type \`${config.prefix}transcript ${closedTickets.rows[t].id}\` to view.`;
closed.push(`> **#${closedTickets.rows[t].id}**: \`${desc}${desc.length > 20 ? '...' : ''}\`${transcript}`);
}
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('Closed tickets', closedTickets.count === 0 ? `${pre} no old tickets` : closed.join('\n\n'), false);
message.delete({timeout: 15000});
let channel;

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const { MessageEmbed } = require('discord.js');
@@ -47,10 +47,10 @@ module.exports = {
.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
}, {

View File

@@ -1,9 +1,9 @@
/**
*
*
* @name DiscordTickets
* @author eartharoid <contact@eartharoid.me>
* @license GNU-GPLv3
*
*
*/
const fs = require('fs');
@@ -66,7 +66,7 @@ module.exports = {
}
];
}
const BASE_URL = config.transcripts.web.server;
if (config.transcripts.web.enabled)
@@ -83,7 +83,7 @@ module.exports = {
} catch (e) {
channel = message.channel;
}
channel.send(res).then(m => {
if (channel.id === message.channel.id)
m.delete({timeout: 15000});