mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 04:13:08 +02:00
Add categories database table
This commit is contained in:
parent
1f2d40234b
commit
74fa568a7c
@ -82,6 +82,29 @@ module.exports = async (log) => {
|
||||
tableName: DB_TABLE_PREFIX + 'guilds'
|
||||
});
|
||||
|
||||
const Category = sequelize.define('Category', {
|
||||
id: {
|
||||
type: DataTypes.CHAR(18),
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
unique: 'name_guild'
|
||||
},
|
||||
guild: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Guild,
|
||||
key: 'id'
|
||||
},
|
||||
unique: 'name_guild'
|
||||
},
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'categories'
|
||||
});
|
||||
|
||||
const Ticket = sequelize.define('Ticket', {
|
||||
id: {
|
||||
@ -102,6 +125,14 @@ module.exports = async (log) => {
|
||||
key: 'id'
|
||||
},
|
||||
},
|
||||
category: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Category,
|
||||
key: 'id'
|
||||
},
|
||||
},
|
||||
}, {
|
||||
tableName: DB_TABLE_PREFIX + 'tickets'
|
||||
});
|
||||
|
@ -1,5 +1,4 @@
|
||||
const { Plugin } = require('../modules/plugins');
|
||||
const fastify = require('fastify')();
|
||||
|
||||
module.exports = class SettingsServer extends Plugin {
|
||||
constructor(client){
|
||||
@ -10,23 +9,25 @@ module.exports = class SettingsServer extends Plugin {
|
||||
commands: []
|
||||
});
|
||||
|
||||
this.fastify = require('fastify')();
|
||||
|
||||
this.client.plugins.plugins.set(this.id, this);
|
||||
this.preload();
|
||||
}
|
||||
|
||||
async preload() {
|
||||
fastify.register(this.client.log.fastify, {
|
||||
this.fastify.register(this.client.log.fastify, {
|
||||
type: 'http'
|
||||
});
|
||||
}
|
||||
|
||||
async load() {
|
||||
fastify.listen(process.env.HTTP_PORT || 8080, (err, address) => {
|
||||
this.fastify.listen(process.env.HTTP_PORT || 8080, (err, address) => {
|
||||
if (err) throw err;
|
||||
this.client.log.info(`Settings server listening at ${address}`);
|
||||
});
|
||||
|
||||
fastify.get('/', async (req, res) => {
|
||||
this.fastify.get('/', async (req, res) => {
|
||||
res.type('application/json').code(200);
|
||||
return { hello: 'world' };
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user