mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-01 08:21:27 +03:00
Node v18, discord.js v14
This commit is contained in:
@@ -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 = () => ({
|
||||
|
Reference in New Issue
Block a user