From c5d6e0c5454ac24e15fac31a6393aa9442206bf5 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 12 Apr 2020 15:34:26 +0300 Subject: [PATCH] transporter -> logger --- structure/client/Logger.js | 62 +++++++++++++++++++++++++++++++++ structure/client/Transporter.js | 12 ------- 2 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 structure/client/Logger.js delete mode 100644 structure/client/Transporter.js diff --git a/structure/client/Logger.js b/structure/client/Logger.js new file mode 100644 index 0000000..0c67f41 --- /dev/null +++ b/structure/client/Logger.js @@ -0,0 +1,62 @@ +const chalk = require('chalk'); + +class Logger { + + constructor(client) { + + this.client = client; + + this.client.hooker.hook('ready', () => { + this.transport(`Client connected to ${chalk.bold(this.client.user.tag)} with ${chalk.bold(`${this.client.guilds.size} guild${this.client.guilds.size === 1 ? '' : 's'}`)}.`, { embed: true, type: 'SUCCESS' }); + }); + + this.client.hooker.hook('componentUpdate', ({ component, type }) => { + this.info(`Component ${chalk.bold(component.resolveable)} was ${chalk.bold(Constants.ComponentTypes[type])}.`); + }); + + this.client.hooker.hook('reconnect', () => { + this.warn(`Shard is reconnecting.`, { embed: true }); + }); + + } + + async transport(message = 'N/A', opts = {}) { + process.send({ message, ...opts }); + } + + /* Quick & Dirty Functions */ + + log(message, opts = {}) { + this.transport(message, { ...opts, type: 'LOG' }); + } + + info(message, opts = {}) { + this.transport(message, { ...opts, type: 'INFO' }); + } + + warn(message, opts = {}) { + this.transport(message, { ...opts, type: 'WARN' }); + } + + debug(message, opts = {}) { + this.transport(message, { ...opts, type: 'DEBUG' }); + } + + error(message, opts = {}) { + this.transport(message, { ...opts, type: 'ERROR' }); + } + + +} + +module.exports = Logger; + +const Constants = { + ComponentTypes: { + LOAD: 'loaded', + UNLOAD: 'unloaded', + RELOAD: 'reloaded', + ENABLE: 'enabled', + DISABLE: 'disabled' + } +}; \ No newline at end of file diff --git a/structure/client/Transporter.js b/structure/client/Transporter.js deleted file mode 100644 index 0e3b656..0000000 --- a/structure/client/Transporter.js +++ /dev/null @@ -1,12 +0,0 @@ -class Transporter { - - constructor(manager) { - - this.manager = manager; - - } - - -} - -module.exports = Transporter; \ No newline at end of file