diff --git a/index.js b/index.js index 7d9fd19..4c9a84d 100644 --- a/index.js +++ b/index.js @@ -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`); diff --git a/package.json b/package.json index aea3422..2b52c92 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/structure/DiscordClient.js b/src/structure/DiscordClient.js index 908be2c..7da8a54 100644 --- a/src/structure/DiscordClient.js +++ b/src/structure/DiscordClient.js @@ -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' }); }); diff --git a/src/structure/interfaces/Setting.js b/src/structure/interfaces/Setting.js index 7662132..5dffd08 100644 --- a/src/structure/interfaces/Setting.js +++ b/src/structure/interfaces/Setting.js @@ -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