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': [ 'no-control-regex': [
'off' '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 - Highly customisable
- Ticket "panel" / "widget" (react to embed to create ticket) - Ticket "panel" / "widget" (react to embed to create ticket)
- Simple commands - 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 - Most (all of the best) features of the premium bots, for free
- Self-hosted with your bot application, your logo and guild name - 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 ## Screenshot
@ -31,4 +31,4 @@ For installation, configuration, usage, and other information, **go to the [wiki
## Donate ## 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" "sqlite3": "^5.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"mysql2": "2.x" "mysql2": "2.x",
"mariadb": "2.x",
"pg": "8.x",
"tedious": "9.x"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^7.10.0", "eslint": "^7.10.0",

View File

@ -35,14 +35,12 @@ module.exports = {
let channel = message.mentions.channels.first(); let channel = message.mentions.channels.first();
if (!channel) { if (!channel) {
channel = message.channel; channel = message.channel;
ticket = await Ticket.findOne({ where: { channel: message.channel.id } }); ticket = await Ticket.findOne({ where: { channel: message.channel.id } });
if(!ticket) if(!ticket)
return message.channel.send(notTicket); return message.channel.send(notTicket);
} else { } else {
ticket = await Ticket.findOne({ where: { channel: channel.id } }); ticket = await Ticket.findOne({ where: { channel: channel.id } });
if (!ticket) { if (!ticket) {
notTicket notTicket
@ -64,8 +62,6 @@ module.exports = {
.setFooter(guild.name, guild.iconURL()) .setFooter(guild.name, guild.iconURL())
); );
let member = guild.member(message.mentions.users.first() || guild.members.cache.get(args[0])); let member = guild.member(message.mentions.users.first() || guild.members.cache.get(args[0]));
if (!member) if (!member)
@ -99,7 +95,6 @@ module.exports = {
); );
message.channel.send( message.channel.send(
new MessageEmbed() new MessageEmbed()
.setColor(config.colour) .setColor(config.colour)

View File

@ -156,7 +156,6 @@ module.exports = {
) )
embed.addField('Web archive', await archive.export(Ticket, channel)); embed.addField('Web archive', await archive.export(Ticket, channel));
if (embed.fields.length < 1) if (embed.fields.length < 1)
embed.setDescription(`No text transcripts or archive data exists for ticket ${ticket.id}`); embed.setDescription(`No text transcripts or archive data exists for ticket ${ticket.id}`);

View File

@ -80,11 +80,9 @@ module.exports = {
let open = [], let open = [],
closed = []; closed = [];
for (let t in openTickets.rows) { for (let t in openTickets.rows) {
let desc = openTickets.rows[t].topic.substring(0, 30); let desc = openTickets.rows[t].topic.substring(0, 30);
open.push(`> <#${openTickets.rows[t].channel}>: \`${desc}${desc.length > 20 ? '...' : ''}\``); open.push(`> <#${openTickets.rows[t].channel}>: \`${desc}${desc.length > 20 ? '...' : ''}\``);
} }
for (let t in closedTickets.rows) { for (let t in closedTickets.rows) {

View File

@ -50,6 +50,5 @@ module.exports = {
edited: true edited: true
}) + '\n'); }) + '\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 require('./modules/updater')(); // check for updates
/** /**
* storage * storage
*/ */
@ -48,14 +47,40 @@ const { Sequelize, Model, DataTypes } = require('sequelize');
let sequelize; let sequelize;
if(config.storage.type === 'mysql') { switch (config.storage.type) {
case 'mysql':
log.info('Connecting to MySQL database...'); log.info('Connecting to MySQL database...');
sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, { sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASS, {
dialect: 'mysql', dialect: 'mysql',
host: process.env.DB_HOST, host: process.env.DB_HOST,
logging: log.debug 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'); log.info('Using SQLite storage');
sequelize = new Sequelize({ sequelize = new Sequelize({
dialect: 'sqlite', dialect: 'sqlite',

View File

@ -15,13 +15,10 @@ version = 'v' + version;
const boxen = require('boxen'); const boxen = require('boxen');
const link = require('terminal-link'); const link = require('terminal-link');
module.exports = () => { module.exports = async () => {
if(!config.updater) if(!config.updater)
return; return;
const json = await (await fetch('https://api.github.com/repos/eartharoid/DiscordTickets/releases')).json();
fetch('https://api.github.com/repos/eartharoid/DiscordTickets/releases')
.then(res => res.json())
.then(json => {
const update = json[0]; const update = json[0];
let notice = []; let notice = [];
@ -42,5 +39,4 @@ module.exports = () => {
}) })
); );
} }
});
}; };

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