use rest params

This commit is contained in:
ChomeNS 2022-11-20 12:41:35 +07:00
parent 3f0c366cf9
commit 7cacc880e0

View file

@ -1,6 +1,5 @@
/* eslint-disable require-jsdoc */ /* eslint-disable require-jsdoc */
/* eslint-disable max-len */ /* eslint-disable max-len */
/* eslint-disable prefer-rest-params */
const moment = require('moment-timezone'); const moment = require('moment-timezone');
const util = require('util'); const util = require('util');
@ -18,13 +17,13 @@ function inject(bot, _dcclient, config, rl) {
bot.console = {}; bot.console = {};
bot.console.host = 'all'; bot.console.host = 'all';
bot.console.log = function(message) { bot.console.log = function(message) {
console.log(prefix('&6LOG', message)); log(prefix('&6LOG', message));
}; };
bot.console.info = function(message) { bot.console.info = function(message) {
console.log(prefix('&aINFO', message)); log(prefix('&aINFO', message));
}; };
bot.console.error = function(error) { bot.console.error = function(error) {
console.log(prefix('&cERROR', typeof error === 'string' ? error : error.stack)); log(prefix('&cERROR', typeof error === 'string' ? error : error.stack));
}; };
bot.consoleQueue = []; bot.consoleQueue = [];
@ -46,13 +45,13 @@ function inject(bot, _dcclient, config, rl) {
rl.removeAllListeners(); rl.removeAllListeners();
}); });
// readline > fix on console.log // readline > fix on log
const log = console.log; function log(...args) {
console.log = function() {
rl.output.write('\x1b[2K\r'); rl.output.write('\x1b[2K\r');
log.apply(console, Array.prototype.slice.call(arguments)); console.log(args.toString());
rl._refreshLine(); rl._refreshLine();
}; };
rl.on('line', function(line) { rl.on('line', function(line) {
try { try {
if (line.toLowerCase() === '' || if (line.toLowerCase() === '' ||