mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-05 04:13:08 +02:00
mjs -> cjs
This commit is contained in:
parent
9cdd3f92e5
commit
cbfbf05e8c
@ -6,13 +6,8 @@
|
||||
"baseUrl": "src",
|
||||
"resolveJsonModule": true,
|
||||
"checkJs": false,
|
||||
"paths": {
|
||||
"@/*": ["*.mjs"],
|
||||
"#/*": ["*.json"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.mjs",
|
||||
"src/**/*.js"
|
||||
]
|
||||
}
|
18
package.json
18
package.json
@ -3,13 +3,11 @@
|
||||
"version": "4.0.0",
|
||||
"private": "true",
|
||||
"description": "An open-source Discord bot for ticket management",
|
||||
"main": "src/index.mjs",
|
||||
"module": "src/index.mjs",
|
||||
"type": "module",
|
||||
"main": "src/",
|
||||
"scripts": {
|
||||
"contributors:add": "all-contributors add",
|
||||
"contributors:generate": "all-contributors generate",
|
||||
"keygen": "node scripts/keygen.mjs",
|
||||
"keygen": "node scripts/keygen",
|
||||
"lint": "eslint src scripts --ext mjs --fix",
|
||||
"test": "echo \"There's nothing to test\" && exit 1"
|
||||
},
|
||||
@ -32,22 +30,22 @@
|
||||
"node": ">=16.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eartharoid/dbf": "^0.0.1",
|
||||
"@eartharoid/dtf": "^2.0.1",
|
||||
"@prisma/client": "^3.11.0",
|
||||
"@sapphire/framework": "^2.4.1",
|
||||
"@prisma/client": "^3.13.0",
|
||||
"discord.js": "^13.6.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"figlet": "^1.5.2",
|
||||
"leeks.js": "^0.2.4",
|
||||
"leekslazylogger": "^4.1.7",
|
||||
"semver": "^7.3.5",
|
||||
"terminal-link": "^3.0.0",
|
||||
"semver": "^7.3.7",
|
||||
"terminal-link": "^2.1.1",
|
||||
"yaml": "^1.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"all-contributors-cli": "^6.20.0",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint": "^8.14.0",
|
||||
"eslint-plugin-unused-imports": "^2.0.0",
|
||||
"prisma": "^3.11.0"
|
||||
"prisma": "^3.13.0"
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import { randomBytes } from 'crypto';
|
||||
import { short } from 'leeks.js';
|
||||
const { randomBytes } = require('crypto');
|
||||
const { short } = require('leeks.js');
|
||||
|
||||
console.log(short(
|
||||
'Set the "DB_ENCRYPTION_KEY" environment variable to: \n&1&!f' +
|
||||
randomBytes(24).toString('hex') +
|
||||
'&r\n\n&0&!e WARNING &r &e&lIf you lose the encryption key, most of the data in the database will become unreadable, requiring a new key and a full reset.'
|
||||
'&r\n\n&0&!e WARNING &r &e&lIf you lose the encryption key, most of the data in the database will become unreadable, requiring a new key and a full reset.',
|
||||
));
|
24
src/client.js
Normal file
24
src/client.js
Normal file
@ -0,0 +1,24 @@
|
||||
const { Client: FrameworkClient }= require('@eartharoid/dbf');
|
||||
const { Intents } = require('discord.js');
|
||||
const prisma = require('@prisma/client');
|
||||
|
||||
module.exports = class Client extends FrameworkClient {
|
||||
constructor() {
|
||||
super({
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MEMBERS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
],
|
||||
});
|
||||
}
|
||||
async login(token) {
|
||||
this.prisma = new prisma.PrismaClient();
|
||||
return super.login(token);
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
await this.prisma.$disconnect();
|
||||
return super.destroy();
|
||||
}
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
import {
|
||||
container,
|
||||
SapphireClient
|
||||
} from '@sapphire/framework';
|
||||
import { Intents } from 'discord.js';
|
||||
import prisma from '@prisma/client';
|
||||
|
||||
export default class Client extends SapphireClient {
|
||||
constructor() {
|
||||
super({
|
||||
defaultPrefix: 'tickets/',
|
||||
intents: [
|
||||
Intents.FLAGS.GUILDS,
|
||||
Intents.FLAGS.GUILD_MEMBERS,
|
||||
Intents.FLAGS.GUILD_MESSAGES,
|
||||
Intents.FLAGS.GUILD_MESSAGE_REACTIONS
|
||||
],
|
||||
});
|
||||
}
|
||||
async login(token) {
|
||||
container.prisma = new prisma.PrismaClient();
|
||||
return super.login(token);
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
await container.prisma.$disconnect();
|
||||
return super.destroy();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -21,18 +21,17 @@
|
||||
* @license GNU-GPLv3
|
||||
*/
|
||||
|
||||
import dotenv from 'dotenv';
|
||||
import fs from 'fs';
|
||||
import semver from 'semver';
|
||||
import { colours } from 'leeks.js';
|
||||
import logger from './lib/logger.mjs';
|
||||
import banner from './lib/banner.mjs';
|
||||
import YAML from 'yaml';
|
||||
import { container } from '@sapphire/framework';
|
||||
import Client from './client.mjs';
|
||||
|
||||
const fs = require('fs');
|
||||
const semver = require('semver');
|
||||
const { colours } = require('leeks.js');
|
||||
const logger = require('./lib/logger');
|
||||
const banner = require('./lib/banner');
|
||||
const YAML = require('yaml');
|
||||
const Client = require('./client');
|
||||
|
||||
process.env.NODE_ENV ??= 'development'; // make sure NODE_ENV is set
|
||||
dotenv.config(); // load env file
|
||||
require('dotenv').config(); // load env file
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
|
||||
@ -65,7 +64,6 @@ console.log(banner(pkg.version)); // print big title
|
||||
|
||||
const config = YAML.parse(fs.readFileSync(process.env.CONFIG_PATH, 'utf8'));
|
||||
const log = logger(config);
|
||||
container.log = log;
|
||||
|
||||
process.on('unhandledRejection', error => {
|
||||
log.notice(`Discord Tickets v${pkg.version} on Node.js v${process.versions.node} (${process.platform})`);
|
||||
@ -75,4 +73,6 @@ process.on('unhandledRejection', error => {
|
||||
});
|
||||
|
||||
const client = new Client();
|
||||
client.config = config;
|
||||
client.log = log;
|
||||
client.login();
|
@ -1,8 +1,8 @@
|
||||
import { colours } from 'leeks.js';
|
||||
import figlet from 'figlet';
|
||||
import link from 'terminal-link';
|
||||
const { colours } = require('leeks.js');
|
||||
const figlet = require('figlet');
|
||||
const link = require('terminal-link');
|
||||
|
||||
export default version => colours.cyan(figlet.textSync('Discord', { font: 'Banner3' })) +
|
||||
module.exports = version => colours.cyan(figlet.textSync('Discord', { font: 'Banner3' })) +
|
||||
colours.cyan('\n\n' + figlet.textSync('Tickets', { font: 'Banner3' })) +
|
||||
colours.cyanBright(`\n\n${link('Discord Tickets', 'https://discordtickets.app')} bot v${version} by eartharoid`) +
|
||||
colours.cyanBright('\n' + link('Sponsor this project', 'https://discordtickets.app/sponsor')) +
|
@ -1,6 +1,6 @@
|
||||
import Logger from 'leekslazylogger';
|
||||
import DTF from '@eartharoid/dtf';
|
||||
import { short } from 'leeks.js';
|
||||
const Logger = require('leekslazylogger');
|
||||
const DTF = require('@eartharoid/dtf');
|
||||
const { short } = require('leeks.js');
|
||||
|
||||
const dtf = new DTF();
|
||||
const colours = {
|
||||
@ -13,7 +13,7 @@ const colours = {
|
||||
warn: ['&6', '&e'],
|
||||
};
|
||||
|
||||
export default config => {
|
||||
module.exports = config => {
|
||||
const transports = [
|
||||
new Logger.transports.ConsoleTransport({
|
||||
format: log => {
|
||||
@ -22,7 +22,7 @@ export default config => {
|
||||
return short(`&f&!7${timestamp}&r ${colour[0]}[${log.level.name.toUpperCase()}]&r ${log.namespace ? `&d(${log.namespace.toUpperCase()})&r ` : ''}${colour[1]}${log.content}`);
|
||||
},
|
||||
level: config.logs.level,
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
if (config.logs.files.enabled) {
|
||||
@ -32,7 +32,7 @@ export default config => {
|
||||
directory: config.logs.files.directory,
|
||||
level: config.logs.level,
|
||||
name: 'Discord Tickets by eartharoid',
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
16
src/listeners/client/ready.js
Normal file
16
src/listeners/client/ready.js
Normal file
@ -0,0 +1,16 @@
|
||||
const dbf = require('@eartharoid/dbf');
|
||||
|
||||
module.exports = class extends dbf.Listener {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
emitter: client,
|
||||
event: 'ready',
|
||||
id: 'clientReady',
|
||||
once: true,
|
||||
});
|
||||
}
|
||||
|
||||
run() {
|
||||
this.client.log.success('Connected to Discord as "%s"', this.client.user.tag);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user