optimise by removing unneeded modules and replacing with built-in methods (#344)

This commit is contained in:
David Ralph 2022-09-30 19:21:59 +01:00 committed by GitHub
parent 460138fb73
commit ce6e2b7d8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 6 deletions

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
# directories # directories
dist/ dist/
.history/
.vscode/
node_modules/ node_modules/
prisma/ prisma/

View File

@ -44,7 +44,6 @@
"@fastify/jwt": "^5.0.1", "@fastify/jwt": "^5.0.1",
"@fastify/oauth2": "^5.1.0", "@fastify/oauth2": "^5.1.0",
"@prisma/client": "^4.3.1", "@prisma/client": "^4.3.1",
"boolean": "^3.2.0",
"cryptr": "^6.0.3", "cryptr": "^6.0.3",
"discord.js": "^14.3.0", "discord.js": "^14.3.0",
"dotenv": "^16.0.2", "dotenv": "^16.0.2",
@ -55,7 +54,6 @@
"keyv": "^4.5.0", "keyv": "^4.5.0",
"leeks.js": "^0.2.4", "leeks.js": "^0.2.4",
"leekslazylogger": "^4.1.7", "leekslazylogger": "^4.1.7",
"md5": "^2.3.0",
"ms": "^2.1.3", "ms": "^2.1.3",
"node-dir": "^0.1.17", "node-dir": "^0.1.17",
"node-emoji": "^1.11.0", "node-emoji": "^1.11.0",

View File

@ -1,5 +1,5 @@
const { Listener } = require('@eartharoid/dbf'); const { Listener } = require('@eartharoid/dbf');
const md5 = require('md5'); const crypto = require('crypto');
const ms = require('ms'); const ms = require('ms');
const { version } = require('../../../package.json'); const { version } = require('../../../package.json');
const { msToMins } = require('../../lib/misc'); const { msToMins } = require('../../lib/misc');
@ -81,7 +81,7 @@ module.exports = class extends Listener {
categories: await client.prisma.category.count(), categories: await client.prisma.category.count(),
database: process.env.DB_PROVIDER, database: process.env.DB_PROVIDER,
guilds: client.guilds.cache.size, guilds: client.guilds.cache.size,
id: md5(client.user.id), id: crypto.createHash('md5').update(client.user.id).digest('hex'),
members: client.guilds.cache.reduce((t, g) => t + g.memberCount, 0), members: client.guilds.cache.reduce((t, g) => t + g.memberCount, 0),
messages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they can be deleted, messages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they can be deleted,
node: process.version, node: process.version,

View File

@ -1,5 +1,4 @@
const ms = require('ms'); const ms = require('ms');
const { boolean } = require('boolean');
module.exports.get = () => ({ module.exports.get = () => ({
handler: async (req, res) => { handler: async (req, res) => {
@ -22,7 +21,7 @@ module.exports.get = () => ({
discriminator: client.user.discriminator, discriminator: client.user.discriminator,
id: client.user.id, id: client.user.id,
portal: process.env.PORTAL || null, portal: process.env.PORTAL || null,
public: boolean(process.env.PUBLIC_BOT), public: (process.env.PUBLIC_BOT === 'true'),
stats: { stats: {
activatedUsers: users.length, activatedUsers: users.length,
archivedMessages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they can be deleted archivedMessages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they can be deleted