diff --git a/Manager.js b/Manager.js index 44a1635..34b9fc9 100644 --- a/Manager.js +++ b/Manager.js @@ -11,10 +11,9 @@ class Manager extends EventEmitter { super(); this.shardManager = new ShardManager('./structure/client/DiscordClient.js', options); + this.logger = new Logger(this); this.storageManager = new StorageManager(this, options.storage) .initialize(); - - this.logger = new Logger(this); this._built = false; diff --git a/logs/what.log b/logs/what.log index e96ff89..d723508 100644 --- a/logs/what.log +++ b/logs/what.log @@ -1,5 +1,91 @@ -debug: [04-13-2020 09:24:35][shard00] : Shard created. -info: [04-13-2020 09:24:35][shard00] : Component module:utility was loaded. -info: [04-13-2020 09:24:35][shard00] : Component command:ping was loaded. -info: [04-13-2020 09:24:35][shard00] : Component observer:commandHandler was loaded. -info: [04-13-2020 09:24:35][shard00] : Client connected to asfasf#1551 with 1 guild. + +debug: [04-14-2020 12:17:25][manager] : Initializing storage providers. +debug: [04-14-2020 12:17:25][shard00] : Shard created. +info: [04-14-2020 12:17:25][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:17:25][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:17:25][shard00] : Component observer:commandHandler was loaded. +debug: [04-14-2020 12:17:25][shard01] : Shard created. +info: [04-14-2020 12:17:25][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:20:34][manager] : Initializing storage providers. +debug: [04-14-2020 12:20:34][shard00] : Shard created. +info: [04-14-2020 12:20:35][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:20:35][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:20:35][shard00] : Component observer:commandHandler was loaded. +info: [04-14-2020 12:20:35][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:23:19][manager] : Initializing storage providers. +debug: [04-14-2020 12:23:19][shard00] : Shard created. +info: [04-14-2020 12:23:20][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:23:20][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:23:20][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:23:20][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:23:20][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:23:42][manager] : Initializing storage providers. +debug: [04-14-2020 12:23:42][shard00] : Shard created. +info: [04-14-2020 12:23:42][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:23:42][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:23:43][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:23:43][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:23:43][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:24:01][manager] : Initializing storage providers. +debug: [04-14-2020 12:24:01][shard00] : Shard created. +info: [04-14-2020 12:24:02][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:24:02][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:24:02][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:24:02][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:24:02][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:24:33][manager] : Initializing storage providers. +debug: [04-14-2020 12:24:33][shard00] : Shard created. +info: [04-14-2020 12:24:34][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:24:34][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:24:34][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:24:34][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:24:34][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:24:51][manager] : Initializing storage providers. +debug: [04-14-2020 12:24:52][shard00] : Shard created. +info: [04-14-2020 12:24:52][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:24:52][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:24:52][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:24:52][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:24:52][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:25:21][manager] : Initializing storage providers. +debug: [04-14-2020 12:25:21][shard00] : Shard created. +info: [04-14-2020 12:25:22][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:25:22][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:25:22][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:25:22][shard00] : Attempted to load an invalid class: "What". +info: [04-14-2020 12:25:22][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:26:11][manager] : Initializing storage providers. +debug: [04-14-2020 12:26:12][shard00] : Shard created. +debug: [04-14-2020 12:26:23][manager] : Initializing storage providers. +debug: [04-14-2020 12:26:23][shard00] : Shard created. +info: [04-14-2020 12:26:24][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:26:24][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:26:24][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:26:24][shard00] : Attempted to load an invalid class: "What". +info: [04-14-2020 12:26:24][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:26:53][manager] : Initializing storage providers. +debug: [04-14-2020 12:26:53][shard00] : Shard created. +debug: [04-14-2020 12:26:55][manager] : Initializing storage providers. +debug: [04-14-2020 12:26:55][shard00] : Shard created. +debug: [04-14-2020 12:26:57][manager] : Initializing storage providers. +debug: [04-14-2020 12:27:35][manager] : Initializing storage providers. +debug: [04-14-2020 12:27:36][shard00] : Shard created. +info: [04-14-2020 12:27:36][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:27:36][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:27:37][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:27:37][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:27:37][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:27:37][manager] : Initializing storage providers. +debug: [04-14-2020 12:39:31][manager] : Initializing storage providers. +debug: [04-14-2020 12:39:32][shard00] : Shard created. +info: [04-14-2020 12:39:32][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:39:32][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:39:32][shard00] : Component observer:commandHandler was loaded. +warn: [04-14-2020 12:39:32][shard00] : Attempted to load an invalid class. +info: [04-14-2020 12:39:32][shard00] : Client connected to asfasf#1551 with 1 guild. +debug: [04-14-2020 12:39:51][manager] : Initializing storage providers. +debug: [04-14-2020 12:39:51][shard00] : Shard created. +info: [04-14-2020 12:39:52][shard00] : Component module:utility was loaded. +info: [04-14-2020 12:39:52][shard00] : Component command:ping was loaded. +info: [04-14-2020 12:39:52][shard00] : Component observer:commandHandler was loaded. +info: [04-14-2020 12:39:52][shard00] : Client connected to asfasf#1551 with 1 guild. diff --git a/middleware/logger/Logger.js b/middleware/logger/Logger.js index f8c1f3e..52be859 100644 --- a/middleware/logger/Logger.js +++ b/middleware/logger/Logger.js @@ -1,4 +1,4 @@ -const { createLogger, format, transports, config } = require('winston'); +const { createLogger, format, transports: { Console }, config } = require('winston'); const { combine, label, printf } = format; const moment = require('moment'); const chalk = require('chalk'); @@ -29,7 +29,7 @@ class Logger { transports: [ new FileExtension({ filename: `logs/what.log`, level: 'debug'}), //Will NOT log "silly" logs, could change in future. new FileExtension({ filename: `logs/error.log` , level: 'error' }), - new transports.Console({ level: 'silly' }), //Will log EVERYTHING. + new Console({ level: 'silly' }), //Will log EVERYTHING. new DiscordWebhook({ level: 'error' }) //Broadcast errors to a discord webhook. ] }); @@ -37,7 +37,7 @@ class Logger { //TODO: Add proper date-oriented filenames and add a daily rotation file (?). this.shardManager - .on('shardCreate', (shard) => this.write(shard, "Shard created.", 'debug')) + .on('shardCreate', (shard) => this.write('debug', "Shard created.", shard)) .on('message', (shard, message) => this._handleMessage(shard, message)); } @@ -53,11 +53,11 @@ class Logger { || message._storage || message._webhook) return undefined; //Properties used for discord.js internal sharding & our own structures. must filter for. - await this.write(shard, message.message, message.type); + this.write(message.type, message.message, shard); } - async write(shard, string = '', type = 'silly') { + write(type = 'silly', string = '', shard = null) { const color = Constants.Colors[type]; const header = `${chalk[color](`[${this.date}][${shard ? `shard${this._shardId(shard)}` : 'manager'}]`)}`; diff --git a/storage/StorageManager.js b/storage/StorageManager.js index 00c65e3..1e5bcdd 100644 --- a/storage/StorageManager.js +++ b/storage/StorageManager.js @@ -6,15 +6,17 @@ class StorageManager { constructor(manager, options = {}) { - this.providers = new Collection(); this.manager = manager; + + this.providers = new Collection(); this.options = options; } async initialize() { - console.log('Initiating storage providers'); + this.manager.logger.write('debug', "Initializing storage providers."); + let _providers = path.join(process.cwd(), 'storage', 'providers'); let providers = fs.readdirSync(_providers); diff --git a/structure/client/Registry.js b/structure/client/Registry.js index 4fe713c..4431147 100644 --- a/structure/client/Registry.js +++ b/structure/client/Registry.js @@ -23,13 +23,13 @@ class Registry { for(const path of files) { const func = require(path); if(typeof func !== 'function') { - //this.client.logger.error("Attempted to index an invalid function as a component."); + this.client.logger.warn("Attempted to index an invalid function as a component."); continue; } const component = new func(this.client); //Instantiates the component class. if(classToHandle && !(component instanceof classToHandle)) { - //this.client.logger.error("Attempted to load an invalid class."); + this.client.logger.warn("Attempted to load an invalid class."); continue; } @@ -44,12 +44,12 @@ class Registry { async loadComponent(component, directory) { if(!(component instanceof Component)) { - //this.client.logger.error("Attempted to load an invalid component."); + this.client.logger.warn("Attempted to load an invalid component."); return null; } if(this.components.has(component.resolveable)) { - //this.client.logger.error("Attempted to reload an existing component."); + this.client.logger.warn("Attempted to reload an existing component."); return null; } diff --git a/structure/client/components/observers/CommandHandler.js b/structure/client/components/observers/CommandHandler.js index 8e34537..5a6c590 100644 --- a/structure/client/components/observers/CommandHandler.js +++ b/structure/client/components/observers/CommandHandler.js @@ -95,8 +95,6 @@ class CommandHandler extends Observer { const parsedArguments = await this._parseArguments(message, args); - - } async _handleInhibitors(message) {