mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 00:03:09 +02:00
Node v18, discord.js v14
This commit is contained in:
parent
c04787bb80
commit
3a1c0f54bd
15
package.json
15
package.json
@ -27,10 +27,10 @@
|
||||
},
|
||||
"homepage": "https://discordtickets.app",
|
||||
"engines": {
|
||||
"node": ">=16.6"
|
||||
"node": ">=18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eartharoid/dbf": "^0.0.1",
|
||||
"@eartharoid/dbf": "^0.2.0",
|
||||
"@eartharoid/dtf": "^2.0.1",
|
||||
"@eartharoid/i18n": "^1.0.4",
|
||||
"@fastify/cookie": "^6.0.0",
|
||||
@ -39,26 +39,25 @@
|
||||
"@fastify/oauth2": "^5.0.0",
|
||||
"@prisma/client": "^4.0.0",
|
||||
"cryptr": "^6.0.3",
|
||||
"discord.js": "^13.9.0",
|
||||
"discord.js": "^14.0.2",
|
||||
"dotenv": "^16.0.1",
|
||||
"fastify": "^4.2.1",
|
||||
"figlet": "^1.5.2",
|
||||
"keyv": "^4.3.2",
|
||||
"keyv": "^4.3.3",
|
||||
"leeks.js": "^0.2.4",
|
||||
"leekslazylogger": "^4.1.7",
|
||||
"ms": "^2.1.3",
|
||||
"node-dir": "^0.1.17",
|
||||
"node-fetch": "^2.6.7",
|
||||
"object-diffy": "^1.0.4",
|
||||
"prisma": "^4.0.0",
|
||||
"semver": "^7.3.7",
|
||||
"terminal-link": "^2.1.1",
|
||||
"yaml": "^1.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"all-contributors-cli": "^6.20.0",
|
||||
"eslint": "^8.19.0",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"nodemon": "^2.0.19",
|
||||
"prisma": "^4.0.0"
|
||||
"nodemon": "^2.0.19"
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
const { Client: FrameworkClient }= require('@eartharoid/dbf');
|
||||
const { Intents } = require('discord.js');
|
||||
const { Client: FrameworkClient } = require('@eartharoid/dbf');
|
||||
const { GatewayIntentBits } = require('discord.js');
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const Keyv = require('keyv');
|
||||
const I18n = require('@eartharoid/i18n');
|
||||
@ -12,9 +12,9 @@ module.exports = class Client extends FrameworkClient {
|
||||
constructor(config, log) {
|
||||
super({
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MEMBERS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
],
|
||||
});
|
||||
|
||||
|
55
src/http.js
55
src/http.js
@ -3,7 +3,7 @@ const oauth = require('@fastify/oauth2');
|
||||
// const { randomBytes } = require('crypto');
|
||||
const { short } = require('leeks.js');
|
||||
const { join } = require('path');
|
||||
const { readFiles } = require('node-dir');
|
||||
const { files } = require('node-dir');
|
||||
|
||||
module.exports = client => {
|
||||
|
||||
@ -115,36 +115,29 @@ module.exports = client => {
|
||||
// route loading
|
||||
const dir = join(__dirname, '/routes');
|
||||
|
||||
readFiles(dir,
|
||||
{
|
||||
exclude: /^\./,
|
||||
match: /.js$/,
|
||||
},
|
||||
(err, content, next) => next(),
|
||||
(err, files) => {
|
||||
if (err) throw err;
|
||||
files(dir, {
|
||||
exclude: /^\./,
|
||||
match: /.js$/,
|
||||
sync: true,
|
||||
}).forEach(file => {
|
||||
const path = file
|
||||
.substring(0, file.length - 3) // remove `.js`
|
||||
.substring(dir.length) // remove higher directories
|
||||
.replace(/\[(\w+)\]/gi, ':$1') // convert [] to :
|
||||
.replace('/index', '') || '/'; // remove index
|
||||
const route = require(file);
|
||||
|
||||
for (const file of files) {
|
||||
const path = file
|
||||
.substring(0, file.length - 3) // remove `.js`
|
||||
.substring(dir.length) // remove higher directories
|
||||
.replace(/\[(\w+)\]/gi, ':$1') // convert [] to :
|
||||
.replace('/index', '') || '/'; // remove index
|
||||
const route = require(file);
|
||||
Object.keys(route).forEach(method => fastify.route({
|
||||
config: { client },
|
||||
method: method.toUpperCase(),
|
||||
path,
|
||||
...route[method](fastify),
|
||||
})); // register route
|
||||
});
|
||||
|
||||
Object.keys(route).forEach(method => fastify.route({
|
||||
config: { client },
|
||||
method: method.toUpperCase(),
|
||||
path,
|
||||
...route[method](fastify),
|
||||
})); // register route
|
||||
}
|
||||
|
||||
// start server
|
||||
fastify.listen({ port: process.env.HTTP_BIND }, (err, addr) => {
|
||||
if (err) client.log.error.http(err);
|
||||
else client.log.success.http(`Listening at ${addr}`);
|
||||
});
|
||||
},
|
||||
);
|
||||
// start server
|
||||
fastify.listen({ port: process.env.HTTP_BIND }, (err, addr) => {
|
||||
if (err) client.log.error.http(err);
|
||||
else client.log.success.http(`Listening at ${addr}`);
|
||||
});
|
||||
};
|
@ -69,7 +69,7 @@ module.exports.post = fastify => ({
|
||||
data.discordCategory = channel.id;
|
||||
}
|
||||
|
||||
if (!data.channelName) data.channelName = 'ticket-{num}';
|
||||
data.channelName ??= 'ticket-{num}';
|
||||
|
||||
const category = await client.prisma.category.create({
|
||||
data: {
|
||||
|
@ -1,4 +1,3 @@
|
||||
const fetch = require('node-fetch');
|
||||
const { domain } = require('../../lib/http');
|
||||
|
||||
module.exports.get = () => ({
|
||||
|
Loading…
Reference in New Issue
Block a user