Node v18, discord.js v14

This commit is contained in:
Isaac 2022-07-18 13:34:29 +01:00
parent c04787bb80
commit 3a1c0f54bd
5 changed files with 37 additions and 46 deletions

View File

@ -27,10 +27,10 @@
}, },
"homepage": "https://discordtickets.app", "homepage": "https://discordtickets.app",
"engines": { "engines": {
"node": ">=16.6" "node": ">=18.0"
}, },
"dependencies": { "dependencies": {
"@eartharoid/dbf": "^0.0.1", "@eartharoid/dbf": "^0.2.0",
"@eartharoid/dtf": "^2.0.1", "@eartharoid/dtf": "^2.0.1",
"@eartharoid/i18n": "^1.0.4", "@eartharoid/i18n": "^1.0.4",
"@fastify/cookie": "^6.0.0", "@fastify/cookie": "^6.0.0",
@ -39,26 +39,25 @@
"@fastify/oauth2": "^5.0.0", "@fastify/oauth2": "^5.0.0",
"@prisma/client": "^4.0.0", "@prisma/client": "^4.0.0",
"cryptr": "^6.0.3", "cryptr": "^6.0.3",
"discord.js": "^13.9.0", "discord.js": "^14.0.2",
"dotenv": "^16.0.1", "dotenv": "^16.0.1",
"fastify": "^4.2.1", "fastify": "^4.2.1",
"figlet": "^1.5.2", "figlet": "^1.5.2",
"keyv": "^4.3.2", "keyv": "^4.3.3",
"leeks.js": "^0.2.4", "leeks.js": "^0.2.4",
"leekslazylogger": "^4.1.7", "leekslazylogger": "^4.1.7",
"ms": "^2.1.3", "ms": "^2.1.3",
"node-dir": "^0.1.17", "node-dir": "^0.1.17",
"node-fetch": "^2.6.7",
"object-diffy": "^1.0.4", "object-diffy": "^1.0.4",
"prisma": "^4.0.0",
"semver": "^7.3.7", "semver": "^7.3.7",
"terminal-link": "^2.1.1", "terminal-link": "^2.1.1",
"yaml": "^1.10.2" "yaml": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {
"all-contributors-cli": "^6.20.0", "all-contributors-cli": "^6.20.0",
"eslint": "^8.19.0", "eslint": "^8.20.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"nodemon": "^2.0.19", "nodemon": "^2.0.19"
"prisma": "^4.0.0"
} }
} }

View File

@ -1,5 +1,5 @@
const { Client: FrameworkClient }= require('@eartharoid/dbf'); const { Client: FrameworkClient } = require('@eartharoid/dbf');
const { Intents } = require('discord.js'); const { GatewayIntentBits } = require('discord.js');
const { PrismaClient } = require('@prisma/client'); const { PrismaClient } = require('@prisma/client');
const Keyv = require('keyv'); const Keyv = require('keyv');
const I18n = require('@eartharoid/i18n'); const I18n = require('@eartharoid/i18n');
@ -12,9 +12,9 @@ module.exports = class Client extends FrameworkClient {
constructor(config, log) { constructor(config, log) {
super({ super({
intents: [ intents: [
Intents.FLAGS.GUILDS, GatewayIntentBits.Guilds,
Intents.FLAGS.GUILD_MEMBERS, GatewayIntentBits.GuildMembers,
Intents.FLAGS.GUILD_MESSAGES, GatewayIntentBits.GuildMessages,
], ],
}); });

View File

@ -3,7 +3,7 @@ const oauth = require('@fastify/oauth2');
// const { randomBytes } = require('crypto'); // const { randomBytes } = require('crypto');
const { short } = require('leeks.js'); const { short } = require('leeks.js');
const { join } = require('path'); const { join } = require('path');
const { readFiles } = require('node-dir'); const { files } = require('node-dir');
module.exports = client => { module.exports = client => {
@ -115,36 +115,29 @@ module.exports = client => {
// route loading // route loading
const dir = join(__dirname, '/routes'); const dir = join(__dirname, '/routes');
readFiles(dir, files(dir, {
{ exclude: /^\./,
exclude: /^\./, match: /.js$/,
match: /.js$/, sync: true,
}, }).forEach(file => {
(err, content, next) => next(), const path = file
(err, files) => { .substring(0, file.length - 3) // remove `.js`
if (err) throw err; .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) { Object.keys(route).forEach(method => fastify.route({
const path = file config: { client },
.substring(0, file.length - 3) // remove `.js` method: method.toUpperCase(),
.substring(dir.length) // remove higher directories path,
.replace(/\[(\w+)\]/gi, ':$1') // convert [] to : ...route[method](fastify),
.replace('/index', '') || '/'; // remove index })); // register route
const route = require(file); });
Object.keys(route).forEach(method => fastify.route({ // start server
config: { client }, fastify.listen({ port: process.env.HTTP_BIND }, (err, addr) => {
method: method.toUpperCase(), if (err) client.log.error.http(err);
path, else client.log.success.http(`Listening at ${addr}`);
...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}`);
});
},
);
}; };

View File

@ -69,7 +69,7 @@ module.exports.post = fastify => ({
data.discordCategory = channel.id; data.discordCategory = channel.id;
} }
if (!data.channelName) data.channelName = 'ticket-{num}'; data.channelName ??= 'ticket-{num}';
const category = await client.prisma.category.create({ const category = await client.prisma.category.create({
data: { data: {

View File

@ -1,4 +1,3 @@
const fetch = require('node-fetch');
const { domain } = require('../../lib/http'); const { domain } = require('../../lib/http');
module.exports.get = () => ({ module.exports.get = () => ({