67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
const chalk = require('chalk');
|
|
|
|
class Logger {
|
|
|
|
constructor(client) {
|
|
|
|
this.client = client;
|
|
|
|
this.client.eventHooker.hook('ready', () => {
|
|
const guilds = this.client.guilds.cache.size;
|
|
this.info(`Client connected to ${chalk.bold(this.client.user.tag)} with ${chalk.bold(`${guilds} guild${guilds === 1 ? '' : 's'}`)}.`);
|
|
});
|
|
|
|
this.client.eventHooker.hook('componentUpdate', ({ component, type }) => {
|
|
this.info(`Component ${chalk.bold(component.resolveable)} was ${chalk.bold(Constants.ComponentTypes[type])}.`);
|
|
});
|
|
|
|
this.client.eventHooker.hook('reconnect', () => {
|
|
this.warn(`Shard is reconnecting.`);
|
|
});
|
|
|
|
}
|
|
|
|
async transport(message = 'N/A', opts = {}) {
|
|
process.send({ message, ...opts });
|
|
}
|
|
|
|
/* Quick & Dirty Functions */
|
|
|
|
silly(message, opts = {}) {
|
|
this.transport(message, { ...opts, type: 'silly' });
|
|
}
|
|
|
|
debug(message, opts = {}) {
|
|
this.transport(message, { ...opts, type: 'debug' });
|
|
}
|
|
|
|
verbose(message, opts = {}) {
|
|
this.transport(message, { ...opts, type: 'verbose' });
|
|
}
|
|
|
|
info(message, opts = {}) {
|
|
this.transport(message, { ...opts, type: 'info' });
|
|
}
|
|
|
|
warn(message, opts = {}) {
|
|
this.transport(message, { ...opts, type: 'warn' });
|
|
}
|
|
|
|
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'
|
|
}
|
|
}; |