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

@ -32,6 +32,9 @@ module.exports = {
],
'no-control-regex': [
'off'
],
'no-console': [
'off'
]
}
};

View File

@ -9,10 +9,10 @@ DiscordTickets is a Discord bot for managing support ticket channels, to allow y
- Highly customisable
- Ticket "panel" / "widget" (react to embed to create ticket)
- Simple commands
- SQLite (easy, default) **or** MySQL (recommend) storage
- Supports multiple databases: SQLite (easy, default), MySQL (recommend) storage, MariaDB, PostgresSQL and Microsoft SQL Server
- Most (all of the best) features of the premium bots, for free
- Self-hosted with your bot application, your logo and guild name
- Optional express.js server for web archvies: [DiscordTickets-Portal](https://github.com/eartharoid/DiscordTickets-Portal/)
- Optional express.js server for web archives: [DiscordTickets-Portal](https://github.com/eartharoid/DiscordTickets-Portal/)
## Screenshot
@ -31,4 +31,4 @@ For installation, configuration, usage, and other information, **go to the [wiki
## Donate
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B214BHI)
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/eartharoid)

View File

@ -19,7 +19,10 @@
"sqlite3": "^5.0.0"
},
"peerDependencies": {
"mysql2": "2.x"
"mysql2": "2.x",
"mariadb": "2.x",
"pg": "8.x",
"tedious": "9.x"
},
"devDependencies": {
"eslint": "^7.10.0",

View File

@ -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)
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.`);
@ -64,11 +62,9 @@ module.exports = {
.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)

View File

@ -156,7 +156,6 @@ module.exports = {
)
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

@ -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: '',

View File

@ -34,11 +34,11 @@ 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 {
@ -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)

View File

@ -80,11 +80,9 @@ module.exports = {
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) {

View File

@ -50,6 +50,5 @@ module.exports = {
edited: true
}) + '\n');
}
};

View File

@ -40,7 +40,6 @@ log.multi(log); // required to allow other files to access the logger
require('./modules/updater')(); // check for updates
/**
* storage
*/
@ -48,14 +47,40 @@ const { Sequelize, Model, DataTypes } = require('sequelize');
let sequelize;
if(config.storage.type === 'mysql') {
switch (config.storage.type) {
case 'mysql':
log.info('Connecting to MySQL database...');
sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
dialect: 'mysql',
host: process.env.DB_HOST,
logging: log.debug
});
} else {
break;
case 'mariadb':
log.info('Connecting to MariaDB database...');
sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
dialect: 'mariadb',
host: process.env.DB_HOST,
logging: log.debug
});
break;
case 'postgres':
log.info('Connecting to PostgresSQL database...');
sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
dialect: 'postgres',
host: process.env.DB_HOST,
logging: log.debug
});
break;
case 'microsoft':
log.info('Connecting to Microsoft SQL Server database...');
sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
dialect: 'mssql',
host: process.env.DB_HOST,
logging: log.debug
});
break;
default:
log.info('Using SQLite storage');
sequelize = new Sequelize({
dialect: 'sqlite',

View File

@ -17,7 +17,7 @@ const fetch = require('node-fetch');
module.exports.add = (message) => {
if(message.type !== 'DEFAULT') return;
if (message.type !== 'DEFAULT') return;
if (config.transcripts.text.enabled) { // text transcripts
let path = `user/transcripts/text/${message.channel.id}.txt`,

View File

@ -15,32 +15,28 @@ version = 'v' + version;
const boxen = require('boxen');
const link = require('terminal-link');
module.exports = () => {
module.exports = async () => {
if(!config.updater)
return;
const json = await (await fetch('https://api.github.com/repos/eartharoid/DiscordTickets/releases')).json();
const update = json[0];
let notice = [];
fetch('https://api.github.com/repos/eartharoid/DiscordTickets/releases')
.then(res => res.json())
.then(json => {
const update = json[0];
let notice = [];
if (version !== update.tag_name) {
log.notice(log.f(`There is an update available for Discord Tickets (${version} -> ${update.tag_name})`));
if (version !== update.tag_name) {
log.notice(log.f(`There is an update available for Discord Tickets (${version} -> ${update.tag_name})`));
notice.push(`&6You are currently using &c${version}&6, the latest is &a${update.tag_name}&6.`);
notice.push(`&6Download "&f${update.name}&6" from`);
notice.push(link('&6the GitHub releases page', 'https://github.com/eartharoid/DiscordTickets/releases/'));
notice.push(`&6You are currently using &c${version}&6, the latest is &a${update.tag_name}&6.`);
notice.push(`&6Download "&f${update.name}&6" from`);
notice.push(link('&6the GitHub releases page', 'https://github.com/eartharoid/DiscordTickets/releases/'));
console.log(
boxen(log.f(notice.join('\n')), {
padding: 1,
margin: 1,
align: 'center',
borderColor: 'yellow',
borderStyle: 'round'
})
);
}
});
console.log(
boxen(log.f(notice.join('\n')), {
padding: 1,
margin: 1,
align: 'center',
borderColor: 'yellow',
borderStyle: 'round'
})
);
}
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 698 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 577 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB