This commit is contained in:
Erik 2022-07-04 11:44:05 +03:00
parent 9e8beb687f
commit 287193dd17
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
4 changed files with 26 additions and 12 deletions

View File

@ -1,4 +1,4 @@
const env = require('dotenv').config({ override: true, debug: true });
require('dotenv').config({ override: true });
// eslint-disable-next-line no-console
console.log(`Starting in ${process.env.NODE_ENV} mode`);

View File

@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon --trace-warnings --unhandled-rejections=strict index.js",
"dev": "node --trace-warnings --unhandled-rejections=strict index.js",
"debug": "node --trace-warnings --inspect index.js",
"update": "git pull && cd api && yarn update",
"test": "jest --detectOpenHandles",

View File

@ -70,7 +70,7 @@ class DiscordClient extends Client {
// });
process.on('unhandledRejection', (err, reason) => {
this.logger.error(`Unhandled rejection:\n${err.stack || err}\n${inspect(reason)}`);
this.logger.error(`Unhandled rejection:\n${err?.stack || err}\n${inspect(reason)}`);
});
process.on('message', this._handleMessage.bind(this));
@ -135,7 +135,7 @@ class DiscordClient extends Client {
return new Promise((resolve, reject) => {
this._evals.set(script, { resolve, reject });
process.send({ _mEval: true, script });
process.send({ _mEval: true, script, debug: options.debug || process.env.NODE_ENV === 'development' });
});

View File

@ -222,28 +222,42 @@ class Setting extends Component {
// Manipulator functions
add(list = [], params = [], caseSensitive = false) {
const modified = [],
skipped = [];
for (const param of params) {
if (!list.includes(param)) list.push(!caseSensitive ? param : param.toLowerCase());
if (!list.includes(param)) {
list.push(!caseSensitive ? param : param.toLowerCase());
modified.push(param);
} else skipped.push(param);
}
return list;
return { list, modified, skipped };
}
remove(list = [], params = [], caseSensitive = false) {
const modified = [],
skipped = [];
for (const param of params) {
if (list.includes(param)) list.splice(list.indexOf(!caseSensitive ? param : param.toLowerCase()), 1);
if (list.includes(param)) {
list.splice(list.indexOf(!caseSensitive ? param : param.toLowerCase()), 1);
} else skipped.push(param);
}
return list;
return { list, modified, skipped };
}
set(list, params = []) {
const modified = [...new Set(params)];
list.splice(0, list.length);
list.push(...params);
return list;
list.push(...modified);
return { list, modified };
}
reset(list) {
list.splice(0, list.length);
return list;
const modified = list.splice(0, list.length);
return { list, modified };
}
// Functions for message component based settings