From 504624bd772755ef9cd9cff6103623598acd8e10 Mon Sep 17 00:00:00 2001 From: Tobiah Date: Wed, 10 Feb 2021 08:58:27 -0600 Subject: [PATCH] fix logger field --- src/Logger.js | 12 ++++++------ src/commands/Settings/AllowCustomCommands.js | 2 +- src/commands/Settings/AllowInlineCommands.js | 2 +- src/commands/Settings/DeleteAfterRespond.js | 2 +- src/commands/Settings/Language.js | 2 +- src/commands/Settings/Platform.js | 2 +- src/commands/Settings/RespondToSettings.js | 2 +- src/tools/generateManifest.js | 6 ++---- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Logger.js b/src/Logger.js index bdcc5fc92..f353184fc 100644 --- a/src/Logger.js +++ b/src/Logger.js @@ -45,20 +45,20 @@ const scopes = { * @property {function} fatal - Logs a fatal message. The program should terminate after such * an error */ -class Logger { - isLoggable(level) { - return Object.keys(levels).indexOf(level.toUpperCase()) >= Object.keys(levels).indexOf(l.logLevel) - } -} +class Logger {} const colorify = (level, map) => level[map[level] || 'red']; const fmt = (level, msg) => `[${colorify(scope, scopes)}] ${(colorify(level, levels) || 'ukn').toLowerCase()}: ${msg}`; +Logger.prototype.isLoggable = (level) => { + return Object.keys(levels).indexOf(level.toUpperCase()) >= Object.keys(levels).indexOf(l.logLevel); +} + Object.keys(levels).forEach((level) => { Logger.prototype[level.toLowerCase()] = (message) => { const simple = fmt(level, message); const nonError = Object.keys(levels).indexOf(level) < Object.keys(levels).indexOf('ERROR'); - if (this.isLoggable(level) && nonError) { + if (Logger.prototype.isLoggable(level) && nonError) { console.log(simple); } diff --git a/src/commands/Settings/AllowCustomCommands.js b/src/commands/Settings/AllowCustomCommands.js index 5a07132a9..9e7a697fd 100644 --- a/src/commands/Settings/AllowCustomCommands.js +++ b/src/commands/Settings/AllowCustomCommands.js @@ -7,7 +7,7 @@ class AllowCustomCommands extends Command { constructor(bot) { super(bot, 'settings.allowCustom', 'allow custom commands', 'Toggle whether or not custom commands are allowed here.', 'CUST_CMDS'); this.usages = [ - { description: 'Change if this channel can use custom commands', parameters: ['custom commands enabled'] }, + { description: 'Change if this channel can use custom commands', parameters: ['on', 'off'] }, ]; this.regex = new RegExp('^allow\\s?custom(?:\\s?commands)?\\s?(on|off)?(?:\\s+in\\s+((?:\\<\\#)?\\d+(?:\\>)?|here))?$', 'i'); this.requiresAuth = true; diff --git a/src/commands/Settings/AllowInlineCommands.js b/src/commands/Settings/AllowInlineCommands.js index 6ea3c0eff..bcea345b0 100644 --- a/src/commands/Settings/AllowInlineCommands.js +++ b/src/commands/Settings/AllowInlineCommands.js @@ -7,7 +7,7 @@ class AllowInlineCommands extends Command { constructor(bot) { super(bot, 'settings.allowinline', 'allow inline commands', 'Toggle whether or not inline commands are allowed here.', 'CMD_MGMT'); this.usages = [ - { description: 'Change if this channel can use inline commands', parameters: ['inline commands enabled'] }, + { description: 'Change if this channel can use inline commands', parameters: ['on', 'off'] }, ]; this.regex = new RegExp('^allow\\s?inline(?:\\s?commands)?\\s?(on|off)?(?:\\s+in\\s+((?:\\<\\#)?\\d+(?:\\>)?|here))?$', 'i'); this.requiresAuth = true; diff --git a/src/commands/Settings/DeleteAfterRespond.js b/src/commands/Settings/DeleteAfterRespond.js index f7fac0efc..f3e4a7b18 100644 --- a/src/commands/Settings/DeleteAfterRespond.js +++ b/src/commands/Settings/DeleteAfterRespond.js @@ -7,7 +7,7 @@ class RespondToSettings extends Command { constructor(bot) { super(bot, 'settings.deleteafterrespond', 'delete after respond', 'Set whether or not to allow the bot to delete commands and/or responses after responding.', 'CMD_MGMT'); this.usages = [ - { description: 'Change if the bot to delete commands and/or responses after responding in this channel', parameters: ['deleting enabled'] }, + { description: 'Change if the bot to delete commands and/or responses after responding in this channel', parameters: ['all', 'command', 'respond', 'none'] }, ]; this.regex = new RegExp('^delete\\s?after\\s?respond\\s?(all|command|respond|none)?(?:\\s+in\\s+((?:\\<\\#)?\\d+(?:\\>)?|here))?$', 'i'); this.requiresAuth = true; diff --git a/src/commands/Settings/Language.js b/src/commands/Settings/Language.js index cea3b7e34..68eb80e06 100644 --- a/src/commands/Settings/Language.js +++ b/src/commands/Settings/Language.js @@ -9,7 +9,7 @@ class Language extends Command { constructor(bot) { super(bot, 'settings.language', 'language', 'Set the channel\'s language', 'CORE'); this.usages = [ - { description: 'Change this channel\'s language', parameters: ['language'] }, + { description: 'Change this channel\'s language', parameters: languages, separator: '|'}, ]; this.regex = new RegExp(`^${this.call}\\s?(${languages.join('|')})?(?:\\s+in\\s+(${captures.channel}|here))?$`, 'i'); this.requiresAuth = true; diff --git a/src/commands/Settings/Platform.js b/src/commands/Settings/Platform.js index ffbf0437c..dcddf2232 100644 --- a/src/commands/Settings/Platform.js +++ b/src/commands/Settings/Platform.js @@ -7,7 +7,7 @@ class Platform extends Command { constructor(bot) { super(bot, 'settings.platform', 'platform', 'Change a channel\'s platform', 'CORE'); this.usages = [ - { description: 'Change this channel\'s platform', parameters: ['platform'] }, + { description: 'Change this channel\'s platform', parameters: platforms, separator: '|' }, ]; this.regex = new RegExp(`^${this.call}(?:\\s+(${platforms.join('|')}))?(?:\\s+in\\s+(${captures.channel}|here))?$`, 'i'); this.requiresAuth = true; diff --git a/src/commands/Settings/RespondToSettings.js b/src/commands/Settings/RespondToSettings.js index b132bcc26..257c66e9b 100644 --- a/src/commands/Settings/RespondToSettings.js +++ b/src/commands/Settings/RespondToSettings.js @@ -7,7 +7,7 @@ class RespondToSettings extends Command { constructor(bot) { super(bot, 'settings.respondSettings', 'respond to settings', 'Toggle whether or not the bot tells you when settings change from your command.', 'CMD_MGMT'); this.usages = [ - { description: 'Change if this channel has settings changes responded in it', parameters: ['response enabled'] }, + { description: 'Change if this channel has settings changes responded in it', parameters: ['on', 'off'] }, ]; this.regex = new RegExp(`^respond(?:\\sto)?\\s?settings\\s?(on|off)?(?:\\s+in\\s+(${captures.channel}|here))?$`, 'i'); this.requiresAuth = true; diff --git a/src/tools/generateManifest.js b/src/tools/generateManifest.js index 07c63c7e7..057bdbea1 100644 --- a/src/tools/generateManifest.js +++ b/src/tools/generateManifest.js @@ -4,6 +4,7 @@ const fs = require('fs'); const path = require('path'); const BaseCommand = require('../models/Command'); const { games } = require('../CommonFunctions'); +const logger = require('../Logger'); const generateManifest = async () => { const commandDir = path.join(__dirname, '../commands'); @@ -43,10 +44,7 @@ const generateManifest = async () => { try { fs.writeFileSync('commands.json', JSON.stringify(commands), 'utf8'); - if (['DEBUG', 'INFO'].some(str => str === process.env.LOG_LEVEL)) { - // eslint-disable-next-line no-console - console.log('[DEBUG] Wrote command manifest...'); - } + logger.info('Wrote command manifest...'); } catch (e) { // eslint-disable-next-line no-console console.error(e);